2
votes

I've integrated the new paypal checkout order using smart payment buttons (https://developer.paypal.com/docs/checkout/#). It's working quite well allowing me to let the User pay with a Credit Card or SEPA without a paypal account:

paypal.Buttons({
  // ...
  createOrder(data, actions) {
},
  // ...
  onApprove(data, actions) {
  // data.orderID available here

Now in the User's order overview I want to display which type of payment was used and not only that they used paypal to pay me. However I cannot find a way to get that information using the @paypal/checkout-server-sdk nor the paypal-rest-sdk because all I have is the CheckoutOrder and the Capture objects.

The orderID from the client can be used in my backend to get the Order details:

paypalCheckoutSdk.orders.OrdersGetRequest(payload.orderID)

But all I get is this stuff:

"result": {
    "id": "6CC44267CA709615A",
    "intent": "CAPTURE",
    "purchase_units": [{
        "reference_id": "default",
        "amount": { ... },
        "payee": { ... },
        "shipping": {
            "name": { ... },
            "address": { ... }
        },
        "payments": {
            "captures": [{
                "id": "2GP872418N1179401",
                "status": "COMPLETED",
                "amount": { ... },
                "final_capture": true,
                "seller_protection": {...},
                "links": [...],
                ...
            }]
        }
    }],
    "payer": { ... },
    "status": "COMPLETED"
}

No information about the credit card that was used, not even that is was a credit card and not a paypal account.

If I try to use the paypal-rest-sdk the Order cannot even be found by that ID. Must be some special checkout order.

The Capture object paypalOrder.result.purchase_units[0].payments.captures[0].id does not help either. It's quite bare and offers nothing that the Order did not already tell me. No link to anywhere. The captureId does not allow me to search for a transaction or payment.

If I log into the sandbox seller account, the order does not show which payment type was used either. Is that information just lost? Or is there a way to retrieve it?

Thanks!

1

1 Answers

3
votes

For this payment, 2GP872418N1179401 is the PayPal transaction ID in the seller account. It is the ID you should record in your business accounting database on capture completion, as it is what you can later reference in the seller (sandbox.)paypal.com account and reports for years to come.

The top level 6CC44267CA709615A is more ephemeral, I believe that's the checkout's order ID you started with and so it's only used for the payment approval. I'm not sure when exactly it expires but you should only keep it around awhile for debug purposes, it has no business/accounting value.

As for finding out what type of payment was used, PayPal keeps that information private to the payer in their design. Whether they used a particular Visa, MC, Amex, Discover, PayPal Credit, their balance, or some other local funding source.... that's the buyer's business; all the seller knows is they received a payment through PayPal. This said to be for security and privacy, so that if any seller's site is ever compromised, the buyer's billing information is not exposed.