Created
December 13, 2018 18:39
-
-
Save rocksinghajay/de1d074a764ab8acc6a99c76d27be3be to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| axios.post('https://api.sandbox.paypal.com/v1/oauth2/token', { grant_type: 'client_credentials' }, | |
| { | |
| headers: { | |
| 'Content-Type': 'application/x-www-form-urlencoded', | |
| 'Authorization': ` ` // Your Authorization Value | |
| } | |
| } | |
| ) | |
| .then(response => { | |
| console.log(response.data.access_token) | |
| axios.post('https://api.sandbox.paypal.com/v1/payments/payment', { Details }, // you can get data details from https://developer.paypal.com/docs/api/payments/v1/ | |
| { | |
| headers: { | |
| 'Content-Type': 'application/json', | |
| 'Authorization': `Bearer ${response.data.access_token}` | |
| } | |
| } | |
| ) | |
| .then(response => { | |
| const { id, links } = response.data | |
| const approvalUrl = links.find(data => data.rel == "approval_url") | |
| console.log(id) | |
| console.log(approvalUrl) | |
| }).catch(err => { | |
| console.log({ ...err }) | |
| }) | |
| }).catch(err => { | |
| console.log({ ...err }) | |
| }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment