我已将PayPal与我的angular 2应用程序与REST API应用程序集成在一起。它可以在沙盒环境中正常工作,但不能在实时环境中工作。共享我使用的代码:
paypalConfig = {
env: 'production',
client: {
sandbox: 'my_sandbox_client_key',
production: 'my_live_client_key'
},
commit: true,
style: {
color: 'gold', // 'gold, 'blue', 'silver', 'black'
size: 'medium', // 'medium', 'small', 'large', 'responsive'
shape: 'pill' // 'rect', 'pill'
},
payment: (data, actions) => {
return actions.payment.create({
payment: {
transactions: [
{ amount: { total: this.finalAmount, currency: 'USD' } }
]
}
});
},
onAuthorize: (data, actions) => {
return actions.payment.execute().then((payment) => {
//Do something when payment is successful.
alert('Payment Successful, Thank You!');
})
}};
ngAfterViewChecked(): void {
if (!this.addScript) {
this.addPaypalScript().then(() => {
paypal.Button.render(this.paypalConfig, '#paypal-checkout-btn');
this.paypalLoad = false;
})
}
}
addPaypalScript() {
this.addScript = true;
return new Promise((resolve, reject) => {
let scripttagElement = document.createElement('script');
scripttagElement.src = 'https://www.paypalobjects.com/api/checkout.js';
scripttagElement.onload = resolve;
document.body.appendChild(scripttagElement);
})
}
这是我收到的失败消息:
Screenshot of PayPal's US account for live transaction failed
谢谢。