Skip to content

Commit 720df68

Browse files
authored
refactor: add return url to createSubscription (#80)
1 parent 3a7faf4 commit 720df68

File tree

3 files changed

+21
-12
lines changed

3 files changed

+21
-12
lines changed

packages/sdk/src/client/common/hooks/useComputeSession.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*/
1010

1111
import { useCallback, useEffect, useRef, useState } from "react";
12-
import { Address, Hex } from "viem";
12+
import { Hex } from "viem";
1313
import {
1414
ComputeApiConfig,
1515
getComputeApiSession,

packages/sdk/src/client/common/types/index.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,8 @@ export interface CreateSubscriptionOptions {
338338
successUrl?: string;
339339
/** URL to redirect to if checkout is canceled */
340340
cancelUrl?: string;
341+
/** URL to return if return link is clicked from stripe portal */
342+
returnUrl?: string;
341343
}
342344

343345
export interface CreateSubscriptionResponse {
@@ -414,11 +416,7 @@ export type DeployProgressCallback = (step: DeployStep, txHash?: Hex) => void;
414416
/**
415417
* Steps in sequential deployment flow
416418
*/
417-
export type DeployStep =
418-
| "createApp"
419-
| "acceptAdmin"
420-
| "setPublicLogs"
421-
| "complete";
419+
export type DeployStep = "createApp" | "acceptAdmin" | "setPublicLogs" | "complete";
422420

423421
/**
424422
* Result from sequential deployment

packages/sdk/src/client/common/utils/billingapi.ts

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,12 @@
1212

1313
import axios, { AxiosResponse } from "axios";
1414
import { Address, type WalletClient } from "viem";
15-
import { ProductID, CreateSubscriptionOptions, CreateSubscriptionResponse, ProductSubscriptionResponse } from "../types";
15+
import {
16+
ProductID,
17+
CreateSubscriptionOptions,
18+
CreateSubscriptionResponse,
19+
ProductSubscriptionResponse,
20+
} from "../types";
1621
import { calculateBillingAuthSignature } from "./auth";
1722
import { BillingEnvironmentConfig } from "../types";
1823
import {
@@ -136,12 +141,18 @@ export class BillingApiClient {
136141
// Subscription Methods
137142
// ==========================================================================
138143

139-
async createSubscription(productId: ProductID = "compute", options?: CreateSubscriptionOptions): Promise<CreateSubscriptionResponse> {
144+
async createSubscription(
145+
productId: ProductID = "compute",
146+
options?: CreateSubscriptionOptions,
147+
): Promise<CreateSubscriptionResponse> {
140148
const endpoint = `${this.config.billingApiServerURL}/products/${productId}/subscription`;
141-
const body = options ? {
142-
success_url: options.successUrl,
143-
cancel_url: options.cancelUrl,
144-
} : undefined;
149+
const body = options
150+
? {
151+
success_url: options.successUrl,
152+
cancel_url: options.cancelUrl,
153+
return_url: options.returnUrl,
154+
}
155+
: undefined;
145156
const resp = await this.makeAuthenticatedRequest(endpoint, "POST", productId, body);
146157
return resp.json();
147158
}

0 commit comments

Comments
 (0)