I’m developing a payment system with PayPal API. Everything works except that the transaction is in USD and not SGD (like how I want it to be).
PayPal Button from react-paypal-button-v2
<PayPalButton
currency='SGD'
amount={parcel.basePrice}
onSuccess={successPaymentHandler}
/>
Script to add PayPal button
const addPayPalScript = () => {
const script = document.createElement("script");
script.type = "text/javascript";
script.src =
"https://www.paypal.com/sdk/js?client-id=CLIENT_ID¤cy=SGD";
script.async = true;
script.onload = () => {
setSdkReady(true);
};
document.body.appendChild(script);
};
I followed the documentation here. https://developer.paypal.com/docs/checkout/reference/customize-sdk/
2
Answers
SGD is a PayPal supported currency, and your code’s usage appears correct according to the documentation for that unofficial react-paypal-button-v2 component, so I’m not sure what’s going wrong here.
Try the newer official @paypal/react-paypal-js instead.
You can use the currency inside options rather than as a props in component code will be like