Skip to content

Instantly share code, notes, and snippets.

@bluepnume
Created January 31, 2018 03:07
Show Gist options
  • Save bluepnume/a9e24c6c91992397ac9d13de0d31a31b to your computer and use it in GitHub Desktop.
Save bluepnume/a9e24c6c91992397ac9d13de0d31a31b to your computer and use it in GitHub Desktop.
// Compressed version of quick start
<script src="https://www.paypalobjects.com/api/checkout.js"></script>
<div id="paypal-button"></div>
<script>
paypal.Button.render({
env: 'sandbox',
client: { sandbox: 'demo_sandbox_client_id' },
payment: function(data, actions) {
return actions.payment.create({
transactions: [{
amount: { total: '0.01', currency: 'USD' }
}]
});
},
onAuthorize: function(data, actions) {
return actions.payment.execute().then(function () {
window.alert('Thanks for your purchase!');
});
}
}, '#paypal-button');
</script>
// Or the super-compressed code-golf version
// (uses some javascript patterns not available in older browsers though...)
<script src="https://www.paypalobjects.com/api/checkout.js"></script>
<script>
paypal.Button.render({
env: 'sandbox',
client: { sandbox: 'demo_sandbox_client_id' },
payment: (data, actions) => actions.payment.create({
transactions: [{ amount: { total: '0.01', currency: 'USD' } }]
}),
onAuthorize: (data, actions) => actions.payment.execute().then(
() => window.alert('Thanks for your purchase!')),
}, document.body);
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment