Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/tricky-numbers-cross.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@paypal/paypal-js": minor
---

Made return_url and cancel_url optional in subscription application_context
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 15 additions & 0 deletions packages/paypal-js/types/tests/buttons.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
Loading