Skip to content

Commit

Permalink
Support success and cancel URLs
Browse files Browse the repository at this point in the history
  • Loading branch information
qianl15 committed Dec 5, 2024
1 parent 9efa235 commit 6fb370a
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/endpoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ export class CloudSubscription {
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
const userEmail = ctxt.koaContext.state.user["https://dbos.dev/email"] as string;
const body = ctxt.request.body as {success_url: string, cancel_url: string};
const successUrl = body.success_url as string ?? 'https://console.dbos.dev';
const cancelUrl = body.cancel_url as string ?? 'https://www.dbos.dev/pricing';
const successUrl = body.success_url ?? 'https://console.dbos.dev';
const cancelUrl = body.cancel_url ?? 'https://www.dbos.dev/pricing';
const sessionURL = await ctxt.invokeWorkflow(Utils).createSubscription(auth0UserID, userEmail, successUrl, cancelUrl);
if (!sessionURL) {
throw new DBOSResponseError("Failed to create a checkout session!", 500);
Expand All @@ -60,7 +60,7 @@ export class CloudSubscription {
@PostApi('/create-customer-portal')
static async createCustomerPortal(ctxt: HandlerContext) {
const auth0User = ctxt.authenticatedUser;
const returnUrl = (ctxt.request.body as {return_url: string}).return_url as string ?? 'https://www.dbos.dev/pricing';
const returnUrl = (ctxt.request.body as {return_url: string}).return_url ?? 'https://www.dbos.dev/pricing';
const sessionURL = await ctxt.invokeWorkflow(Utils).createStripeCustomerPortal(auth0User, returnUrl);
if (!sessionURL) {
throw new DBOSResponseError("Failed to create customer portal!", 500);
Expand Down

0 comments on commit 6fb370a

Please sign in to comment.