Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

javascript variables on PayPal button

44 views
Skip to first unread message

Daniele Ferrarese

unread,
Mar 4, 2022, 9:52:27 AM3/4/22
to
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&currency=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

Kristjan Robam

unread,
Apr 4, 2022, 7:07:04 AM4/4/22
to
Something for You.

Can You help me out with 2100 euros ?

I want to buy a new Iphone.



Kristjan Robam

Ace of diamonds

unread,
Jul 6, 2022, 12:18:25 PM7/6/22
to
Hey guy. Would You want to get rich with me doing programming? If yes, call me !!!!!!!!!

✆☎☏📱📞 : 372 53900660


Daniele Ferrarese kirjutas Reede, 4. märts 2022 kl 16:52:27 UTC+2:
0 new messages