An example of a PayPal In-Context checkout integration using browserify and browserify-shim
- Install
browserify
andbrowserify-shim
into your project:
npm install browserify browserify-shim --save-dev
- In your
package.json
, add abrowserify
key 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.js
and 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-incontext
module 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! 💰💳💸