How to get the last 4 digits of the card number
Closed this issue · 1 comments
How to get the last 4 digits of the card number after the user's online payment in the API?
or API documents?
When the user pays for the transaction, there are no 4 digits of the card number in the order details or webhook data.
Hey @shaw-01.
For Orders, you'd need to look at the last digits value on the response, something like this: $order->getPaymentSource()->getCard()->getLastDigits()
. This will contain whatever digits the API has sent for that card, though it's possible that only the last 2 digits, not the last 4, are returned.
For Webhooks, how you access it would vary as this SDK does not currently implement Webhook functionality. The path on the webhook is almost the same, as the payload is essentially just an order. Something like this resource -> payment_source -> card -> last_digits
.
The SDK docs show that value on the model associated to the card here, and the REST API docs show this field here.