From b859079fbfc79ea8129e9677f4219599d6b7709b Mon Sep 17 00:00:00 2001 From: Brendan Dugan Date: Mon, 21 Nov 2022 22:44:25 -0800 Subject: [PATCH 1/2] Add support for createBillingAgreement --- .../src/lib/components/paypal.component.ts | 10 ++++++++++ .../ngx-paypal-lib/src/lib/models/paypal-models.ts | 8 +++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/projects/ngx-paypal-lib/src/lib/components/paypal.component.ts b/projects/ngx-paypal-lib/src/lib/components/paypal.component.ts index a05723d..c51e794 100644 --- a/projects/ngx-paypal-lib/src/lib/components/paypal.component.ts +++ b/projects/ngx-paypal-lib/src/lib/components/paypal.component.ts @@ -256,6 +256,14 @@ export class NgxPaypalComponent implements OnChanges, OnDestroy, AfterViewInit { }); }; + const createBillingAgreement = () => { + return this.ngZone.run(() => { + if (config.createBillingAgreement) { + return config.createBillingAgreement(); + } + }); + }; + const buttonsConfig = { style: config.style, fundingSource: undefined, @@ -323,6 +331,8 @@ export class NgxPaypalComponent implements OnChanges, OnDestroy, AfterViewInit { // The onShippingChange callback cannot be used with subscriptions // so we only add it if it is set ...(config.onShippingChange && { onShippingChange }), + // only add createBillingAgreement if it is set + ...(config.createBillingAgreement && { createBillingAgreement }), }; let fundSource = undefined; diff --git a/projects/ngx-paypal-lib/src/lib/models/paypal-models.ts b/projects/ngx-paypal-lib/src/lib/models/paypal-models.ts index 643b8bb..e296679 100644 --- a/projects/ngx-paypal-lib/src/lib/models/paypal-models.ts +++ b/projects/ngx-paypal-lib/src/lib/models/paypal-models.ts @@ -19,6 +19,12 @@ export interface IPayPalConfig { */ createOrderOnServer?: (data: any) => Promise; + /** + * Use when creating a billing agreement for recurring payments - a legacy feature similar to subscriptions. + * See https://developer.paypal.com/docs/api/payments.billing-agreements/v1/ + */ + createBillingAgreement?: () => Promise; + /** * Advanced configuration */ @@ -293,7 +299,7 @@ export type ShippingPreference = export type PaypalLandingPage = "LOGIN" | "BILLING"; -export type OrderIntent = "CAPTURE" | "AUTHORIZE" | "subscription"; +export type OrderIntent = "CAPTURE" | "AUTHORIZE" | "subscription" | "tokenize"; export type DisbursementMode = "INSTANT" | "DELAYED"; From fb6ae2530462ed36a6cc559e735c11ba761cc5c3 Mon Sep 17 00:00:00 2001 From: Brendan Dugan Date: Mon, 21 Nov 2022 22:49:47 -0800 Subject: [PATCH 2/2] bump version --- projects/ngx-paypal-lib/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/ngx-paypal-lib/package.json b/projects/ngx-paypal-lib/package.json index 183f233..373c7f3 100644 --- a/projects/ngx-paypal-lib/package.json +++ b/projects/ngx-paypal-lib/package.json @@ -1,6 +1,6 @@ { "name": "ngx-paypal", - "version": "10.1.0", + "version": "10.2.0", "license": "MIT", "repository": { "type": "git",