PayPal integration for Angular. For live example and documentation visit https://enngage.github.io/ngx-paypal/
I strongly recommend checking out PayPal's docs linked above if you want to learn more about the flow of checkout process and meaning behind certain properties. There are ton of properties you can set within the
createOrder method and good IDE will show you these properties so use that, I don't find it particulary useful to list all properties and their description here - PayPal docs is your friend.
npm install ngx-paypal --save
NgxPayPalModule in your module (i.e.
Creating orders on client
Creating orders on server
Authorizing on server
To authorize on payment on server, provide
authorizeOnServer. If you do so, client validation is not used and therefore the
onClientAuthorization will not be called.
Multiple ngx-paypal components on the same page
The key is to inject
PayPalScriptService, register script manually and then call
customInit with the PayPal API once your component is available. Note that if you use conditions (
*ngIf) you will have to adjust the core accordingly because of the timings and call
customInit once both PayPalApi has loaded and your component was initialized.
Unit testing in Angular is possible, but a bit clunky because this component tries to dynamically include paypals's script if its not already loaded. You are not required to include in globally or manually which has a benefit of not loading until you actually use this component. This has a caveat though, since the load callback is executed outside of Angular's zone, performing unit tests might fail due to racing condition where Angular might fail the test before the script has a chance to load and initialize captcha.
A simple fix for this is wait certain amount of time so that everything has a chance to initialize. See example below:
Breaking v5 release
npm run publish-lib
Publishing demo app
Under root, generate demo app with
npm run build-demo-gh-pages npx ngh --dir=dist-demo