Skip to content

Commit 490497c

Browse files
[Checkout] Enhance redirect handling for different payment types (#6959)
1 parent bdb4c31 commit 490497c

File tree

1 file changed

+26
-10
lines changed

1 file changed

+26
-10
lines changed

apps/dashboard/src/app/checkout/components/client/CheckoutEmbed.client.tsx

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -85,17 +85,33 @@ export function CheckoutEmbed({
8585
onPurchaseSuccess: (result) => {
8686
if (!redirectUri) return;
8787
const url = new URL(redirectUri);
88-
if (result.type === "transaction") {
89-
url.searchParams.set("txHash", result.transactionHash);
90-
return window.open(url.toString());
91-
}
92-
if (result.status.status === "NOT_FOUND") {
93-
throw new Error("Transaction not found");
94-
}
95-
const txHash = result.status.source?.transactionHash;
96-
if (typeof txHash === "string") {
97-
url.searchParams.set("txHash", txHash);
88+
switch (result.type) {
89+
case "crypto": {
90+
url.searchParams.set("status", result.status.status);
91+
if (
92+
"source" in result.status &&
93+
result.status.source?.transactionHash
94+
) {
95+
url.searchParams.set(
96+
"txHash",
97+
result.status.source?.transactionHash,
98+
);
99+
}
100+
break;
101+
}
102+
case "fiat": {
103+
url.searchParams.set("status", result.status.status);
104+
if ("intentId" in result.status) {
105+
url.searchParams.set("intentId", result.status.intentId);
106+
}
107+
break;
108+
}
109+
case "transaction": {
110+
url.searchParams.set("txHash", result.transactionHash);
111+
break;
112+
}
98113
}
114+
return window.open(url.toString());
99115
},
100116
}}
101117
/>

0 commit comments

Comments
 (0)