@superlogic/spree-pay 0.3.3 → 0.3.5
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/README.md +37 -6
- package/build/{CryptoComTab-OW42JVO5.js → CryptoComTab-P4MC2R2N.js} +5 -5
- package/build/{CryptoTab-NTHHA7YO.js → CryptoTab-CI5C22BD.js} +2 -2
- package/build/{chunk-BSDEX662.js → chunk-D23MABH2.js} +1 -1
- package/build/{chunk-ZPFV3WW6.js → chunk-FHY6YBXC.js} +4 -4
- package/build/{chunk-6RZ4XF7B.js → chunk-KQ25SXYH.js} +14 -25
- package/build/index.cjs +45 -54
- package/build/index.d.cts +1 -0
- package/build/index.d.ts +1 -0
- package/build/index.js +27 -27
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -213,18 +213,49 @@ enum LogLevel {
|
|
|
213
213
|
|
|
214
214
|
## Theme Customization
|
|
215
215
|
|
|
216
|
-
|
|
216
|
+
SpreePay uses CSS variables for theming (see all 58+ variables in `packages/spree-pay/src/styles/globals.css:22-82`). You can override these using CSS or CSS-in-JS.
|
|
217
|
+
|
|
218
|
+
**Important:** To override the theme locally (scoped), you need **more specific CSS** than just `.sl-spreepay`. Use a wrapper class like `.your-class .sl-spreepay` or combine with SpreePay's className prop.
|
|
219
|
+
|
|
220
|
+
### Global override (affects all SpreePay instances)
|
|
217
221
|
|
|
218
222
|
```css
|
|
219
223
|
.sl-spreepay {
|
|
220
|
-
--primary: #
|
|
221
|
-
--accent: #
|
|
222
|
-
--s-default: #
|
|
223
|
-
/* ... see packages/spree-pay/src/styles/globals.css for all 58 variables */
|
|
224
|
+
--primary: #272e32;
|
|
225
|
+
--accent: #439ef4;
|
|
226
|
+
--s-default: #ffffff;
|
|
224
227
|
}
|
|
225
228
|
```
|
|
226
229
|
|
|
227
|
-
|
|
230
|
+
### Local/scoped override
|
|
231
|
+
|
|
232
|
+
**Option A:** Wrap SpreePay in a container with your own class:
|
|
233
|
+
|
|
234
|
+
```tsx
|
|
235
|
+
<div className="my-checkout">
|
|
236
|
+
<SpreePay {...props} />
|
|
237
|
+
</div>
|
|
238
|
+
|
|
239
|
+
<style>{`
|
|
240
|
+
.my-checkout .sl-spreepay {
|
|
241
|
+
--primary: #your-color;
|
|
242
|
+
--accent: #your-accent;
|
|
243
|
+
}
|
|
244
|
+
`}</style>
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
**Option B:** Pass className to SpreePay and use combined selector:
|
|
248
|
+
|
|
249
|
+
```tsx
|
|
250
|
+
<SpreePay className="custom-theme" {...props} />
|
|
251
|
+
|
|
252
|
+
<style>{`
|
|
253
|
+
.sl-spreepay.custom-theme {
|
|
254
|
+
--primary: #your-color;
|
|
255
|
+
--accent: #your-accent;
|
|
256
|
+
}
|
|
257
|
+
`}</style>
|
|
258
|
+
```
|
|
228
259
|
|
|
229
260
|
## Keycloak SSO page example (/silent-check-sso.html)
|
|
230
261
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Iframe3ds
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-D23MABH2.js";
|
|
4
4
|
import {
|
|
5
5
|
InfoBanner,
|
|
6
6
|
Legal,
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
useSpreePayRegister,
|
|
13
13
|
useSpreePaymentMethod,
|
|
14
14
|
useStaticConfig
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-KQ25SXYH.js";
|
|
16
16
|
|
|
17
17
|
// src/components/CryptoComTab/CryptoComTab.tsx
|
|
18
18
|
import { useCallback, useEffect } from "react";
|
|
@@ -22,7 +22,7 @@ import NiceModal from "@ebay/nice-modal-react";
|
|
|
22
22
|
var cryptoComLogger = logger.child("crypto-com-payment");
|
|
23
23
|
var useCryptoComPayment = () => {
|
|
24
24
|
const { selectedPaymentMethod } = useSpreePaymentMethod();
|
|
25
|
-
const {
|
|
25
|
+
const { redirect3dsURI } = useSpreePayEnv();
|
|
26
26
|
const cryptoComPayment = async (params) => {
|
|
27
27
|
if (selectedPaymentMethod.type !== "CDC" /* CDC */) {
|
|
28
28
|
throw new Error("Unsupported payment method");
|
|
@@ -34,8 +34,8 @@ var useCryptoComPayment = () => {
|
|
|
34
34
|
metadata,
|
|
35
35
|
type: "CDC" /* CDC */,
|
|
36
36
|
cdc: {
|
|
37
|
-
returnUrl: `${typeof window !== "undefined" ? window.location.origin : ""}${
|
|
38
|
-
cancelUrl: `${typeof window !== "undefined" ? window.location.origin : ""}${
|
|
37
|
+
returnUrl: `${typeof window !== "undefined" ? window.location.origin : ""}${redirect3dsURI}?payment_intent=success`,
|
|
38
|
+
cancelUrl: `${typeof window !== "undefined" ? window.location.origin : ""}${redirect3dsURI}?payment_intent=canceled`
|
|
39
39
|
}
|
|
40
40
|
});
|
|
41
41
|
cryptoComLogger.info("Payment created", {
|
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
CheckoutButton,
|
|
3
3
|
PointsSwitch,
|
|
4
4
|
cn as cn2
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-FHY6YBXC.js";
|
|
6
6
|
import {
|
|
7
7
|
Dialog,
|
|
8
8
|
DialogContent,
|
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
useSpreePayConfig,
|
|
17
17
|
useSpreePayRegister,
|
|
18
18
|
useSpreePaymentMethod
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-KQ25SXYH.js";
|
|
20
20
|
|
|
21
21
|
// src/components/CryptoTab/Crypto/CryptoWrapper.tsx
|
|
22
22
|
import { useMemo as useMemo2 } from "react";
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
useSpreePayEnv,
|
|
7
7
|
useSpreePaymentMethod,
|
|
8
8
|
useStaticConfig
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-KQ25SXYH.js";
|
|
10
10
|
|
|
11
11
|
// src/components/common/PointsSwitch.tsx
|
|
12
12
|
import { useId } from "react";
|
|
@@ -206,7 +206,7 @@ var CheckoutButton = ({ isLoggedIn }) => {
|
|
|
206
206
|
const { appProps, staticConfig } = useStaticConfig();
|
|
207
207
|
const { amount, onProcess, isProcessing, transactionFeePercentage } = appProps;
|
|
208
208
|
const { spreePayConfig } = useSpreePayConfig();
|
|
209
|
-
const {
|
|
209
|
+
const { tenantId, keycloakClientId } = useSpreePayEnv();
|
|
210
210
|
const { selectedPaymentMethod, isInternalProcessing } = useSpreePaymentMethod();
|
|
211
211
|
const { splitAmount, type, method } = selectedPaymentMethod;
|
|
212
212
|
const usdAmount = getSplitAmount(amount ?? 0, splitAmount ?? 0, spreePayConfig?.pointsConversionRatio);
|
|
@@ -240,11 +240,11 @@ var CheckoutButton = ({ isLoggedIn }) => {
|
|
|
240
240
|
isLoggedIn ? /* @__PURE__ */ jsx5(Fragment, { children: onProcess && /* @__PURE__ */ jsx5("button", { disabled: isDisabled, onClick: onProcess, className: checkoutClass, children: getCheckoutContent() }) }) : /* @__PURE__ */ jsxs3(
|
|
241
241
|
"a",
|
|
242
242
|
{
|
|
243
|
-
href: `${staticConfig.keycloakUrl}/realms/${
|
|
243
|
+
href: `${staticConfig.keycloakUrl}/realms/${tenantId}/protocol/openid-connect/auth?client_id=${keycloakClientId ?? "oneof-next"}&response_type=code&redirect_uri=${window.location.href}`,
|
|
244
244
|
className: checkoutClass,
|
|
245
245
|
children: [
|
|
246
246
|
"Log in / Sign up",
|
|
247
|
-
|
|
247
|
+
tenantId === "moca" ? " for an AIR account" : ""
|
|
248
248
|
]
|
|
249
249
|
}
|
|
250
250
|
),
|
|
@@ -9,7 +9,7 @@ var PaymentType = /* @__PURE__ */ ((PaymentType2) => {
|
|
|
9
9
|
})(PaymentType || {});
|
|
10
10
|
|
|
11
11
|
// package.json
|
|
12
|
-
var version = "0.3.
|
|
12
|
+
var version = "0.3.5";
|
|
13
13
|
|
|
14
14
|
// src/utils/logger.ts
|
|
15
15
|
var LogLevel = /* @__PURE__ */ ((LogLevel2) => {
|
|
@@ -225,7 +225,7 @@ var useSpreePaymentMethod = () => {
|
|
|
225
225
|
var useSpreePayEnv = () => {
|
|
226
226
|
const ctx = useContext(SpreePayActionsContext);
|
|
227
227
|
if (!ctx) throw new Error("useSpreePay must be used within a SpreePayProvider");
|
|
228
|
-
return
|
|
228
|
+
return ctx.env;
|
|
229
229
|
};
|
|
230
230
|
var useSpreePayRegister = () => {
|
|
231
231
|
const ctx = useContext(SpreePayActionsContext);
|
|
@@ -322,23 +322,23 @@ var config = {
|
|
|
322
322
|
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
323
323
|
var StaticConfigContext = createContext2(null);
|
|
324
324
|
var StaticConfigProvider = ({ children, props }) => {
|
|
325
|
-
const {
|
|
325
|
+
const { environment, tenantId } = useSpreePayEnv();
|
|
326
326
|
const [appProps, setAppProps] = useState2(props);
|
|
327
327
|
useEffect(() => {
|
|
328
328
|
setAppProps(props);
|
|
329
329
|
}, [props]);
|
|
330
330
|
const staticConfig = useMemo(() => {
|
|
331
|
-
const envConfig = config[
|
|
332
|
-
const isKnownTenant =
|
|
331
|
+
const envConfig = config[environment];
|
|
332
|
+
const isKnownTenant = tenantId in envConfig;
|
|
333
333
|
if (!isKnownTenant) {
|
|
334
|
-
logger.warn(`Unknown tenantId "${
|
|
335
|
-
tenantId
|
|
336
|
-
environment
|
|
334
|
+
logger.warn(`Unknown tenantId "${tenantId}", falling back to "moca"`, {
|
|
335
|
+
tenantId,
|
|
336
|
+
environment
|
|
337
337
|
});
|
|
338
338
|
}
|
|
339
|
-
const appKey = isKnownTenant ?
|
|
339
|
+
const appKey = isKnownTenant ? tenantId : "moca";
|
|
340
340
|
return envConfig[appKey];
|
|
341
|
-
}, [
|
|
341
|
+
}, [environment, tenantId]);
|
|
342
342
|
return /* @__PURE__ */ jsx2(StaticConfigContext.Provider, { value: { staticConfig, appProps }, children });
|
|
343
343
|
};
|
|
344
344
|
var useStaticConfig = () => {
|
|
@@ -464,22 +464,11 @@ var registerApi = (config2) => {
|
|
|
464
464
|
|
|
465
465
|
// src/hooks/useSpreePayConfig.ts
|
|
466
466
|
import useSWR from "swr";
|
|
467
|
+
var URL = "/v1/tenants/configs/spree-pay";
|
|
467
468
|
var useSpreePayConfig = () => {
|
|
468
|
-
const {
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
...data,
|
|
472
|
-
rainbowProjectId: data.rainbowProjectId ?? "3fdcd5ff50cb84917cd05e40146975d8",
|
|
473
|
-
rainbowAppName: data.rainbowAppName ?? "AIR Shop",
|
|
474
|
-
pointsTitle: data.pointsTitle ?? "AIR SP",
|
|
475
|
-
pointsConversionRatio: data.pointsConversionRatio ?? 0.01,
|
|
476
|
-
crypto: {
|
|
477
|
-
...data.crypto,
|
|
478
|
-
oneInchAggregationRouter: data.crypto?.oneInchAggregationRouter || "0x111111125421ca6dc452d289314280a0f8842a65"
|
|
479
|
-
}
|
|
480
|
-
} : null,
|
|
481
|
-
configIsLoading: isLoading
|
|
482
|
-
};
|
|
469
|
+
const { origin } = useSpreePayEnv();
|
|
470
|
+
const { data, isLoading } = useSWR(origin ? `${URL}?origin=${origin}` : URL);
|
|
471
|
+
return { spreePayConfig: data ?? null, configIsLoading: isLoading };
|
|
483
472
|
};
|
|
484
473
|
|
|
485
474
|
// src/components/common/InfoBanner.tsx
|
package/build/index.cjs
CHANGED
|
@@ -68,7 +68,7 @@ var init_payments = __esm({
|
|
|
68
68
|
var version;
|
|
69
69
|
var init_package = __esm({
|
|
70
70
|
"package.json"() {
|
|
71
|
-
version = "0.3.
|
|
71
|
+
version = "0.3.5";
|
|
72
72
|
}
|
|
73
73
|
});
|
|
74
74
|
|
|
@@ -285,7 +285,7 @@ var init_SpreePayActionsContext = __esm({
|
|
|
285
285
|
useSpreePayEnv = () => {
|
|
286
286
|
const ctx = (0, import_react.useContext)(SpreePayActionsContext);
|
|
287
287
|
if (!ctx) throw new Error("useSpreePay must be used within a SpreePayProvider");
|
|
288
|
-
return
|
|
288
|
+
return ctx.env;
|
|
289
289
|
};
|
|
290
290
|
useSpreePayRegister = () => {
|
|
291
291
|
const ctx = (0, import_react.useContext)(SpreePayActionsContext);
|
|
@@ -396,23 +396,23 @@ var init_StaticConfigContext = __esm({
|
|
|
396
396
|
import_jsx_runtime2 = require("react/jsx-runtime");
|
|
397
397
|
StaticConfigContext = (0, import_react2.createContext)(null);
|
|
398
398
|
StaticConfigProvider = ({ children, props }) => {
|
|
399
|
-
const {
|
|
399
|
+
const { environment, tenantId } = useSpreePayEnv();
|
|
400
400
|
const [appProps, setAppProps] = (0, import_react2.useState)(props);
|
|
401
401
|
(0, import_react2.useEffect)(() => {
|
|
402
402
|
setAppProps(props);
|
|
403
403
|
}, [props]);
|
|
404
404
|
const staticConfig = (0, import_react2.useMemo)(() => {
|
|
405
|
-
const envConfig = config[
|
|
406
|
-
const isKnownTenant =
|
|
405
|
+
const envConfig = config[environment];
|
|
406
|
+
const isKnownTenant = tenantId in envConfig;
|
|
407
407
|
if (!isKnownTenant) {
|
|
408
|
-
logger.warn(`Unknown tenantId "${
|
|
409
|
-
tenantId
|
|
410
|
-
environment
|
|
408
|
+
logger.warn(`Unknown tenantId "${tenantId}", falling back to "moca"`, {
|
|
409
|
+
tenantId,
|
|
410
|
+
environment
|
|
411
411
|
});
|
|
412
412
|
}
|
|
413
|
-
const appKey = isKnownTenant ?
|
|
413
|
+
const appKey = isKnownTenant ? tenantId : "moca";
|
|
414
414
|
return envConfig[appKey];
|
|
415
|
-
}, [
|
|
415
|
+
}, [environment, tenantId]);
|
|
416
416
|
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(StaticConfigContext.Provider, { value: { staticConfig, appProps }, children });
|
|
417
417
|
};
|
|
418
418
|
useStaticConfig = () => {
|
|
@@ -862,27 +862,17 @@ var init_transactionFee = __esm({
|
|
|
862
862
|
});
|
|
863
863
|
|
|
864
864
|
// src/hooks/useSpreePayConfig.ts
|
|
865
|
-
var import_swr, useSpreePayConfig;
|
|
865
|
+
var import_swr, URL, useSpreePayConfig;
|
|
866
866
|
var init_useSpreePayConfig = __esm({
|
|
867
867
|
"src/hooks/useSpreePayConfig.ts"() {
|
|
868
868
|
"use strict";
|
|
869
869
|
import_swr = __toESM(require("swr"), 1);
|
|
870
|
+
init_SpreePayActionsContext();
|
|
871
|
+
URL = "/v1/tenants/configs/spree-pay";
|
|
870
872
|
useSpreePayConfig = () => {
|
|
871
|
-
const {
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
...data,
|
|
875
|
-
rainbowProjectId: data.rainbowProjectId ?? "3fdcd5ff50cb84917cd05e40146975d8",
|
|
876
|
-
rainbowAppName: data.rainbowAppName ?? "AIR Shop",
|
|
877
|
-
pointsTitle: data.pointsTitle ?? "AIR SP",
|
|
878
|
-
pointsConversionRatio: data.pointsConversionRatio ?? 0.01,
|
|
879
|
-
crypto: {
|
|
880
|
-
...data.crypto,
|
|
881
|
-
oneInchAggregationRouter: data.crypto?.oneInchAggregationRouter || "0x111111125421ca6dc452d289314280a0f8842a65"
|
|
882
|
-
}
|
|
883
|
-
} : null,
|
|
884
|
-
configIsLoading: isLoading
|
|
885
|
-
};
|
|
873
|
+
const { origin } = useSpreePayEnv();
|
|
874
|
+
const { data, isLoading } = (0, import_swr.default)(origin ? `${URL}?origin=${origin}` : URL);
|
|
875
|
+
return { spreePayConfig: data ?? null, configIsLoading: isLoading };
|
|
886
876
|
};
|
|
887
877
|
}
|
|
888
878
|
});
|
|
@@ -1233,7 +1223,7 @@ var init_CheckoutButton = __esm({
|
|
|
1233
1223
|
const { appProps, staticConfig } = useStaticConfig();
|
|
1234
1224
|
const { amount, onProcess, isProcessing, transactionFeePercentage } = appProps;
|
|
1235
1225
|
const { spreePayConfig } = useSpreePayConfig();
|
|
1236
|
-
const {
|
|
1226
|
+
const { tenantId, keycloakClientId } = useSpreePayEnv();
|
|
1237
1227
|
const { selectedPaymentMethod, isInternalProcessing } = useSpreePaymentMethod();
|
|
1238
1228
|
const { splitAmount, type, method } = selectedPaymentMethod;
|
|
1239
1229
|
const usdAmount = getSplitAmount(amount ?? 0, splitAmount ?? 0, spreePayConfig?.pointsConversionRatio);
|
|
@@ -1267,11 +1257,11 @@ var init_CheckoutButton = __esm({
|
|
|
1267
1257
|
isLoggedIn ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_jsx_runtime11.Fragment, { children: onProcess && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("button", { disabled: isDisabled, onClick: onProcess, className: checkoutClass, children: getCheckoutContent() }) }) : /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
|
|
1268
1258
|
"a",
|
|
1269
1259
|
{
|
|
1270
|
-
href: `${staticConfig.keycloakUrl}/realms/${
|
|
1260
|
+
href: `${staticConfig.keycloakUrl}/realms/${tenantId}/protocol/openid-connect/auth?client_id=${keycloakClientId ?? "oneof-next"}&response_type=code&redirect_uri=${window.location.href}`,
|
|
1271
1261
|
className: checkoutClass,
|
|
1272
1262
|
children: [
|
|
1273
1263
|
"Log in / Sign up",
|
|
1274
|
-
|
|
1264
|
+
tenantId === "moca" ? " for an AIR account" : ""
|
|
1275
1265
|
]
|
|
1276
1266
|
}
|
|
1277
1267
|
),
|
|
@@ -2314,7 +2304,7 @@ var init_useCryptoComPayment = __esm({
|
|
|
2314
2304
|
cryptoComLogger = logger.child("crypto-com-payment");
|
|
2315
2305
|
useCryptoComPayment = () => {
|
|
2316
2306
|
const { selectedPaymentMethod } = useSpreePaymentMethod();
|
|
2317
|
-
const {
|
|
2307
|
+
const { redirect3dsURI } = useSpreePayEnv();
|
|
2318
2308
|
const cryptoComPayment = async (params) => {
|
|
2319
2309
|
if (selectedPaymentMethod.type !== "CDC" /* CDC */) {
|
|
2320
2310
|
throw new Error("Unsupported payment method");
|
|
@@ -2326,8 +2316,8 @@ var init_useCryptoComPayment = __esm({
|
|
|
2326
2316
|
metadata,
|
|
2327
2317
|
type: "CDC" /* CDC */,
|
|
2328
2318
|
cdc: {
|
|
2329
|
-
returnUrl: `${typeof window !== "undefined" ? window.location.origin : ""}${
|
|
2330
|
-
cancelUrl: `${typeof window !== "undefined" ? window.location.origin : ""}${
|
|
2319
|
+
returnUrl: `${typeof window !== "undefined" ? window.location.origin : ""}${redirect3dsURI}?payment_intent=success`,
|
|
2320
|
+
cancelUrl: `${typeof window !== "undefined" ? window.location.origin : ""}${redirect3dsURI}?payment_intent=canceled`
|
|
2331
2321
|
}
|
|
2332
2322
|
});
|
|
2333
2323
|
cryptoComLogger.info("Payment created", {
|
|
@@ -2529,7 +2519,7 @@ init_transactionFee();
|
|
|
2529
2519
|
var cardPaymentLogger = logger.child("card-payment");
|
|
2530
2520
|
var useCardPayment = () => {
|
|
2531
2521
|
const { selectedPaymentMethod } = useSpreePaymentMethod();
|
|
2532
|
-
const {
|
|
2522
|
+
const { redirect3dsURI } = useSpreePayEnv();
|
|
2533
2523
|
const { appProps } = useStaticConfig();
|
|
2534
2524
|
const cardPayment = async (params) => {
|
|
2535
2525
|
if (selectedPaymentMethod.type !== "CREDIT_CARD" /* CREDIT_CARD */ || !selectedPaymentMethod.method) {
|
|
@@ -2577,7 +2567,7 @@ var useCardPayment = () => {
|
|
|
2577
2567
|
card: {
|
|
2578
2568
|
cardId,
|
|
2579
2569
|
transactionFee,
|
|
2580
|
-
returnUrl: `${typeof window !== "undefined" ? window.location.origin : ""}${
|
|
2570
|
+
returnUrl: `${typeof window !== "undefined" ? window.location.origin : ""}${redirect3dsURI}`
|
|
2581
2571
|
}
|
|
2582
2572
|
});
|
|
2583
2573
|
let { status } = paymentResData;
|
|
@@ -2907,7 +2897,7 @@ init_useSpreePayConfig();
|
|
|
2907
2897
|
var splitPaymentLogger = logger.child("split-card-payment");
|
|
2908
2898
|
var useSplitCardPayments = (mode = "web2") => {
|
|
2909
2899
|
const { selectedPaymentMethod } = useSpreePaymentMethod();
|
|
2910
|
-
const {
|
|
2900
|
+
const { redirect3dsURI } = useSpreePayEnv();
|
|
2911
2901
|
const { appProps } = useStaticConfig();
|
|
2912
2902
|
const { spreePayConfig } = useSpreePayConfig();
|
|
2913
2903
|
const splitPayment = async (params) => {
|
|
@@ -2947,7 +2937,7 @@ var useSplitCardPayments = (mode = "web2") => {
|
|
|
2947
2937
|
card: {
|
|
2948
2938
|
cardId,
|
|
2949
2939
|
transactionFee,
|
|
2950
|
-
returnUrl: `${typeof window !== "undefined" ? window.location.origin : ""}${
|
|
2940
|
+
returnUrl: `${typeof window !== "undefined" ? window.location.origin : ""}${redirect3dsURI}`
|
|
2951
2941
|
},
|
|
2952
2942
|
points: {
|
|
2953
2943
|
amount: points
|
|
@@ -3036,8 +3026,10 @@ var useSplitCardPayments = (mode = "web2") => {
|
|
|
3036
3026
|
|
|
3037
3027
|
// src/hooks/useCards.ts
|
|
3038
3028
|
var import_swr2 = __toESM(require("swr"), 1);
|
|
3029
|
+
init_SpreePayActionsContext();
|
|
3039
3030
|
var useCards = () => {
|
|
3040
|
-
const {
|
|
3031
|
+
const { origin } = useSpreePayEnv();
|
|
3032
|
+
const { data, isLoading, mutate } = (0, import_swr2.default)(`/v1/payments/cards?origin=${origin}`);
|
|
3041
3033
|
return {
|
|
3042
3034
|
cards: data?.data.filter((c) => c.active) || [],
|
|
3043
3035
|
cardsIsLoading: isLoading,
|
|
@@ -4500,7 +4492,7 @@ var SplitBlock = (props) => {
|
|
|
4500
4492
|
const [address, setAddress] = (0, import_react11.useState)(null);
|
|
4501
4493
|
const [walletReady, setWalletReady] = (0, import_react11.useState)(false);
|
|
4502
4494
|
const { pointsConversionRatio, pointsTitle } = spreePayConfig || {};
|
|
4503
|
-
const {
|
|
4495
|
+
const { useWeb3Points, environment } = useSpreePayEnv();
|
|
4504
4496
|
const prevPointsChainRef = (0, import_react11.useRef)(spreePayConfig?.pointsChain);
|
|
4505
4497
|
const initWallet = (0, import_react11.useCallback)(
|
|
4506
4498
|
async (pointsChain) => {
|
|
@@ -4509,7 +4501,7 @@ var SplitBlock = (props) => {
|
|
|
4509
4501
|
const res = await getAirWallet({
|
|
4510
4502
|
mocaChain: pointsChain.mocaChain,
|
|
4511
4503
|
partnerId: pointsChain.partnerId,
|
|
4512
|
-
buildEnv:
|
|
4504
|
+
buildEnv: environment === "prod" ? import_airkit2.BUILD_ENV.PRODUCTION : import_airkit2.BUILD_ENV.SANDBOX
|
|
4513
4505
|
});
|
|
4514
4506
|
setAddress(res.address ?? null);
|
|
4515
4507
|
setWalletReady(res.walletReady);
|
|
@@ -4519,14 +4511,14 @@ var SplitBlock = (props) => {
|
|
|
4519
4511
|
} catch (e) {
|
|
4520
4512
|
splitBlockLogger.error("Air Wallet initialization failed", e, {
|
|
4521
4513
|
partnerId: pointsChain?.partnerId,
|
|
4522
|
-
environment
|
|
4514
|
+
environment
|
|
4523
4515
|
});
|
|
4524
4516
|
}
|
|
4525
4517
|
},
|
|
4526
|
-
[onToggle,
|
|
4518
|
+
[onToggle, environment]
|
|
4527
4519
|
);
|
|
4528
4520
|
(0, import_react11.useEffect)(() => {
|
|
4529
|
-
if (!
|
|
4521
|
+
if (!useWeb3Points) return;
|
|
4530
4522
|
const pointsChainChanged = prevPointsChainRef.current !== spreePayConfig?.pointsChain;
|
|
4531
4523
|
prevPointsChainRef.current = spreePayConfig?.pointsChain;
|
|
4532
4524
|
const doInit = async () => {
|
|
@@ -4537,8 +4529,8 @@ var SplitBlock = (props) => {
|
|
|
4537
4529
|
await initWallet(spreePayConfig?.pointsChain);
|
|
4538
4530
|
};
|
|
4539
4531
|
doInit();
|
|
4540
|
-
}, [spreePayConfig?.pointsChain, initWallet,
|
|
4541
|
-
const isPointsSelectorDisabled =
|
|
4532
|
+
}, [spreePayConfig?.pointsChain, initWallet, useWeb3Points]);
|
|
4533
|
+
const isPointsSelectorDisabled = useWeb3Points ? !walletReady : false;
|
|
4542
4534
|
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: "flex flex-col gap-1", children: /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(PointsSelector, { isDisabled: isPointsSelectorDisabled, onSelect: () => onSelect("air"), isSelected, children: [
|
|
4543
4535
|
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: "flex items-center gap-2", children: balance?.availablePoints ? /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("p", { className: "text-left text-xs font-medium text-(--brand-primary) sm:text-sm", children: [
|
|
4544
4536
|
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)("span", { className: "text-(--secondary)", children: "Available" }),
|
|
@@ -4592,13 +4584,13 @@ var Points = () => {
|
|
|
4592
4584
|
var import_jsx_runtime28 = require("react/jsx-runtime");
|
|
4593
4585
|
var CreditCardTab = ({ isLoggedIn }) => {
|
|
4594
4586
|
const { selectedPaymentMethod, setSelectedPaymentMethod } = useSpreePaymentMethod();
|
|
4595
|
-
const {
|
|
4587
|
+
const { useWeb3Points } = useSpreePayEnv();
|
|
4596
4588
|
const { appProps } = useStaticConfig();
|
|
4597
4589
|
const { spreePayConfig } = useSpreePayConfig();
|
|
4598
4590
|
const { register } = useSpreePayRegister();
|
|
4599
4591
|
const { mutateCards } = useCards();
|
|
4600
4592
|
const { mutateBalance } = useSlapiBalance();
|
|
4601
|
-
const isWeb3Enabled = Boolean(
|
|
4593
|
+
const isWeb3Enabled = Boolean(useWeb3Points);
|
|
4602
4594
|
const { cardPayment } = useCardPayment();
|
|
4603
4595
|
const { splitPayment } = useSplitCardPayments(isWeb3Enabled ? "web3" : "web2");
|
|
4604
4596
|
const { pointsPayment } = usePointsPayment(isWeb3Enabled ? "web3" : "web2");
|
|
@@ -4891,21 +4883,20 @@ var SpreePayInner = () => {
|
|
|
4891
4883
|
const el = node.querySelector(":scope > .sl-spreepay__portal");
|
|
4892
4884
|
setPortalEl(el ?? null);
|
|
4893
4885
|
}, []);
|
|
4894
|
-
const {
|
|
4886
|
+
const { environment, tenantId, keycloakClientId, accessToken: envAccessToken, ssoPageURI } = useSpreePayEnv();
|
|
4895
4887
|
(0, import_react21.useEffect)(() => {
|
|
4896
|
-
configureLogger({ environment
|
|
4888
|
+
configureLogger({ environment });
|
|
4897
4889
|
logger.logVersion();
|
|
4898
|
-
}, [
|
|
4890
|
+
}, [environment]);
|
|
4899
4891
|
const { staticConfig, appProps } = useStaticConfig();
|
|
4900
|
-
const tenantId = env?.tenantId;
|
|
4901
4892
|
const { isChecking, accessToken } = useKeycloakSSO({
|
|
4902
4893
|
realm: tenantId,
|
|
4903
4894
|
url: staticConfig.keycloakUrl,
|
|
4904
|
-
clientId:
|
|
4905
|
-
ssoPageURI
|
|
4906
|
-
enabled: !
|
|
4895
|
+
clientId: keycloakClientId ?? "oneof-next",
|
|
4896
|
+
ssoPageURI,
|
|
4897
|
+
enabled: !envAccessToken
|
|
4907
4898
|
});
|
|
4908
|
-
const _accessToken =
|
|
4899
|
+
const _accessToken = envAccessToken ?? accessToken;
|
|
4909
4900
|
const unauthenticatedFetcher = (0, import_react21.useCallback)(() => Promise.resolve(null), []);
|
|
4910
4901
|
const slapiFetcher = (0, import_react21.useMemo)(() => {
|
|
4911
4902
|
if (_accessToken) {
|
package/build/index.d.cts
CHANGED
package/build/index.d.ts
CHANGED
package/build/index.js
CHANGED
|
@@ -8,10 +8,10 @@ import {
|
|
|
8
8
|
getSplitAmount,
|
|
9
9
|
getTransactionFee,
|
|
10
10
|
useSlapiBalance
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-FHY6YBXC.js";
|
|
12
12
|
import {
|
|
13
13
|
Iframe3ds
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-D23MABH2.js";
|
|
15
15
|
import {
|
|
16
16
|
InfoBanner,
|
|
17
17
|
LogLevel,
|
|
@@ -31,7 +31,7 @@ import {
|
|
|
31
31
|
useSpreePayRegister,
|
|
32
32
|
useSpreePaymentMethod,
|
|
33
33
|
useStaticConfig
|
|
34
|
-
} from "./chunk-
|
|
34
|
+
} from "./chunk-KQ25SXYH.js";
|
|
35
35
|
|
|
36
36
|
// src/SpreePay.tsx
|
|
37
37
|
import { useCallback as useCallback7, useEffect as useEffect8, useMemo as useMemo7, useState as useState10 } from "react";
|
|
@@ -49,7 +49,7 @@ import NiceModal from "@ebay/nice-modal-react";
|
|
|
49
49
|
var cardPaymentLogger = logger.child("card-payment");
|
|
50
50
|
var useCardPayment = () => {
|
|
51
51
|
const { selectedPaymentMethod } = useSpreePaymentMethod();
|
|
52
|
-
const {
|
|
52
|
+
const { redirect3dsURI } = useSpreePayEnv();
|
|
53
53
|
const { appProps } = useStaticConfig();
|
|
54
54
|
const cardPayment = async (params) => {
|
|
55
55
|
if (selectedPaymentMethod.type !== "CREDIT_CARD" /* CREDIT_CARD */ || !selectedPaymentMethod.method) {
|
|
@@ -97,7 +97,7 @@ var useCardPayment = () => {
|
|
|
97
97
|
card: {
|
|
98
98
|
cardId,
|
|
99
99
|
transactionFee,
|
|
100
|
-
returnUrl: `${typeof window !== "undefined" ? window.location.origin : ""}${
|
|
100
|
+
returnUrl: `${typeof window !== "undefined" ? window.location.origin : ""}${redirect3dsURI}`
|
|
101
101
|
}
|
|
102
102
|
});
|
|
103
103
|
let { status } = paymentResData;
|
|
@@ -408,7 +408,7 @@ import NiceModal3 from "@ebay/nice-modal-react";
|
|
|
408
408
|
var splitPaymentLogger = logger.child("split-card-payment");
|
|
409
409
|
var useSplitCardPayments = (mode = "web2") => {
|
|
410
410
|
const { selectedPaymentMethod } = useSpreePaymentMethod();
|
|
411
|
-
const {
|
|
411
|
+
const { redirect3dsURI } = useSpreePayEnv();
|
|
412
412
|
const { appProps } = useStaticConfig();
|
|
413
413
|
const { spreePayConfig } = useSpreePayConfig();
|
|
414
414
|
const splitPayment = async (params) => {
|
|
@@ -448,7 +448,7 @@ var useSplitCardPayments = (mode = "web2") => {
|
|
|
448
448
|
card: {
|
|
449
449
|
cardId,
|
|
450
450
|
transactionFee,
|
|
451
|
-
returnUrl: `${typeof window !== "undefined" ? window.location.origin : ""}${
|
|
451
|
+
returnUrl: `${typeof window !== "undefined" ? window.location.origin : ""}${redirect3dsURI}`
|
|
452
452
|
},
|
|
453
453
|
points: {
|
|
454
454
|
amount: points
|
|
@@ -538,7 +538,8 @@ var useSplitCardPayments = (mode = "web2") => {
|
|
|
538
538
|
// src/hooks/useCards.ts
|
|
539
539
|
import useSWR from "swr";
|
|
540
540
|
var useCards = () => {
|
|
541
|
-
const {
|
|
541
|
+
const { origin } = useSpreePayEnv();
|
|
542
|
+
const { data, isLoading, mutate } = useSWR(`/v1/payments/cards?origin=${origin}`);
|
|
542
543
|
return {
|
|
543
544
|
cards: data?.data.filter((c) => c.active) || [],
|
|
544
545
|
cardsIsLoading: isLoading,
|
|
@@ -1967,7 +1968,7 @@ var SplitBlock = (props) => {
|
|
|
1967
1968
|
const [address, setAddress] = useState7(null);
|
|
1968
1969
|
const [walletReady, setWalletReady] = useState7(false);
|
|
1969
1970
|
const { pointsConversionRatio, pointsTitle } = spreePayConfig || {};
|
|
1970
|
-
const {
|
|
1971
|
+
const { useWeb3Points, environment } = useSpreePayEnv();
|
|
1971
1972
|
const prevPointsChainRef = useRef6(spreePayConfig?.pointsChain);
|
|
1972
1973
|
const initWallet = useCallback4(
|
|
1973
1974
|
async (pointsChain) => {
|
|
@@ -1976,7 +1977,7 @@ var SplitBlock = (props) => {
|
|
|
1976
1977
|
const res = await getAirWallet({
|
|
1977
1978
|
mocaChain: pointsChain.mocaChain,
|
|
1978
1979
|
partnerId: pointsChain.partnerId,
|
|
1979
|
-
buildEnv:
|
|
1980
|
+
buildEnv: environment === "prod" ? BUILD_ENV2.PRODUCTION : BUILD_ENV2.SANDBOX
|
|
1980
1981
|
});
|
|
1981
1982
|
setAddress(res.address ?? null);
|
|
1982
1983
|
setWalletReady(res.walletReady);
|
|
@@ -1986,14 +1987,14 @@ var SplitBlock = (props) => {
|
|
|
1986
1987
|
} catch (e) {
|
|
1987
1988
|
splitBlockLogger.error("Air Wallet initialization failed", e, {
|
|
1988
1989
|
partnerId: pointsChain?.partnerId,
|
|
1989
|
-
environment
|
|
1990
|
+
environment
|
|
1990
1991
|
});
|
|
1991
1992
|
}
|
|
1992
1993
|
},
|
|
1993
|
-
[onToggle,
|
|
1994
|
+
[onToggle, environment]
|
|
1994
1995
|
);
|
|
1995
1996
|
useEffect5(() => {
|
|
1996
|
-
if (!
|
|
1997
|
+
if (!useWeb3Points) return;
|
|
1997
1998
|
const pointsChainChanged = prevPointsChainRef.current !== spreePayConfig?.pointsChain;
|
|
1998
1999
|
prevPointsChainRef.current = spreePayConfig?.pointsChain;
|
|
1999
2000
|
const doInit = async () => {
|
|
@@ -2004,8 +2005,8 @@ var SplitBlock = (props) => {
|
|
|
2004
2005
|
await initWallet(spreePayConfig?.pointsChain);
|
|
2005
2006
|
};
|
|
2006
2007
|
doInit();
|
|
2007
|
-
}, [spreePayConfig?.pointsChain, initWallet,
|
|
2008
|
-
const isPointsSelectorDisabled =
|
|
2008
|
+
}, [spreePayConfig?.pointsChain, initWallet, useWeb3Points]);
|
|
2009
|
+
const isPointsSelectorDisabled = useWeb3Points ? !walletReady : false;
|
|
2009
2010
|
return /* @__PURE__ */ jsx14("div", { className: "flex flex-col gap-1", children: /* @__PURE__ */ jsxs7(PointsSelector, { isDisabled: isPointsSelectorDisabled, onSelect: () => onSelect("air"), isSelected, children: [
|
|
2010
2011
|
/* @__PURE__ */ jsx14("div", { className: "flex items-center gap-2", children: balance?.availablePoints ? /* @__PURE__ */ jsxs7("p", { className: "text-left text-xs font-medium text-(--brand-primary) sm:text-sm", children: [
|
|
2011
2012
|
/* @__PURE__ */ jsx14("span", { className: "text-(--secondary)", children: "Available" }),
|
|
@@ -2059,13 +2060,13 @@ var Points = () => {
|
|
|
2059
2060
|
import { jsx as jsx16, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
2060
2061
|
var CreditCardTab = ({ isLoggedIn }) => {
|
|
2061
2062
|
const { selectedPaymentMethod, setSelectedPaymentMethod } = useSpreePaymentMethod();
|
|
2062
|
-
const {
|
|
2063
|
+
const { useWeb3Points } = useSpreePayEnv();
|
|
2063
2064
|
const { appProps } = useStaticConfig();
|
|
2064
2065
|
const { spreePayConfig } = useSpreePayConfig();
|
|
2065
2066
|
const { register } = useSpreePayRegister();
|
|
2066
2067
|
const { mutateCards } = useCards();
|
|
2067
2068
|
const { mutateBalance } = useSlapiBalance();
|
|
2068
|
-
const isWeb3Enabled = Boolean(
|
|
2069
|
+
const isWeb3Enabled = Boolean(useWeb3Points);
|
|
2069
2070
|
const { cardPayment } = useCardPayment();
|
|
2070
2071
|
const { splitPayment } = useSplitCardPayments(isWeb3Enabled ? "web3" : "web2");
|
|
2071
2072
|
const { pointsPayment } = usePointsPayment(isWeb3Enabled ? "web3" : "web2");
|
|
@@ -2190,9 +2191,9 @@ var TabButtons = (props) => {
|
|
|
2190
2191
|
|
|
2191
2192
|
// src/SpreePayContent.tsx
|
|
2192
2193
|
import { jsx as jsx18, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
2193
|
-
var CryptoTab = lazy(() => import("./CryptoTab-
|
|
2194
|
+
var CryptoTab = lazy(() => import("./CryptoTab-CI5C22BD.js").then((module) => ({ default: module.CryptoTab })));
|
|
2194
2195
|
var CryptoComTab = lazy(
|
|
2195
|
-
() => import("./CryptoComTab-
|
|
2196
|
+
() => import("./CryptoComTab-P4MC2R2N.js").then((module) => ({ default: module.CryptoComTab }))
|
|
2196
2197
|
);
|
|
2197
2198
|
var TabLoadingFallback = () => /* @__PURE__ */ jsx18("div", { className: "flex items-center justify-center px-5 py-8 md:px-7", children: /* @__PURE__ */ jsxs11("div", { className: "flex flex-col items-center gap-3", children: [
|
|
2198
2199
|
/* @__PURE__ */ jsx18("div", { className: "h-8 w-8 animate-spin rounded-full border-4 border-(--border-component-specific-card) border-t-(--brand-primary)" }),
|
|
@@ -2345,21 +2346,20 @@ var SpreePayInner = () => {
|
|
|
2345
2346
|
const el = node.querySelector(":scope > .sl-spreepay__portal");
|
|
2346
2347
|
setPortalEl(el ?? null);
|
|
2347
2348
|
}, []);
|
|
2348
|
-
const {
|
|
2349
|
+
const { environment, tenantId, keycloakClientId, accessToken: envAccessToken, ssoPageURI } = useSpreePayEnv();
|
|
2349
2350
|
useEffect8(() => {
|
|
2350
|
-
configureLogger({ environment
|
|
2351
|
+
configureLogger({ environment });
|
|
2351
2352
|
logger.logVersion();
|
|
2352
|
-
}, [
|
|
2353
|
+
}, [environment]);
|
|
2353
2354
|
const { staticConfig, appProps } = useStaticConfig();
|
|
2354
|
-
const tenantId = env?.tenantId;
|
|
2355
2355
|
const { isChecking, accessToken } = useKeycloakSSO({
|
|
2356
2356
|
realm: tenantId,
|
|
2357
2357
|
url: staticConfig.keycloakUrl,
|
|
2358
|
-
clientId:
|
|
2359
|
-
ssoPageURI
|
|
2360
|
-
enabled: !
|
|
2358
|
+
clientId: keycloakClientId ?? "oneof-next",
|
|
2359
|
+
ssoPageURI,
|
|
2360
|
+
enabled: !envAccessToken
|
|
2361
2361
|
});
|
|
2362
|
-
const _accessToken =
|
|
2362
|
+
const _accessToken = envAccessToken ?? accessToken;
|
|
2363
2363
|
const unauthenticatedFetcher = useCallback7(() => Promise.resolve(null), []);
|
|
2364
2364
|
const slapiFetcher = useMemo7(() => {
|
|
2365
2365
|
if (_accessToken) {
|