New to the community? Welcome! Please read our Community Rules and Guidelines
Pay, shop, and do even more on the PayPal appGet the App
Hello PayPal Community,
I tried to update our PayPal payment button to the latest version, I pasted the following code to my webpage, but the PayPal payment button does not show up at all when I launch the page. Are there any errors in my code? Please help, thank you very much for your time and effort.
>>>>>>>>>>>>>>>>>>>>>>>>>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1"> </head>
<body>
<script src="https://www.paypal.com/sdk/js?client-id=MY-ID¤cy=USD"></script> <!-- Set up a container element for the button --> <div id="paypal-button-container"></div> <script> paypal.Buttons({ // Sets up the transaction when a payment button is clicked createOrder: (data, actions) => { return actions.order.create({ purchase_units: [{ amount: { value: '121.88' // Can also reference a variable or function } description: { value: 'Online Transaction (g_1-2097_1-2327)' } invoice_id: { value: 'Online Order ID' } payee: { email: { value: 'Customer's email address' } } }] }); }, // Finalize the transaction after payer approval onApprove: (data, actions) => { return actions.order.capture().then(function(orderData) { // Successful capture! For dev/demo purposes: console.log('Capture result', orderData, JSON.stringify(orderData, null, 2)); const transaction = orderData.purchase_units[0].payments.captures[0]; alert(`Transaction ${transaction.status}: ${transaction.id}\n\nSee console for all available details`); // When ready to go live, remove the alert and show a success message within this page. For example: // const element = document.getElementById('paypal-button-container'); actions.redirect('https://www.test.com/AcceptPayment'); }); } }).render('#paypal-button-container'); </script>
</body
©1999-2023 PayPal, Inc. All rights reserved.