Receive payments in different accounts on same page with multiple smart buttons
hassan_k011
Contributor
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on
May-31-2021
10:58 PM
Hi Guys.
i have two paypal accounts for which i need to receive payments using smart buttons for each account on same page. i am using Javascript sdk. now in my code i have initialize on smart button against one client id.
<script src="https://www.paypal.com/sdk/js?client-id={my-client-id}¤cy=USD&disable-funding=credit" data-sdk-integration-source="button-factory"></script>
function internationalPayment() {
var description = document.querySelector('#international-button-container #international_description');
var amount = document.querySelector('#international-button-container #international_amount');
var descriptionError = document.querySelector('#international-button-container #internationalDescriptionError');
var priceError = document.querySelector('#international-button-container #internationalPriceLabelError');
var invoiceid = document.querySelector('#international-button-container #invoice_id');
var invoiceidError = document.querySelector('#international-button-container #invoiceid_Error');
var invoiceidDiv = document.querySelector('#international-button-container #invoice_id_div');
var elArr = [description, amount];
console.log(invoiceidDiv.firstChild);
// invoiceidDiv.style.display = "block";
var purchase_units = [];
purchase_units[0] = {};
purchase_units[0].amount = {};
function validate(event) {
return event.value.length > 0;
}
paypal.Buttons({
style: {
color: 'gold',
shape: 'rect',
label: 'paypal',
layout: 'vertical',
},
onInit: function (data, actions) {
actions.disable();
if(invoiceidDiv.style.display === "block") {
elArr.push(invoiceid);
}
elArr.forEach(function (item) {
item.addEventListener('keyup', function (event) {
var result = elArr.every(validate);
if (result) {
actions.enable();
} else {
actions.disable();
}
});
});
},
onClick: function () {
if (description.value.length < 1) {
descriptionError.style.visibility = "visible";
} else {
descriptionError.style.visibility = "hidden";
}
if (amount.value.length < 1) {
priceError.style.visibility = "visible";
} else {
priceError.style.visibility = "hidden";
}
if (invoiceid.value.length < 1 && invoiceidDiv.style.display === "block") {
invoiceidError.style.visibility = "visible";
} else {
invoiceidError.style.visibility = "hidden";
}
purchase_units[0].description = description.value;
purchase_units[0].amount.value = amount.value;
if(invoiceid.value !== '') {
purchase_units[0].invoice_id = invoiceid.value;
}
},
createOrder: function (data, actions) {
return actions.order.create({
purchase_units: purchase_units,
});
},
onApprove: function (data, actions) {
return actions.order.capture().then(function (details) {
alert('Transaction completed by ' + details.payer.name.given_name + '!');
});
},
onError: function (err) {
console.log(err);
}
}).render('#international_payment_button');
}
internationalPayment();
the question is how can i initialize paypal script with another Client ID on same page ?
Labels:
- Labels:
-
PayPal Buttons
0 REPLIES 0
Haven't Found your Answer?
It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.
Related Content
- Can't find my current billing statement on my account page. in Reporting Archives
- How do we set up a staff account on Zettle or Paypal Here in Merchant Products and Services Archives
- Would like to have subscription capabilities for my shopify account. in Merchant Products and Services Archives
- How long does it take a credit card transaction to show up in my PayPal account? in Merchant Products and Services Archives
- Merchant card processor account in Business Tools Archives