Skip to content

Commit 49ad057

Browse files
committed
Add successUrl support to payment page
1 parent 759b93b commit 49ad057

File tree

12 files changed

+779
-74
lines changed

12 files changed

+779
-74
lines changed

apps/dashboard/src/app/pay/page.tsx

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,21 @@ type SearchParams = {
2121
[key: string]: string | string[] | undefined;
2222
};
2323

24+
const onlyAddress = (v: string) => (isAddress(v) ? v : undefined);
25+
const onlyNumber = (v: string) =>
26+
Number.isNaN(Number(v)) ? undefined : Number(v);
27+
const onlyUrl = (v: string) => (v.startsWith("http") ? v : undefined);
28+
2429
export default async function PayPage(props: {
2530
searchParams: Promise<SearchParams>;
2631
}) {
2732
const searchParams = await props.searchParams;
2833

29-
const onlyAddress = (v: string) => (isAddress(v) ? v : undefined);
30-
const onlyNumber = (v: string) =>
31-
Number.isNaN(Number(v)) ? undefined : Number(v);
32-
3334
const receiver = parse(searchParams.receiver, onlyAddress);
3435
const token = parse(searchParams.token, onlyAddress);
3536
const chain = parse(searchParams.chain, onlyNumber);
3637
const amount = parse(searchParams.amount, onlyNumber);
38+
const successUrl = parse(searchParams.successUrl, onlyUrl);
3739

3840
return (
3941
<ThemeProvider
@@ -51,6 +53,13 @@ export default async function PayPage(props: {
5153
tokenAddress={token}
5254
receiverAddress={receiver}
5355
amount={amount ? amount.toString() : undefined}
56+
onSuccess={() => {
57+
if (successUrl) {
58+
const url = new URL(successUrl);
59+
url.searchParams.set("success", "true");
60+
window.location.href = url.toString();
61+
}
62+
}}
5463
/>
5564
</div>
5665
</div>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[
2+
{
3+
"import": "*",
4+
"limit": "1 kB",
5+
"name": "@thirdweb-dev/nexus (esm)",
6+
"path": "./dist/esm/exports/nexus.js"
7+
},
8+
{
9+
"limit": "1 kB",
10+
"name": "@thirdweb-dev/nexus (cjs)",
11+
"path": "./dist/cjs/exports/nexus.js"
12+
}
13+
]

packages/nexus-fetch/biome.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"$schema": "https://biomejs.dev/schemas/2.0.6/schema.json",
3+
"extends": "//",
4+
"overrides": [
5+
{
6+
"assist": {
7+
"actions": {
8+
"source": {
9+
"useSortedKeys": "off"
10+
}
11+
}
12+
},
13+
"includes": ["package.json"]
14+
}
15+
]
16+
}

packages/nexus-fetch/knip.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"$schema": "https://unpkg.com/knip@5/schema.json",
3+
"entry": ["src/exports/**"],
4+
"ignore": ["src/**/__generated__/**", "**/*.bench.ts"],
5+
"ignoreBinaries": ["printf"],
6+
"ignoreDependencies": ["tslib"],
7+
"project": ["src/**/*.{ts,tsx}"],
8+
"rules": {
9+
"enumMembers": "off",
10+
"optionalPeerDependencies": "off"
11+
}
12+
}

packages/nexus-fetch/package.json

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
{
2+
"author": "thirdweb eng <[email protected]>",
3+
"browser": {
4+
"crypto": false
5+
},
6+
"bugs": {
7+
"url": "https://github.com/thirdweb-dev/js/issues"
8+
},
9+
"devDependencies": {
10+
"@biomejs/biome": "2.0.6",
11+
"@size-limit/preset-small-lib": "11.2.0",
12+
"knip": "5.60.2",
13+
"rimraf": "6.0.1",
14+
"size-limit": "11.2.0",
15+
"typescript": "5.8.3"
16+
},
17+
"engines": {
18+
"node": ">=22"
19+
},
20+
"exports": {
21+
".": {
22+
"types": "./dist/types/exports/nexus-fetch.d.ts",
23+
"import": "./dist/esm/exports/nexus-fetch.js",
24+
"default": "./dist/cjs/exports/nexus-fetch.js"
25+
}
26+
},
27+
"files": [
28+
"dist/*",
29+
"src/*",
30+
"!**/*.tsbuildinfo",
31+
"!**/*.test.ts",
32+
"!**/*.test.tsx",
33+
"!**/*.test.ts.snap",
34+
"!**/*.test-d.ts",
35+
"!**/*.bench.ts",
36+
"!tsconfig.build.json"
37+
],
38+
"license": "Apache-2.0",
39+
"main": "./dist/cjs/exports/nexus-fetch.js",
40+
"module": "./dist/esm/exports/nexus-fetch.js",
41+
"name": "@thirdweb-dev/fetch",
42+
"peerDependencies": {
43+
"typescript": ">=5.0.4"
44+
},
45+
"peerDependenciesMeta": {
46+
"typescript": {
47+
"optional": true
48+
}
49+
},
50+
"repository": {
51+
"type": "git",
52+
"url": "git+https://github.com/thirdweb-dev/js.git#main"
53+
},
54+
"scripts": {
55+
"build": "pnpm clean && pnpm build:types && pnpm build:cjs && pnpm build:esm",
56+
"build:cjs": "tsc --noCheck --project ./tsconfig.build.json --module commonjs --outDir ./dist/cjs --verbatimModuleSyntax false && printf '{\"type\":\"commonjs\"}' > ./dist/cjs/package.json",
57+
"build:esm": "tsc --noCheck --project ./tsconfig.build.json --module es2020 --outDir ./dist/esm && printf '{\"type\": \"module\",\"sideEffects\":false}' > ./dist/esm/package.json",
58+
"build:types": "tsc --project ./tsconfig.build.json --module nodenext --moduleResolution nodenext --declarationDir ./dist/types --emitDeclarationOnly --declaration --declarationMap",
59+
"clean": "rimraf dist",
60+
"dev": "tsc --project ./tsconfig.build.json --module nodenext --moduleResolution nodenext --outDir ./dist/esm --watch",
61+
"dev:cjs": "printf '{\"type\":\"commonjs\"}' > ./dist/cjs/package.json && tsc --noCheck --project ./tsconfig.build.json --module commonjs --outDir ./dist/cjs --verbatimModuleSyntax false --watch",
62+
"dev:esm": "printf '{\"type\": \"module\",\"sideEffects\":false}' > ./dist/esm/package.json && tsc --noCheck --project ./tsconfig.build.json --module es2020 --outDir ./dist/esm --watch",
63+
"fix": "biome check ./src --fix",
64+
"format": "biome format ./src --write",
65+
"knip": "knip",
66+
"lint": "knip && biome check ./src && tsc --project ./tsconfig.build.json --module nodenext --moduleResolution nodenext --noEmit",
67+
"size": "size-limit",
68+
"typecheck": "tsc --project ./tsconfig.build.json --module nodenext --moduleResolution nodenext --noEmit",
69+
"test:ui": "bun ./testing/test.html --watch"
70+
},
71+
"sideEffects": false,
72+
"type": "module",
73+
"types": "./dist/types/exports/nexus-fetch.d.ts",
74+
"typings": "./dist/types/exports/nexus-fetch.d.ts",
75+
"version": "0.0.0"
76+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { wrap } from "../fetch.js";

0 commit comments

Comments
 (0)