Search code examples
paypalpaypal-sandboxpaypal-rest-sdk

How i can get the payment_source in the order capture response of API PayPal?


I am using the PayPal API to create and capture payment orders. I would like to know if it is possible to obtain the card data, payment method and the name of the cardholder after capturing the order? So far I only get it to return the payment amount, its description and its reference id, but according to the API it should also return an object called payment_source, which I can't see.

I'll paste the response I get:

{
    "id": "2LN68665F4466933X",
    "intent": "CAPTURE",
    "status": "COMPLETED",
    "purchase_units": [
        {
            "reference_id": "123456",
            "amount": {
                "currency_code": "MXN",
                "value": "1.00"
            },
            "payee": {
                "email_address": "[email protected]",
                "merchant_id": "ACGFSQTV9DKWN",
                "display_data": {
                    "brand_name": "ONLINE STORE"
                }
            },
            "description": "Studies Payment",
            "soft_descriptor": "PAYPAL *TEST STORE",
            "payments": {
                "captures": [
                    {
                        "id": "2K6883372G5768117",
                        "status": "COMPLETED",
                        "amount": {
                            "currency_code": "MXN",
                            "value": "1.00"
                        },
                        "final_capture": true,
                        "seller_protection": {
                            "status": "ELIGIBLE",
                            "dispute_categories": [
                                "ITEM_NOT_RECEIVED",
                                "UNAUTHORIZED_TRANSACTION"
                            ]
                        },
                        "seller_receivable_breakdown": {
                            "gross_amount": {
                                "currency_code": "MXN",
                                "value": "1.00"
                            },
                            "paypal_fee": {
                                "currency_code": "MXN",
                                "value": "1.00"
                            },
                            "net_amount": {
                                "currency_code": "MXN",
                                "value": "0.00"
                            }
                        },
                        "links": [
                            {
                                "href": "https://api.sandbox.paypal.com/v2/payments/captures/2K6883372G5768117",
                                "rel": "self",
                                "method": "GET"
                            },
                            {
                                "href": "https://api.sandbox.paypal.com/v2/payments/captures/2K6883372G5768117/refund",
                                "rel": "refund",
                                "method": "POST"
                            },
                            {
                                "href": "https://api.sandbox.paypal.com/v2/checkout/orders/2LN68665F4466933X",
                                "rel": "up",
                                "method": "GET"
                            }
                        ],
                        "create_time": "2022-01-21T18:30:53Z",
                        "update_time": "2022-01-21T18:30:53Z"
                    }
                ]
            }
        }
    ],
    "payer": {
        "name": {
            "given_name": "John",
            "surname": "Doe"
        },
        "email_address": "[email protected]",
        "payer_id": "DW9FW6ALYZ6EG",
        "address": {
            "country_code": "MX"
        }
    },
    "create_time": "2022-01-21T18:29:37Z",
    "update_time": "2022-01-21T18:30:53Z",
    "links": [
        {
            "href": "https://api.sandbox.paypal.com/v2/checkout/orders/2LN68665F4466933X",
            "rel": "self",
            "method": "GET"
        }
    ]
}

Thanks in advance.


Solution

  • No, it is not possible for a normal PayPal Checkout. Customer billing information (e.g. whether they paid with a card or some other funding source) is kept private by design.

    Payment source information only exists when integrating with Advanced custom card fields, which is an add-on hosted fields integration and requires applying to enable it and additional development to present the alternate hosted fields checkout below the regular PayPal button.