如何实时集成PayPal帐户



我们目前无法使用您的PayPal帐户处理您的付款。请返回商家并尝试使用其他付款方式 如何使用 Angular6 使PayPal帐户生效,我已经尝试过使用此代码,但它不起作用,它在沙盒中工作正常,但在生产级别上不起作用

**code**
import { Component,AfterViewChecked  } from '@angular/core';
declare let paypal: any;
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent implements AfterViewChecked {
addScript: boolean = false;
paypalLoad: boolean = true;
finalAmount: number = 1;
paypalConfig = {
env: 'production',
client: {
//sandbox: '';
production:'';
},
commit: true,
payment: (data, actions) => {
return actions.payment.create({
payment: {
transactions: [
{ amount: { total: this.finalAmount, currency: 'USD' } }
]
}
});
},
onAuthorize: (data, actions) => {
return actions.payment.execute().then((payment) => {
alert('Transaction completed');
//Do something when payment is successful.
})
}
};
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);
})
}
}

当您从沙盒切换到生产模式时,事情应该可以正常工作 - 请确保传递正确的凭据。 上述错误可能由于各种原因而发生,需要更多详细信息来调查该问题,因此建议您在支持团队PayPal提出查询票证 https://www.paypal-support.com/s/?language=en_US

最新更新