From 3481e781f8b387d0e5cdc0baf9b5ae1fdf9a7af8 Mon Sep 17 00:00:00 2001 From: Haripriyan Date: Tue, 6 Oct 2020 10:32:08 +0530 Subject: [PATCH] feat: renames planName to planId and deprecates planName --- src/interfaces/cb-types.ts | 4 +++- src/models/CBCheckout.ts | 11 ++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/interfaces/cb-types.ts b/src/interfaces/cb-types.ts index 6de821a..e7991dd 100644 --- a/src/interfaces/cb-types.ts +++ b/src/interfaces/cb-types.ts @@ -5,7 +5,9 @@ export interface CBCheckoutProps extends CBCheckoutParams { export type CBCheckoutParams = { site: string; - planName: string; + /** @deprecated since 1.0.7. Use `planId` instead. **/ + planName?: string; + planId?: string; } & CBCheckoutQueryParams; export type CBCheckoutQueryParams = { diff --git a/src/models/CBCheckout.ts b/src/models/CBCheckout.ts index cdde2a7..eb27d28 100644 --- a/src/models/CBCheckout.ts +++ b/src/models/CBCheckout.ts @@ -23,7 +23,16 @@ export class CBCheckout { } private baseUrl() { - return `https://${this.props.site}.chargebee.com/hosted_pages/plans/${this.props.planName}`; + return `https://${ + this.props.site + }.chargebee.com/hosted_pages/plans/${this.planResource()}`; + } + + private planResource() { + if (this.props.planId) { + return this.props.planId; + } + return this.props.planName; } private buildQueryParams() {