我在使用REST API时遇到问题 paypal-checkout javascript集成 (https://github.com/paypal/paypal-checkout)将第三方设为 付款接收方。
根据这个
https://devblog.paypal.com/setting-payee/
现在应该允许第三方收款人。正确的吗?
事情的核心似乎是这个电话:
paypal.rest.payment.create(button_member.env,
button_member.client,
pp_data_member);
其中button_member.env是"沙盒"
和button_member.client是
{"sandbox":"Ab**********0O","production":"AW**********38"}
当pp_data_member为
时{"intent":"authorize",
"payer":{"payment_method":"paypal"},
"transactions":[
{ "amount":{"total":"5.50",
"currency":"USD",
"details":{
"subtotal":"5.00","tax":"0.00","shipping":"0.50"
}},
"payee":{"email":"development-facilitator@troc*****.com"},
"soft_descriptor":"ZenKitsch",
"notify_url":
"https://www.trocadero.com/_internal/alpha/**********",
"description":"Your Zen Kitsch order of September 16, 2017",
"invoice_number":"CHKT-zenkitsch-479618-SV16M8PSFG",
"item_list":{
"items":[{"sku":"844697","name":"United Airlines Beverage Menu Card","quantity":"1","price":"5.00","currency":"USD"}]
}
}
]
}
一切正常。但是当我将收款人设置为不同的沙箱地址时 没有别的变化:
...
"payee":{"email":"development-seller@troc*****.com"},
...
在我使用买家沙箱登录后,我按预期获得了弹出窗口 帐户并确认购买,我从API获得了失败,a 400状态代码和"意外事件":" PERMISSION_DENIED"错误讯息:
Request URL: https://www.sandbox.paypal.com/webapps/hermes/api/payment/PAY-9TX329794L770414LLG6YSZQ/execute
Request Method:POST
Status Code:400 Bad Request
Remote Address:173.0.82.77:443
{"ack":"contingency",
"contingency":"PERMISSION_DENIED",
"meta":
{"calc":"e305762ccebe",
"rlog":"7Jz2DIxLg7B25ErQ1yIJI2shyI%2FIqDJZY2fbMMEef%2FVnBUNHVn2YYp4ptK5fN6DoGzjRHFjL6nRZkZqdnHIRwQ_15e8c60e8a8"
},
"server":"6ajNNYfBIhVmBs2ogHWhF35ezBlTaOHlCtx2erpwzk-5XmIY9isE5Hk07x5GBputw5DXmqsjLE71y3mJtJHw6TPBWcgBGzPpOkEXIWpJVOPsgsani23mTTQPfrrhKtd2pLLSFQDXQ0ISqpWOC0vZa4DvUshowfLFfFn_oNyAB_gquO5vWd1wIZOEp8z6EiUAnjsDBhCv1K1xBjn6KsOFyczIThuWeoh86RnPLJnhzpqXWAuSDCof_00kGVXCskQDxDqLpa4-0Ry"
}
任何帮助非常感谢。谢谢!
编辑添加:小代码来演示此问题。收款人设置为应用程序所有者的第一个按钮工作,第二个按钮失败,错误可能是控制台中的ssen。
<html><head><title>PP Button Test</title></head>
<body>
<script src="https://www.paypalobjects.com/api/checkout.js" data-version-4></script>
<div id="myContainerElement1"></div>
<hr>
<div id="myContainerElement2"></div>
<script>
paypal.Button.render({
client: {
sandbox: 'AbR*****T0O',
production: 'xxxxxxxxx'
},
payment: function(data, actions) {
return actions.payment.create({
transactions: [
{
amount: {
total: '1.00',
currency: 'USD'
},
payee:{email:'development-facilitator@troc*****.com'},
}
]
});
},
commit: true,
locale: 'en_US',
style: {
size: 'medium', // tiny, small, medium
color: 'blue', // orange, blue, silver
shape: 'pill' // pill, rect
},
env: 'sandbox', // Optional: specify 'sandbox' or 'production'
onAuthorize: function(data, actions) {
return actions.payment.execute().then(function(response) {
console.log('payment 1 completed!');
});
},
onCancel: function(data) {
console.log('payment 1 was cancelled!');
}
}, '#myContainerElement1');
paypal.Button.render({
client: {
sandbox: 'AbRF38w5WaF4qE3nSr_JLsxdGGOEGSpS4wxI8HbW-QYcnISvpmPEc-hJfUemR1k57IrCKwBDNamV9T0O',
production: 'xxxxxxxxx'
},
payment: function(data, actions) {
return actions.payment.create({
transactions: [
{
amount: {
total: '1.00',
currency: 'USD'
},
payee:{email:'development-seller@troc*****.com'},
}
]
});
},
commit: true,
locale: 'en_US',
style: {
size: 'medium', // tiny, small, medium
color: 'blue', // orange, blue, silver
shape: 'pill' // pill, rect
},
env: 'sandbox', // Optional: specify 'sandbox' or 'production'
onAuthorize: function(data, actions) {
return actions.payment.execute().then(function(response) {
console.log('payment 2 completed!');
});
},
onCancel: function(data) {
console.log('payment 2 was cancelled!');
}
}, '#myContainerElement2');
</script>
</body></html>