When rendering a paypal button in angular like so:
@ViewChild("paypalRef", { static: false }) private paypalRef: ElementRef;
renderPaypalButton() {
this.paypalSelected = true;
if (this.paypalButtonRendered != true) {
paypal
.Buttons({
style: {
layout: "horizontal",
color: "white",
label: "",
},
createOrder: (data, actions) => {
return actions.order.create({
purchase_units: [
{
amount: {
value: "1000",
currency_code: "zar",
},
},
],
});
},
})
.render(this.paypalRef.nativeElement);
}
this.paypalButtonRendered = true;
}
the PayPal pop up displays for a split second and then disappears. However, as soon as I remove the createOrder function, the PayPal pop up displays as normal. I am sure there is just something I am doing wrong, but any help would be appreciated thanks.
CodePudding user response:
the PayPal pop up displays for a split second and then disappears.
In general, look at the browser Javascript console and/or Dev Tools "Network" tab log to find the reason for the error.
currency_code: "zar",
For this particular situation, we can see that this is not a PayPal API supported currency.
Generally transactions must be denominated in a common international currency such as USD instead. If the payer has a funding source in a local currency like ZAR, such as a local card, the conversion will be shown to them during checkout. You will receive the transaction currency (again, typically USD)
