I am currently trying to add PayPal
into my Ionic 2 application referring by referring to this link
In PayPal Sandbox environment, I don't get why Credit Card is not shown in my PayPal payment options after I login with the sandbox buyer account.
Here is my code to connect to PayPal:
payViaPaypal() {
let env = this;
this.payPal.init({
PayPalEnvironmentProduction: paypal.PayPalEnvironmentProduction,
PayPalEnvironmentSandbox: paypal.PayPalEnvironmentSandbox
}).then(() => {
env.payPal.prepareToRender(paypal.CurrentEnvironment, new PayPalConfiguration({})).then(() => {
let payment = new PayPalPayment('3.33', 'MYR', 'Description', 'sale');
env.payPal.renderSinglePaymentUI(payment).then((result) => {
if (result.response.state == "approved") {
console.log("Success!")
}
}, () => {
console.error('Error or render dialog closed without being successful');
});
}, () => {
console.error('Error in configuration');
});
}, () => {
console.error('Error in initialization, maybe PayPal isn\'t supported or something else');
});
}
The reason the credit cards in this account are not showing is that I am using MYR as currency in my PayPal Sandbox environment. In PayPal Sandbox environment, only USD is allowed for any credit card transaction, otherwise, you will receive an error when you made credit card transaction using other currencies. Therefore, after I changed the currency to USD, everything works fine for me.