Reputation: 1048
I am loading individual payments method under their own div container:
<br>
div id="paypal-button-container_paypal"<br>
div id=="paypal-button-container_card"<br>
div id=="paypal-button-container_sofort"<br>
let FUNDING_SOURCES = [
paypal.FUNDING.PAYPAL,
paypal.FUNDING.CARD,
paypal.FUNDING.SOFORT
];
FUNDING_SOURCES.forEach(function (fundingSource) {
var button = paypal.Buttons({
fundingSource: fundingSource,
})
button.render('#paypal-button-container_'+fundingSource)
});
How can I trigger the following functions,
createOrder onApprove onInit onClick onCancel
etc... in the above code?
If I do it within the loop, each of the actions will be repeated multiple times.
Do I have to do the following for each of the payment buttons: https://developer.paypal.com/docs/checkout/apm/sofort/#link-renderpaymentbutton (if so then, is not the same code repeating again & again?)
Need your help on this. Help would be appreciated. Thank you.
Upvotes: 0
Views: 76
Reputation: 30359
Put the callback functions (createOrder, onApprove, etc) inside paypal.Buttons({...})
.
They will be called at the appropriate time, for example createOrder occurs after a button is clicked.
Upvotes: 1