@b3dotfun/sdk 0.1.63-alpha.4 → 0.1.63-alpha.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/anyspend/react/components/common/OrderDetails.js +19 -0
- package/dist/cjs/anyspend/react/components/common/PaymentStripeWeb2.js +2 -2
- package/dist/esm/anyspend/react/components/common/OrderDetails.js +19 -0
- package/dist/esm/anyspend/react/components/common/PaymentStripeWeb2.js +2 -2
- package/package.json +1 -1
- package/src/anyspend/react/components/common/OrderDetails.tsx +19 -0
- package/src/anyspend/react/components/common/PaymentStripeWeb2.tsx +2 -2
|
@@ -351,6 +351,25 @@ exports.OrderDetails = (0, react_5.memo)(function OrderDetails({ mode = "modal",
|
|
|
351
351
|
handlePayment();
|
|
352
352
|
}
|
|
353
353
|
}, [isPayableState, isComponentReady, handlePayment]);
|
|
354
|
+
// Auto-redirect to redirectUrl when order is executed (for onramp orders)
|
|
355
|
+
(0, react_5.useEffect)(() => {
|
|
356
|
+
if (order.status === "executed" && order.onrampMetadata?.redirectUrl) {
|
|
357
|
+
const baseUrl = order.onrampMetadata.redirectUrl;
|
|
358
|
+
try {
|
|
359
|
+
const url = new URL(baseUrl);
|
|
360
|
+
// Prevent Open Redirect vulnerabilities by ensuring the protocol is http or https
|
|
361
|
+
if (url.protocol !== "http:" && url.protocol !== "https:") {
|
|
362
|
+
console.error(`Attempted redirect to a URL with an invalid protocol: ${url.protocol}`);
|
|
363
|
+
return;
|
|
364
|
+
}
|
|
365
|
+
const redirectUrl = `${baseUrl.replace(/\/$/, "")}/${order.id}`;
|
|
366
|
+
window.location.href = redirectUrl;
|
|
367
|
+
}
|
|
368
|
+
catch (error) {
|
|
369
|
+
console.error("Invalid redirect URL provided:", baseUrl, error);
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
}, [order.status, order.onrampMetadata?.redirectUrl, order.id]);
|
|
354
373
|
if (!srcToken || !dstToken) {
|
|
355
374
|
return (0, jsx_runtime_1.jsx)("div", { children: "Loading..." });
|
|
356
375
|
}
|
|
@@ -95,9 +95,9 @@ function StripePaymentForm({ order, clientSecret, onPaymentSuccess, }) {
|
|
|
95
95
|
}
|
|
96
96
|
// At this point TypeScript knows result.paymentIntent exists and error is undefined
|
|
97
97
|
console.log("@@stripe-web2-payment:success:", JSON.stringify({ orderId: order.id, paymentIntentId: result.paymentIntent.id }, null, 2));
|
|
98
|
-
// Payment succeeded
|
|
98
|
+
// Payment succeeded
|
|
99
99
|
setMessage(null);
|
|
100
|
-
//
|
|
100
|
+
// Stay on page and show waiting state (redirect will happen in OrderDetails when order is executed)
|
|
101
101
|
const currentUrl = new URL(window.location.href);
|
|
102
102
|
currentUrl.searchParams.set("waitingForDeposit", "true");
|
|
103
103
|
window.history.replaceState(null, "", currentUrl.toString());
|
|
@@ -345,6 +345,25 @@ export const OrderDetails = memo(function OrderDetails({ mode = "modal", order,
|
|
|
345
345
|
handlePayment();
|
|
346
346
|
}
|
|
347
347
|
}, [isPayableState, isComponentReady, handlePayment]);
|
|
348
|
+
// Auto-redirect to redirectUrl when order is executed (for onramp orders)
|
|
349
|
+
useEffect(() => {
|
|
350
|
+
if (order.status === "executed" && order.onrampMetadata?.redirectUrl) {
|
|
351
|
+
const baseUrl = order.onrampMetadata.redirectUrl;
|
|
352
|
+
try {
|
|
353
|
+
const url = new URL(baseUrl);
|
|
354
|
+
// Prevent Open Redirect vulnerabilities by ensuring the protocol is http or https
|
|
355
|
+
if (url.protocol !== "http:" && url.protocol !== "https:") {
|
|
356
|
+
console.error(`Attempted redirect to a URL with an invalid protocol: ${url.protocol}`);
|
|
357
|
+
return;
|
|
358
|
+
}
|
|
359
|
+
const redirectUrl = `${baseUrl.replace(/\/$/, "")}/${order.id}`;
|
|
360
|
+
window.location.href = redirectUrl;
|
|
361
|
+
}
|
|
362
|
+
catch (error) {
|
|
363
|
+
console.error("Invalid redirect URL provided:", baseUrl, error);
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
}, [order.status, order.onrampMetadata?.redirectUrl, order.id]);
|
|
348
367
|
if (!srcToken || !dstToken) {
|
|
349
368
|
return _jsx("div", { children: "Loading..." });
|
|
350
369
|
}
|
|
@@ -89,9 +89,9 @@ function StripePaymentForm({ order, clientSecret, onPaymentSuccess, }) {
|
|
|
89
89
|
}
|
|
90
90
|
// At this point TypeScript knows result.paymentIntent exists and error is undefined
|
|
91
91
|
console.log("@@stripe-web2-payment:success:", JSON.stringify({ orderId: order.id, paymentIntentId: result.paymentIntent.id }, null, 2));
|
|
92
|
-
// Payment succeeded
|
|
92
|
+
// Payment succeeded
|
|
93
93
|
setMessage(null);
|
|
94
|
-
//
|
|
94
|
+
// Stay on page and show waiting state (redirect will happen in OrderDetails when order is executed)
|
|
95
95
|
const currentUrl = new URL(window.location.href);
|
|
96
96
|
currentUrl.searchParams.set("waitingForDeposit", "true");
|
|
97
97
|
window.history.replaceState(null, "", currentUrl.toString());
|
package/package.json
CHANGED
|
@@ -493,6 +493,25 @@ export const OrderDetails = memo(function OrderDetails({
|
|
|
493
493
|
}
|
|
494
494
|
}, [isPayableState, isComponentReady, handlePayment]);
|
|
495
495
|
|
|
496
|
+
// Auto-redirect to redirectUrl when order is executed (for onramp orders)
|
|
497
|
+
useEffect(() => {
|
|
498
|
+
if (order.status === "executed" && order.onrampMetadata?.redirectUrl) {
|
|
499
|
+
const baseUrl = order.onrampMetadata.redirectUrl;
|
|
500
|
+
try {
|
|
501
|
+
const url = new URL(baseUrl);
|
|
502
|
+
// Prevent Open Redirect vulnerabilities by ensuring the protocol is http or https
|
|
503
|
+
if (url.protocol !== "http:" && url.protocol !== "https:") {
|
|
504
|
+
console.error(`Attempted redirect to a URL with an invalid protocol: ${url.protocol}`);
|
|
505
|
+
return;
|
|
506
|
+
}
|
|
507
|
+
const redirectUrl = `${baseUrl.replace(/\/$/, "")}/${order.id}`;
|
|
508
|
+
window.location.href = redirectUrl;
|
|
509
|
+
} catch (error) {
|
|
510
|
+
console.error("Invalid redirect URL provided:", baseUrl, error);
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
}, [order.status, order.onrampMetadata?.redirectUrl, order.id]);
|
|
514
|
+
|
|
496
515
|
if (!srcToken || !dstToken) {
|
|
497
516
|
return <div>Loading...</div>;
|
|
498
517
|
}
|
|
@@ -159,10 +159,10 @@ function StripePaymentForm({
|
|
|
159
159
|
JSON.stringify({ orderId: order.id, paymentIntentId: result.paymentIntent.id }, null, 2),
|
|
160
160
|
);
|
|
161
161
|
|
|
162
|
-
// Payment succeeded
|
|
162
|
+
// Payment succeeded
|
|
163
163
|
setMessage(null);
|
|
164
164
|
|
|
165
|
-
//
|
|
165
|
+
// Stay on page and show waiting state (redirect will happen in OrderDetails when order is executed)
|
|
166
166
|
const currentUrl = new URL(window.location.href);
|
|
167
167
|
currentUrl.searchParams.set("waitingForDeposit", "true");
|
|
168
168
|
window.history.replaceState(null, "", currentUrl.toString());
|