PayPal In-Context Browserify Example
February 22, 2016 ยท View on GitHub
An example of a PayPal In-Context checkout integration using browserify and browserify-shim
Getting started
- Install
browserifyandbrowserify-shiminto your project:
npm install browserify browserify-shim --save-dev
- In your
package.json, add abrowserifykey containing:
"browserify": {
"transform": [
"browserify-shim"
]
}
This tells browserify to use the browserify-shim.
3. Add a browserify-shim key to package.json so you can use PayPal In-Context from your bundle:
"browserify-shim": {
"paypal-incontext": "global:paypal"
}
- In your HTML file, add references to PayPal's
checkout.jsand your bundle.
<script src="https://www.paypalobjects.com/api/checkout.js"></script>
<script src="path/to/dist/js/bundle.js"></script>
- In your code, use the
paypal-incontextmodule you defined previously:
var paypal = require('paypal-incontext');
paypal.checkout.setup('MERCHANT_ID' {
options: {}
});
- Bundle your code:
browserify -d src/ -o dist/js/bundle.js
- Take orders and make money! ๐ฐ๐ณ๐ธ