A greeting to all participants in the NG
I'm trying to insert the HTML code, from PayPal, to insert a button "bynow" on my ecommerce (see code)
<div id="smart-button-container">
<div style="text-align: center;">
<div id="paypal-button-container"></div>
</div>
</div>
<script src="https://www.paypal.com/sdk/js?client-id=my_id&enable-funding=venmo¤cy=EUR" data-sdk-integration-source="button-factory"></script>
<script>
function initPayPalButton() {
paypal.Buttons({
style: {
shape: 'rect',
color: 'gold',
layout: 'vertical',
label: 'paypal',
},
createOrder: function(data, actions) {
return actions.order.create({
purchase_units: [{"description":"Order N.","amount":{"currency_code":"EUR","value":10}}]
});
},
onApprove: function(data, actions) {
return actions.order.capture().then(function(orderData) {
// Full available details
console.log('Capture result', orderData, JSON.stringify(orderData, null, 2));
// Show a success message within this page, e.g.
const element = document.getElementById('paypal-button-container'); element.innerHTML = '';
element.innerHTML = '<h3>Thank you for your payment!</h3>';
// Or go to another URL: actions.redirect('thank_you.html');
});
},
onError: function(err) {
console.log(err);
}
}).render('#paypal-button-container');
}
initPayPalButton();
</script>
trying to replace "description:Order N." with a variable $_SESSION['customer_id'], and total EUR 10 with variable $_SESSION['total_order'] already in my checkout page. I'm not able to find the right syntax.
Besides I would like, if payment success, activate function "validateForm()" which is sending all records to database.
Thank you for help.
Rgds.
Daniele
A greeting to all participants in the NG
I'm trying to insert the HTML code, from PayPal, to insert a button "bynow" on my ecommerce (see code)
<div id="smart-button-container">
<div style="text-align: center;">
<div id="paypal-button-container"></div>
</div>
</div>
<script src="https://www.paypal.com/sdk/js?client-id=my_id&enable-funding=venmo¤cy=EUR" data-sdk-integration-source="button-factory"></script>
<script>
function initPayPalButton() {
paypal.Buttons({
style: {
shape: 'rect',
color: 'gold',
layout: 'vertical',
label: 'paypal',
},
createOrder: function(data, actions) {
return actions.order.create({
purchase_units: [{"description":"Order N.","amount":{"currency_code":"EUR","value":10}}]
});
},
onApprove: function(data, actions) {
return actions.order.capture().then(function(orderData) {
// Full available details
console.log('Capture result', orderData, JSON.stringify(orderData, null, 2));
// Show a success message within this page, e.g.
const element = document.getElementById('paypal-button-container'); element.innerHTML = '';
element.innerHTML = '<h3>Thank you for your payment!</h3>';
// Or go to another URL: actions.redirect('thank_you.html');
});
},
onError: function(err) {
console.log(err);
}
}).render('#paypal-button-container');
}
initPayPalButton();
</script>
trying to replace "description:Order N." with a variable $_SESSION['customer_id'], and total EUR 10 with variable $_SESSION['total_order'] already in my checkout page. I'm not able to find the right syntax.
Besides I would like, if payment success, activate function "validateForm()" which is sending all records to database.
Thank you for help.
Rgds.
Daniele
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 415 |
Nodes: | 16 (2 / 14) |
Uptime: | 50:44:21 |
Calls: | 8,728 |
Calls today: | 1 |
Files: | 13,276 |
Messages: | 5,958,181 |