Payment processing & Redirect page?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I integrated a Smart Payment Button into my site, but 1) the payment did not go through; 2) it is not directing to the 'thankyou' page. I'm not a coder and am feeling lost. Would you please help troubleshoot?
Thanks!
Garrett
<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=AYQEiLhOfhtm3pAZaHsaafpnP6DwQUabWdV_irJun929s4QIMmOwWzEGhgF3RUVY5X3IIrFYsCndOn3a&enable-funding=venmo¤cy=USD" data-sdk-integration-source="button-factory"></script>
<script>
function initPayPalButton() {
paypal.Buttons({
style: {
shape: 'rect',
color: 'white',
layout: 'vertical',
label: 'paypal',
},
createOrder: function(data, actions) {
return actions.order.create({
purchase_units: [{"description":"3-month Membership","amount":{"currency_code":"USD","value":1}}]
});
},
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('thankyou');
});
},
onError: function(err) {
console.log(err);
}
}).render('#paypal-button-container');
}
initPayPalButton();
</script>

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Good day @myemcertain,
Thank you for posting to the PayPal community.
Please contact your internal website developer or support of eCommerce to refer the below detailed guide link and pass the "return_url".
https://developer.paypal.com/docs/api/orders/v2/#definition-application_context
https://developer.paypal.com/docs/api/orders/v2/#orders_create
curl -v -X POST https://api-m.sandbox.paypal.com/v2/checkout/orders \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <Access-Token>" \
-H "PayPal-Request-Id: ******" \
-d '{
"intent": "CAPTURE",
"purchase_units": [
{
"reference_id": "******",
"amount": {
"currency_code": "USD",
"value": "100.00"
}
}
],
"payment_source": {
"paypal": {
"experience_context": {
"payment_method_preference": "IMMEDIATE_PAYMENT_REQUIRED",
"payment_method_selected": "PAYPAL",
"brand_name": "EXAMPLE INC",
"locale": "en-US",
"landing_page": "LOGIN",
"shipping_preference": "SET_PROVIDED_ADDRESS",
"user_action": "PAY_NOW",
"return_url": "https://example.com/returnUrl",
"cancel_url": "https://example.com/cancelUrl"
}
}
}
}'
Guide link - https://developer.paypal.com/docs/checkout/standard/
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you for the response. Sadly, I don't have a developer (that's why I'm using Wix), and am doing my best to implement this myself. Where in my code should I insert your suggested code?
Thanks,
Garrett

Haven't Found your Answer?
It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.
- Assistance Needed: Passing and Retrieving Custom Data in PayPal Webhook Payload in PayPal Payments Standard
- Payments Refunded Automatically After Successful Transactions - PayPal Business Account Issue in REST APIs
- subscription_id has disappeared in REST APIs
- Why does PayPal redirect to different pages (login vs credit card form) depending on browser mode? in Braintree Server-side Integration (PHP, Java, .NET, Ruby, Python, NodeJS SDKs)
- Is PaymentPlugins an official PayPal partner ? in PayPal Payments Standard