diff --git a/.changeset/tricky-numbers-cross.md b/.changeset/tricky-numbers-cross.md new file mode 100644 index 000000000..4b530c110 --- /dev/null +++ b/.changeset/tricky-numbers-cross.md @@ -0,0 +1,5 @@ +--- +"@paypal/paypal-js": minor +--- + +Made return_url and cancel_url optional in subscription application_context diff --git a/packages/paypal-js/types/apis/openapi/billing_subscriptions_v1.d.ts b/packages/paypal-js/types/apis/openapi/billing_subscriptions_v1.d.ts index c814fc6e0..f56ecd570 100644 --- a/packages/paypal-js/types/apis/openapi/billing_subscriptions_v1.d.ts +++ b/packages/paypal-js/types/apis/openapi/billing_subscriptions_v1.d.ts @@ -1219,12 +1219,12 @@ export interface components { * Format: uri * @description The URL where the customer is redirected after the customer approves the payment. */ - return_url: string; + return_url?: string; /** * Format: uri * @description The URL where the customer is redirected after the customer cancels the payment. */ - cancel_url: string; + cancel_url?: string; }; /** * Billing Cycle Override diff --git a/packages/paypal-js/types/tests/buttons.test.ts b/packages/paypal-js/types/tests/buttons.test.ts index 8047862be..3223ade62 100644 --- a/packages/paypal-js/types/tests/buttons.test.ts +++ b/packages/paypal-js/types/tests/buttons.test.ts @@ -76,6 +76,21 @@ async function main() { }, }); + // createSubscription with application_context (return_url and cancel_url are optional) + paypal.Buttons({ + style: { label: "subscribe" }, + createSubscription: (data, actions) => { + return actions.subscription.create({ + plan_id: "P-3RX123456M3469222L5IFM4I", + quantity: "1", + application_context: { + brand_name: "My Brand", + shipping_preference: "NO_SHIPPING", + }, + }); + }, + }); + // validation with onInit and onClick // https://developer.paypal.com/docs/checkout/standard/customize/validate-user-input/ paypal.Buttons({