@superlogic/spree-pay 0.1.28 → 0.1.29
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/build/index.cjs +18 -9
- package/build/index.css +6 -2
- package/build/index.js +30 -21
- package/package.json +1 -1
package/build/index.cjs
CHANGED
|
@@ -44,7 +44,7 @@ var import_nice_modal_react7 = __toESM(require("@ebay/nice-modal-react"), 1);
|
|
|
44
44
|
var import_swr5 = require("swr");
|
|
45
45
|
|
|
46
46
|
// package.json
|
|
47
|
-
var version = "0.1.
|
|
47
|
+
var version = "0.1.29";
|
|
48
48
|
|
|
49
49
|
// src/context/SpreePayActionsContext.tsx
|
|
50
50
|
var import_react = require("react");
|
|
@@ -323,9 +323,10 @@ var getTransactionFee = (amount = 0, transactionFeePercentage) => {
|
|
|
323
323
|
// src/components/CheckoutButton.tsx
|
|
324
324
|
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
325
325
|
var CheckoutButton = ({ isLoggedIn }) => {
|
|
326
|
-
const { appProps } = useStaticConfig();
|
|
326
|
+
const { appProps, staticConfig } = useStaticConfig();
|
|
327
327
|
const { amount, onProcess, isProcessing, transactionFeePercentage } = appProps;
|
|
328
328
|
const { spreePayConfig } = useSpreePayConfig();
|
|
329
|
+
const { env } = useSpreePayEnv();
|
|
329
330
|
const { selectedPaymentMethod, isInternalProcessing } = useSpreePaymentMethod();
|
|
330
331
|
const { splitAmount, type, method } = selectedPaymentMethod;
|
|
331
332
|
const usdAmount = getSplitAmount(amount ?? 0, splitAmount ?? 0, spreePayConfig?.pointsConversionRatio);
|
|
@@ -360,7 +361,7 @@ var CheckoutButton = ({ isLoggedIn }) => {
|
|
|
360
361
|
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("a", { className: "underline", href: spreePayConfig?.termsConditionsUrl, target: "_blank", rel: "noreferrer", children: "Terms and Conditions" }),
|
|
361
362
|
"."
|
|
362
363
|
] }) }),
|
|
363
|
-
onProcess && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
364
|
+
isLoggedIn ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_jsx_runtime4.Fragment, { children: onProcess && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
364
365
|
"button",
|
|
365
366
|
{
|
|
366
367
|
disabled: isDisabled,
|
|
@@ -368,6 +369,13 @@ var CheckoutButton = ({ isLoggedIn }) => {
|
|
|
368
369
|
className: "bg-primary h-[60px] w-full cursor-pointer text-xl font-semibold text-white disabled:cursor-not-allowed disabled:opacity-50",
|
|
369
370
|
children: getCheckoutContent()
|
|
370
371
|
}
|
|
372
|
+
) }) : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
373
|
+
"a",
|
|
374
|
+
{
|
|
375
|
+
href: `${staticConfig.keycloakUrl}/realms/${env.tenantId}/protocol/openid-connect/logout?client_id=${staticConfig.keycloakClientId}&post_logout_redirect_uri=${window.location.origin}${window.location.pathname}`,
|
|
376
|
+
className: "bg-primary h-[60px] w-full cursor-pointer text-center text-xl leading-[60px] font-semibold text-white disabled:cursor-not-allowed disabled:opacity-50",
|
|
377
|
+
children: "Login"
|
|
378
|
+
}
|
|
371
379
|
)
|
|
372
380
|
] });
|
|
373
381
|
};
|
|
@@ -2400,7 +2408,7 @@ var PointsSelector = (props) => {
|
|
|
2400
2408
|
readOnly: true,
|
|
2401
2409
|
name: "points amount",
|
|
2402
2410
|
value: Math.round(splitTokens),
|
|
2403
|
-
className: "sm:text-md min-w-[
|
|
2411
|
+
className: "sm:text-md min-w-[80px] bg-white px-1 text-center text-xs font-medium sm:px-3",
|
|
2404
2412
|
onClick: (e) => e.stopPropagation()
|
|
2405
2413
|
}
|
|
2406
2414
|
),
|
|
@@ -2425,7 +2433,7 @@ var PointsSelector = (props) => {
|
|
|
2425
2433
|
readOnly: true,
|
|
2426
2434
|
name: "usd amount",
|
|
2427
2435
|
value: formatUSD(usdAmount + getTransactionFee(usdAmount, appProps.transactionFeePercentage)),
|
|
2428
|
-
className: "sm:text-md min-w-[
|
|
2436
|
+
className: "sm:text-md min-w-[80px] bg-white px-1 text-center text-xs font-medium sm:px-3",
|
|
2429
2437
|
onClick: (e) => e.stopPropagation()
|
|
2430
2438
|
}
|
|
2431
2439
|
),
|
|
@@ -3499,15 +3507,16 @@ var SpreePayInner = () => {
|
|
|
3499
3507
|
ssoPageURI: env?.ssoPageURI,
|
|
3500
3508
|
enabled: !env?.accessToken
|
|
3501
3509
|
});
|
|
3510
|
+
const _accessToken = env.accessToken ?? accessToken;
|
|
3502
3511
|
const slapiFetcher = (0, import_react18.useMemo)(() => {
|
|
3503
|
-
if (
|
|
3512
|
+
if (_accessToken) {
|
|
3504
3513
|
return registerApi({
|
|
3505
|
-
accessToken:
|
|
3514
|
+
accessToken: _accessToken,
|
|
3506
3515
|
tenantId,
|
|
3507
3516
|
baseUrl: staticConfig.slapiUrl
|
|
3508
3517
|
});
|
|
3509
3518
|
}
|
|
3510
|
-
}, [
|
|
3519
|
+
}, [_accessToken, staticConfig, tenantId]);
|
|
3511
3520
|
const getContent = () => {
|
|
3512
3521
|
if (isChecking) {
|
|
3513
3522
|
return /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("div", { className: "flex w-full flex-col", children: [
|
|
@@ -3525,7 +3534,7 @@ var SpreePayInner = () => {
|
|
|
3525
3534
|
revalidateOnFocus: false,
|
|
3526
3535
|
revalidateIfStale: false
|
|
3527
3536
|
},
|
|
3528
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(PortalContainerProvider, { container: portalEl, children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(import_nice_modal_react7.default.Provider, { children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(SpreePayContent, { isLoggedIn: Boolean(
|
|
3537
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(PortalContainerProvider, { container: portalEl, children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(import_nice_modal_react7.default.Provider, { children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(SpreePayContent, { isLoggedIn: Boolean(_accessToken) }) }) })
|
|
3529
3538
|
}
|
|
3530
3539
|
);
|
|
3531
3540
|
};
|
package/build/index.css
CHANGED
|
@@ -464,8 +464,8 @@
|
|
|
464
464
|
.sl-spreepay .min-w-0 {
|
|
465
465
|
min-width: calc(var(--spacing) * 0);
|
|
466
466
|
}
|
|
467
|
-
.sl-spreepay .min-w-\[
|
|
468
|
-
min-width:
|
|
467
|
+
.sl-spreepay .min-w-\[80px\] {
|
|
468
|
+
min-width: 80px;
|
|
469
469
|
}
|
|
470
470
|
.sl-spreepay .flex-1 {
|
|
471
471
|
flex: 1;
|
|
@@ -827,6 +827,10 @@
|
|
|
827
827
|
--tw-leading: 34px;
|
|
828
828
|
line-height: 34px;
|
|
829
829
|
}
|
|
830
|
+
.sl-spreepay .leading-\[60px\] {
|
|
831
|
+
--tw-leading: 60px;
|
|
832
|
+
line-height: 60px;
|
|
833
|
+
}
|
|
830
834
|
.sl-spreepay .leading-none {
|
|
831
835
|
--tw-leading: 1;
|
|
832
836
|
line-height: 1;
|
package/build/index.js
CHANGED
|
@@ -4,7 +4,7 @@ import NiceModal7 from "@ebay/nice-modal-react";
|
|
|
4
4
|
import { SWRConfig } from "swr";
|
|
5
5
|
|
|
6
6
|
// package.json
|
|
7
|
-
var version = "0.1.
|
|
7
|
+
var version = "0.1.29";
|
|
8
8
|
|
|
9
9
|
// src/context/SpreePayActionsContext.tsx
|
|
10
10
|
import { createContext, useCallback, useContext, useRef, useState } from "react";
|
|
@@ -281,11 +281,12 @@ var getTransactionFee = (amount = 0, transactionFeePercentage) => {
|
|
|
281
281
|
};
|
|
282
282
|
|
|
283
283
|
// src/components/CheckoutButton.tsx
|
|
284
|
-
import { jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
284
|
+
import { Fragment, jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
285
285
|
var CheckoutButton = ({ isLoggedIn }) => {
|
|
286
|
-
const { appProps } = useStaticConfig();
|
|
286
|
+
const { appProps, staticConfig } = useStaticConfig();
|
|
287
287
|
const { amount, onProcess, isProcessing, transactionFeePercentage } = appProps;
|
|
288
288
|
const { spreePayConfig } = useSpreePayConfig();
|
|
289
|
+
const { env } = useSpreePayEnv();
|
|
289
290
|
const { selectedPaymentMethod, isInternalProcessing } = useSpreePaymentMethod();
|
|
290
291
|
const { splitAmount, type, method } = selectedPaymentMethod;
|
|
291
292
|
const usdAmount = getSplitAmount(amount ?? 0, splitAmount ?? 0, spreePayConfig?.pointsConversionRatio);
|
|
@@ -320,7 +321,7 @@ var CheckoutButton = ({ isLoggedIn }) => {
|
|
|
320
321
|
/* @__PURE__ */ jsx4("a", { className: "underline", href: spreePayConfig?.termsConditionsUrl, target: "_blank", rel: "noreferrer", children: "Terms and Conditions" }),
|
|
321
322
|
"."
|
|
322
323
|
] }) }),
|
|
323
|
-
onProcess && /* @__PURE__ */ jsx4(
|
|
324
|
+
isLoggedIn ? /* @__PURE__ */ jsx4(Fragment, { children: onProcess && /* @__PURE__ */ jsx4(
|
|
324
325
|
"button",
|
|
325
326
|
{
|
|
326
327
|
disabled: isDisabled,
|
|
@@ -328,6 +329,13 @@ var CheckoutButton = ({ isLoggedIn }) => {
|
|
|
328
329
|
className: "bg-primary h-[60px] w-full cursor-pointer text-xl font-semibold text-white disabled:cursor-not-allowed disabled:opacity-50",
|
|
329
330
|
children: getCheckoutContent()
|
|
330
331
|
}
|
|
332
|
+
) }) : /* @__PURE__ */ jsx4(
|
|
333
|
+
"a",
|
|
334
|
+
{
|
|
335
|
+
href: `${staticConfig.keycloakUrl}/realms/${env.tenantId}/protocol/openid-connect/logout?client_id=${staticConfig.keycloakClientId}&post_logout_redirect_uri=${window.location.origin}${window.location.pathname}`,
|
|
336
|
+
className: "bg-primary h-[60px] w-full cursor-pointer text-center text-xl leading-[60px] font-semibold text-white disabled:cursor-not-allowed disabled:opacity-50",
|
|
337
|
+
children: "Login"
|
|
338
|
+
}
|
|
331
339
|
)
|
|
332
340
|
] });
|
|
333
341
|
};
|
|
@@ -1083,7 +1091,7 @@ function Label({ className, ...props }) {
|
|
|
1083
1091
|
}
|
|
1084
1092
|
|
|
1085
1093
|
// src/components/CreditCardTab/CreditCard/CreditCardForm.tsx
|
|
1086
|
-
import { Fragment, jsx as jsx12, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
1094
|
+
import { Fragment as Fragment2, jsx as jsx12, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
1087
1095
|
var style = {
|
|
1088
1096
|
base: {
|
|
1089
1097
|
fontSize: "16px",
|
|
@@ -1141,7 +1149,7 @@ var CreditCardForm = ({ cancel, saveCard }) => {
|
|
|
1141
1149
|
setCardError("An error occurred while processing your card. Please try again.");
|
|
1142
1150
|
}
|
|
1143
1151
|
};
|
|
1144
|
-
return /* @__PURE__ */ jsxs7(
|
|
1152
|
+
return /* @__PURE__ */ jsxs7(Fragment2, { children: [
|
|
1145
1153
|
/* @__PURE__ */ jsxs7("div", { className: "flex w-full flex-col gap-1", children: [
|
|
1146
1154
|
/* @__PURE__ */ jsx12(
|
|
1147
1155
|
CardNumberElement,
|
|
@@ -1189,7 +1197,7 @@ var CreditCardForm = ({ cancel, saveCard }) => {
|
|
|
1189
1197
|
};
|
|
1190
1198
|
|
|
1191
1199
|
// src/components/CreditCardTab/CreditCard/CreditCard.tsx
|
|
1192
|
-
import { Fragment as
|
|
1200
|
+
import { Fragment as Fragment3, jsx as jsx13, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
1193
1201
|
var StripeWrapper = (props) => {
|
|
1194
1202
|
const stripePromise = useMemo2(() => loadStripe(props.publicKey), [props.publicKey]);
|
|
1195
1203
|
return /* @__PURE__ */ jsx13(Elements, { stripe: stripePromise, children: /* @__PURE__ */ jsx13(CreditCardForm, { cancel: props.onCancel, saveCard: props.saveNewCard }) });
|
|
@@ -1212,7 +1220,7 @@ var CreditCard = () => {
|
|
|
1212
1220
|
};
|
|
1213
1221
|
return /* @__PURE__ */ jsxs8("div", { className: "flex flex-col items-baseline gap-4", children: [
|
|
1214
1222
|
/* @__PURE__ */ jsx13("h3", { className: "text-primary text-xl leading-[34px] font-semibold", children: "Your Credit Cards" }),
|
|
1215
|
-
!showForm && /* @__PURE__ */ jsxs8(
|
|
1223
|
+
!showForm && /* @__PURE__ */ jsxs8(Fragment3, { children: [
|
|
1216
1224
|
/* @__PURE__ */ jsx13(
|
|
1217
1225
|
CardsList,
|
|
1218
1226
|
{
|
|
@@ -2360,7 +2368,7 @@ var PointsSelector = (props) => {
|
|
|
2360
2368
|
readOnly: true,
|
|
2361
2369
|
name: "points amount",
|
|
2362
2370
|
value: Math.round(splitTokens),
|
|
2363
|
-
className: "sm:text-md min-w-[
|
|
2371
|
+
className: "sm:text-md min-w-[80px] bg-white px-1 text-center text-xs font-medium sm:px-3",
|
|
2364
2372
|
onClick: (e) => e.stopPropagation()
|
|
2365
2373
|
}
|
|
2366
2374
|
),
|
|
@@ -2385,7 +2393,7 @@ var PointsSelector = (props) => {
|
|
|
2385
2393
|
readOnly: true,
|
|
2386
2394
|
name: "usd amount",
|
|
2387
2395
|
value: formatUSD(usdAmount + getTransactionFee(usdAmount, appProps.transactionFeePercentage)),
|
|
2388
|
-
className: "sm:text-md min-w-[
|
|
2396
|
+
className: "sm:text-md min-w-[80px] bg-white px-1 text-center text-xs font-medium sm:px-3",
|
|
2389
2397
|
onClick: (e) => e.stopPropagation()
|
|
2390
2398
|
}
|
|
2391
2399
|
),
|
|
@@ -2446,7 +2454,7 @@ var SplitBlock = (props) => {
|
|
|
2446
2454
|
};
|
|
2447
2455
|
|
|
2448
2456
|
// src/components/CreditCardTab/Points/Points.tsx
|
|
2449
|
-
import { Fragment as
|
|
2457
|
+
import { Fragment as Fragment4, jsx as jsx26, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
2450
2458
|
var Points = () => {
|
|
2451
2459
|
const [usePoints, setUsePoints] = useState10(false);
|
|
2452
2460
|
const [selectedPointsType, setSelectedPointsType] = useState10(null);
|
|
@@ -2460,7 +2468,7 @@ var Points = () => {
|
|
|
2460
2468
|
setSelectedPaymentMethod({ ...selectedPaymentMethod, splitAmount: void 0 });
|
|
2461
2469
|
}
|
|
2462
2470
|
};
|
|
2463
|
-
return /* @__PURE__ */ jsxs14(
|
|
2471
|
+
return /* @__PURE__ */ jsxs14(Fragment4, { children: [
|
|
2464
2472
|
/* @__PURE__ */ jsx26(
|
|
2465
2473
|
PointsSwitch,
|
|
2466
2474
|
{
|
|
@@ -2718,11 +2726,11 @@ var useCryptoPayment = () => {
|
|
|
2718
2726
|
|
|
2719
2727
|
// src/components/CryptoTab/Crypto/ConnectButton.tsx
|
|
2720
2728
|
import { ConnectButton as RainbowButton } from "@rainbow-me/rainbowkit";
|
|
2721
|
-
import { Fragment as
|
|
2729
|
+
import { Fragment as Fragment5, jsx as jsx28, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
2722
2730
|
var ConnectButton = () => {
|
|
2723
2731
|
return /* @__PURE__ */ jsx28(RainbowButton.Custom, { children: ({ mounted, chain, account, openAccountModal, openChainModal, openConnectModal }) => {
|
|
2724
2732
|
if (!mounted) return null;
|
|
2725
|
-
return /* @__PURE__ */ jsx28(
|
|
2733
|
+
return /* @__PURE__ */ jsx28(Fragment5, { children: (() => {
|
|
2726
2734
|
if (!mounted || !account || !chain) {
|
|
2727
2735
|
return /* @__PURE__ */ jsx28(
|
|
2728
2736
|
"button",
|
|
@@ -3036,7 +3044,7 @@ var useBaseTokens = () => {
|
|
|
3036
3044
|
};
|
|
3037
3045
|
|
|
3038
3046
|
// src/modals/CryptoSelectModal.tsx
|
|
3039
|
-
import { Fragment as
|
|
3047
|
+
import { Fragment as Fragment6, jsx as jsx34, jsxs as jsxs19 } from "react/jsx-runtime";
|
|
3040
3048
|
var CryptoSelectModal = NiceModal4.create(() => {
|
|
3041
3049
|
const modal = useModal2();
|
|
3042
3050
|
const { isLoading, error, erc20Balances } = useBaseERC20Token();
|
|
@@ -3100,7 +3108,7 @@ var CryptoSelectModal = NiceModal4.create(() => {
|
|
|
3100
3108
|
},
|
|
3101
3109
|
nativeBalance.symbol
|
|
3102
3110
|
),
|
|
3103
|
-
isLoading && /* @__PURE__ */ jsxs19(
|
|
3111
|
+
isLoading && /* @__PURE__ */ jsxs19(Fragment6, { children: [
|
|
3104
3112
|
/* @__PURE__ */ jsx34("div", { className: "h-11 animate-pulse rounded-md bg-gray-100" }),
|
|
3105
3113
|
/* @__PURE__ */ jsx34("div", { className: "h-11 animate-pulse rounded-md bg-gray-100" }),
|
|
3106
3114
|
/* @__PURE__ */ jsx34("div", { className: "h-11 animate-pulse rounded-md bg-gray-100" })
|
|
@@ -3126,7 +3134,7 @@ var CryptoSelectModal = NiceModal4.create(() => {
|
|
|
3126
3134
|
] }),
|
|
3127
3135
|
/* @__PURE__ */ jsx34("h3", { className: "text-primary text-xl font-semibold", children: "All Tokens" }),
|
|
3128
3136
|
/* @__PURE__ */ jsxs19("div", { className: "flex max-h-[40vh] w-full flex-col gap-1 overflow-y-auto", children: [
|
|
3129
|
-
tokensIsLoading && /* @__PURE__ */ jsxs19(
|
|
3137
|
+
tokensIsLoading && /* @__PURE__ */ jsxs19(Fragment6, { children: [
|
|
3130
3138
|
/* @__PURE__ */ jsx34("div", { className: "h-11 animate-pulse rounded-md bg-gray-100" }),
|
|
3131
3139
|
/* @__PURE__ */ jsx34("div", { className: "h-11 animate-pulse rounded-md bg-gray-100" }),
|
|
3132
3140
|
/* @__PURE__ */ jsx34("div", { className: "h-11 animate-pulse rounded-md bg-gray-100" })
|
|
@@ -3459,15 +3467,16 @@ var SpreePayInner = () => {
|
|
|
3459
3467
|
ssoPageURI: env?.ssoPageURI,
|
|
3460
3468
|
enabled: !env?.accessToken
|
|
3461
3469
|
});
|
|
3470
|
+
const _accessToken = env.accessToken ?? accessToken;
|
|
3462
3471
|
const slapiFetcher = useMemo9(() => {
|
|
3463
|
-
if (
|
|
3472
|
+
if (_accessToken) {
|
|
3464
3473
|
return registerApi({
|
|
3465
|
-
accessToken:
|
|
3474
|
+
accessToken: _accessToken,
|
|
3466
3475
|
tenantId,
|
|
3467
3476
|
baseUrl: staticConfig.slapiUrl
|
|
3468
3477
|
});
|
|
3469
3478
|
}
|
|
3470
|
-
}, [
|
|
3479
|
+
}, [_accessToken, staticConfig, tenantId]);
|
|
3471
3480
|
const getContent = () => {
|
|
3472
3481
|
if (isChecking) {
|
|
3473
3482
|
return /* @__PURE__ */ jsxs27("div", { className: "flex w-full flex-col", children: [
|
|
@@ -3485,7 +3494,7 @@ var SpreePayInner = () => {
|
|
|
3485
3494
|
revalidateOnFocus: false,
|
|
3486
3495
|
revalidateIfStale: false
|
|
3487
3496
|
},
|
|
3488
|
-
children: /* @__PURE__ */ jsx43(PortalContainerProvider, { container: portalEl, children: /* @__PURE__ */ jsx43(NiceModal7.Provider, { children: /* @__PURE__ */ jsx43(SpreePayContent, { isLoggedIn: Boolean(
|
|
3497
|
+
children: /* @__PURE__ */ jsx43(PortalContainerProvider, { container: portalEl, children: /* @__PURE__ */ jsx43(NiceModal7.Provider, { children: /* @__PURE__ */ jsx43(SpreePayContent, { isLoggedIn: Boolean(_accessToken) }) }) })
|
|
3489
3498
|
}
|
|
3490
3499
|
);
|
|
3491
3500
|
};
|