简体   繁体   中英

Paypal Smart Buttons: Get clicked button

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?

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,

details.payer

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,

details.payer.payment_source_response

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM