我正在使用新的PayPal Java脚本sdk而不是checkout.js。
我需要将付款发送到不同的商家ID,但是它似乎只能与我的商家ID配合使用,在该商家中我创建了一个SandPad作为PayPal规范,以便使用不同的商家。
我在标题index.html中调用我的客户ID,如下所示:
下面是我的结帐脚本,我想根据要出售的商品使用不同的商家ID。我将特定的商家电子邮件或商家ID放入该对象的Payee命令中,就像我在PayPal指令中写的那样。商家应该根据出售的对象而有所不同,但是PayPal给我一个错误,我使用的是与客户ID不同的收款人。我在哪里错了?
initPayPal(){
var _totaleOrdine = this.totaleOrdine.toString();
var _merchant: string = 'XXXXXXXXX';
paypal.Buttons({
env: 'sandbox', // sandbox | production
locale: 'it_IT',
//ref: https://developer.paypal.com/docs/integration/direct/express-checkout/integration-jsv4/customize-button/
style: {
size: 'responsive',
color: 'gold',
shape: 'pill',
label: 'buynow', // label: checkout, buynow, credit, pay, paypal
tagline: false
},
commit: true,
debug: true,
createOrder: function(data, actions) {
// Set up the transaction
console.log(data);
console.log(actions);
return actions.order.create({
application_context: {
brand_name: "MyBrand",
},
purchase_units: [{
// reference_id:_merchant,
amount: {
value: _totaleOrdine,
},
payee: {
email: 'merchant2@mydomain.it',
merchant_id: 'xxxxx'
},
shipping: {
address: {
address_line_1: "Via Roma 10",
address_line_2: "",
admin_area_2: "Roma",
admin_area_1: "RM",
postal_code: "00100",
country_code: "IT",
},
name:{
full_name: "adam adami"
},
},
}],
});
},
onApprove: function(data, actions) {
return actions.order.capture().then(function(details) {
alert('Transaction completed by ' + details.payer.name.given_name);
console.log(details);
// Call your server to save the transaction
return fetch('/paypal-transaction-complete', {
method: 'post',
body: JSON.stringify({
orderID: data.orderID
})
});
//
});
},
onCancel: function(data, actions) {
/*
* Buyer cancelled the payment
*/
console.log("Buyer cancelled the payment");
},
onError: function(err) {
/*
* An error occurred during the transaction
*/
console.log(err);
console.log("An error occurred during the transaction");
}
}).render(this.paypalbuttoncontainer2);
}