Created
January 31, 2018 03:07
-
-
Save bluepnume/a9e24c6c91992397ac9d13de0d31a31b 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
// 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