Skip to content

Instantly share code, notes, and snippets.

@rocksinghajay
Created December 13, 2018 18:39
Show Gist options
  • Select an option

  • Save rocksinghajay/de1d074a764ab8acc6a99c76d27be3be to your computer and use it in GitHub Desktop.

Select an option

Save rocksinghajay/de1d074a764ab8acc6a99c76d27be3be to your computer and use it in GitHub Desktop.
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