<div id="paypal-button"></div>
<script src="https://www.paypalobjects.com/api/checkout.js"></script>
<script>
paypal.Button.render({
client: { sandbox: 'sandboxemailaddress',
production: 'dummyemailaddress'},
env: 'sandbox',
payment: function() {
var env = this.props.env;
var client = this.props.client;
return paypal.rest.payment.create(this.props.env, this.props.client, {
transactions: [
{
amount: {total: 20.00, currency: 'USD' },
locale: 'en_US',
enableShippingAddress: true,
shippingAddressEditable: false,
shippingAddressOverride: {
recipientName: 'John Public',
line1: '123 South East St',
line2: '',
city: 'Upland',
state: 'CA',
postalCode: '91711',
countryCode: 'US',
countryCode: 'US',
phone: '909-626-3777'
}
}
],
});
},
commit: true,
onAuthorize: function(data, actions) {
return actions.payment.execute().then(function() {
});
},
'#paypal-button');
</script>
按钮显示没有报告错误。 点击按钮后,屏幕上会打开框,出现等待圈,然后框就会出现。 Firefox报告中的Javascript控制台:
window.paypal<["./node_modules/post-robot/src/drivers/receive/types.js"]/exports.RECEIVE_MESSAGE_TYPES< https://www.paypalobjects.com/api/checkout.js:3416:40
receiveMessage https://www.paypalobjects.com/api/checkout.js:1838:13
messageListener https://www.paypalobjects.com/api/checkout.js:1856:13