My paypal smart buttons are showing but not working when I touch them
NR221
New Community Member
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on
May-13-2023
12:27 AM
I have applied this oode <!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> </head> <body> <!-- Replace "test" with your own sandbox Business account app client ID --> <script src="https://www.paypal.com/sdk/js?client-id=test¤cy=USD"></script> <!-- Set up a container element for the button --> <div id="paypal-button-container"></div> <script> paypal.Buttons({ // Order is created on the server and the order id is returned createOrder() { return fetch("/my-server/create-paypal-order", { method: "POST", headers: { "Content-Type": "application/json", }, // use the "body" param to optionally pass additional order information // like product skus and quantities body: JSON.stringify({ cart: [ { sku: "YOUR_PRODUCT_STOCK_KEEPING_UNIT", quantity: "YOUR_PRODUCT_QUANTITY", }, ], }), }) .then((response) => response.json()) .then((order) => order.id); }, // Finalize the transaction on the server after payer approval onApprove(data) { return fetch("/my-server/capture-paypal-order", { method: "POST", headers: { "Content-Type": "application/json", }, body: JSON.stringify({ orderID: data.orderID }) }) .then((response) => response.json()) .then((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'); // element.innerHTML = '<h3>Thank you for your payment!</h3>'; // Or go to another URL: window.location.href = 'thank_you.html'; }); } }).render('#paypal-button-container'); </script> </body> </html>
Labels:
- Labels:
-
Carts
-
PayPal HTML Buttons
1 REPLY 1
MTS_Chiranjeevi
Moderator
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
May-24-2023
12:35 AM
Good day @NR221,
Thank you for posting to the PayPal community.
Please cross check your PayPal Business account and make sure it is verified and confirmed without any account limitations.
Try to process a test payment via card which is not linked to your PayPal account. Since, merchant can't process self payments.
If your still facing any issues, please create a MTS ticket via - https://www.paypal-support.com/s/?language=en_US with the detail information and error details.
Sincerely,
Chiranjeevi
PayPal/Braintree MTS
If this post or any other was helpful, please enrich the community by giving kudos or accepting it as a solution.
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
- PayPal Pay buttons a mysterious process in PayPal Payments Standard
- credit is not eligible unless vault=true in SDKs
- Problems with wordpress in PayPal Payments Standard
- Need help with copy/paste PayPal Button script not working in SDKs
- composer issues: I see paypal/rest-api-sdk-php is no longer supported but paypal/paypalhttp is. in REST APIs