0
I’m using a new PayPal java script sdk not checkout.js.
I need to send payment to different merchant IDs, but it seems to work only with my merchant ID where I created a SandBox as PayPal Specifications in order to use different Merchants.
I call my client ID in the header index.html as below:
And below it is my checkout script where I would like to use different merchant ID based on the object to sell. I put the specific merchant email or merchant ID in payee command, as I suppose is wrote in the PayPal instructions, for that object. The merchant should be different depend on the object to sell, but PayPal give me an error that I’m using a different payee from the client ID. Where am I wrong?
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);
}