How exactly integrate Server-Side REST?
webDev-cr
Contributor
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on
Oct-29-2017
04:36 PM
hI everybody.
I have this code:
<!DOCTYPE html> <head> <meta http-equiv="X-UA-Compatible" content="IE=edge" /> <meta name="viewport" content="width=device-width, initial-scale=1"> <script src="https://www.paypalobjects.com/api/checkout.js"></script> </head> <body> <div id="paypal-button-container"></div> <script> var CREATE_PAYMENT_URL = '/paypal/create-payment'; var EXECUTE_PAYMENT_URL = '/paypal/execute-payment/'; paypal.Button.render({ env: 'sandbox', // sandbox | production // Show the buyer a 'Pay Now' button in the checkout flow commit: true, // payment() is called when the button is clicked payment: function() { return paypal.request.post(CREATE_PAYMENT_URL).then(function(data) { //console.log(" ID del pago retornado: " + data); console.log(CREATE_PAYMENT_URL); return data.id; }); }, // onAuthorize() is called when the buyer approves the payment onAuthorize: function(data) { return paypal.request.post(EXECUTE_PAYMENT_URL, { paymentID: data.paymentID, payerID: data.payerID }).then(function() { // The payment is complete! // You can now show a confirmation message to the customer alert("Felicidades! El pago fue realizado."); }).catch(function(err) { console.log(err); }); console.log(" Data " + data); }, onCancel: function(data, actions) { return actions.redirect(); } }, '#paypal-button-container'); </script> </body>
I have been reading about Paypal Rest Api.
I read the function return JSON data, so what code I must to include in '/paypal/create-payment'; ?
Please, I need a complete example.
Thanks
1 REPLY 1

Moderator
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Jan-29-2018
02:39 PM
Here is the documentation on server side Rest API setup:
Server Side Rest API Integration
Here is the request to get the access token:
Complete Request on your server:
Complete SDK for PHP Rest API Payments:
Thank you,
Jennifer

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
- Is it possible to make payments in RON (Romanian Leu) through PayPal? in REST APIs
- Advance checkout in Braintree Server-side Integration (PHP, Java, .NET, Ruby, Python, NodeJS SDKs)
- How to integrate PayPal during user signup to avoid re-entering credentials for future payments? in REST APIs
- Django-paypal form is not showing "pay with credit or debit card" option in Braintree Server-side Integration (PHP, Java, .NET, Ruby, Python, NodeJS SDKs)
- Shopify PayPal integration, customer authorized multiple times in PayPal Payments Standard