I added the Paypal Smart Buttons API to my website, with the following code:
paypal.Buttons({
createOrder: function(data, actions) {
return actions.order.create({
purchase_units: [{ amount: { value: 0.01 } }],
});
},
onApprove: function(data, actions) {},
onClick: function(){
//HERE I WANT TO GET THE PAYPAL’S BUTTON WHICH HAS BEEN CLICKED.
},
}).render('#paypal-button-container');
Is there any way to get the clicked button?
2
Answers
Which funding source a payer has used within PayPal is kept private by design. All you see is whether they have completed a PayPal payment.
I think you cannot know the clicked button. However, after completing the payment, you can know which button has been clicked based on the payment. After approving the payment, you can access the payer details like this,
You can see the attributes of the payer from this link:
PayPal API, Orders, Payer Definition
For example you can check payment_source_response like this,