@flopay/react 1.0.0 → 1.0.3
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/index.cjs +38 -23
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +38 -23
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
package/dist/index.mjs
CHANGED
|
@@ -461,7 +461,7 @@ function buildSyntheticSession(params, checkoutModeOverride) {
|
|
|
461
461
|
...(params.items ?? []).map((item) => item.overrideAmount ?? item.totalAmount ?? 0),
|
|
462
462
|
...(params.subscriptions ?? []).map((subscription) => subscription.overrideAmount ?? subscription.totalAmount ?? 0)
|
|
463
463
|
].reduce((sum, value) => sum + value, 0);
|
|
464
|
-
const currency = params.items?.
|
|
464
|
+
const currency = params.currency ?? params.items?.find((i) => i.currency)?.currency ?? params.subscriptions?.find((s) => s.currency)?.currency ?? "USD";
|
|
465
465
|
return {
|
|
466
466
|
id: "",
|
|
467
467
|
clientSecret: "",
|
|
@@ -483,26 +483,40 @@ function buildSyntheticSession(params, checkoutModeOverride) {
|
|
|
483
483
|
successUrl: params.successUrl,
|
|
484
484
|
cancelUrl: params.cancelUrl,
|
|
485
485
|
checkoutMode: checkoutModeOverride ?? params.checkoutMode ?? "full",
|
|
486
|
-
items: (params.items ?? []).map((item, idx) =>
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
486
|
+
items: (params.items ?? []).map((item, idx) => {
|
|
487
|
+
const code = item.code ?? item.providerItemId;
|
|
488
|
+
const itemName = item.itemName ?? item.providerItemName ?? code;
|
|
489
|
+
return {
|
|
490
|
+
uuid: `synthetic-item-${idx}`,
|
|
491
|
+
checkoutSessionId: "",
|
|
492
|
+
code,
|
|
493
|
+
providerItemId: code,
|
|
494
|
+
itemName,
|
|
495
|
+
providerItemName: itemName,
|
|
496
|
+
quantity: item.quantity ?? 1,
|
|
497
|
+
totalAmount: item.totalAmount,
|
|
498
|
+
overrideAmount: item.overrideAmount ?? null,
|
|
499
|
+
currency: item.currency ?? currency,
|
|
500
|
+
metadata: item.metadata ?? null
|
|
501
|
+
};
|
|
502
|
+
}),
|
|
503
|
+
subscriptions: (params.subscriptions ?? []).map((subscription, idx) => {
|
|
504
|
+
const code = subscription.code ?? subscription.providerPlanId;
|
|
505
|
+
const subscriptionName = subscription.subscriptionName ?? subscription.providerPlanName ?? code;
|
|
506
|
+
return {
|
|
507
|
+
uuid: `synthetic-sub-${idx}`,
|
|
508
|
+
checkoutSessionId: "",
|
|
509
|
+
code,
|
|
510
|
+
providerPlanId: code,
|
|
511
|
+
subscriptionName,
|
|
512
|
+
providerPlanName: subscriptionName,
|
|
513
|
+
quantity: subscription.quantity ?? 1,
|
|
514
|
+
totalAmount: subscription.totalAmount,
|
|
515
|
+
overrideAmount: subscription.overrideAmount ?? null,
|
|
516
|
+
currency: subscription.currency ?? currency,
|
|
517
|
+
metadata: subscription.metadata ?? null
|
|
518
|
+
};
|
|
519
|
+
})
|
|
506
520
|
};
|
|
507
521
|
}
|
|
508
522
|
function mergeAccountPatch(base, patch) {
|
|
@@ -3231,14 +3245,15 @@ function FloPayCheckout({
|
|
|
3231
3245
|
function hashCreateParams(params) {
|
|
3232
3246
|
const key = JSON.stringify({
|
|
3233
3247
|
c: params?.clientId,
|
|
3248
|
+
cur: params?.currency ?? "",
|
|
3234
3249
|
a: {
|
|
3235
3250
|
e: params?.account?.email?.trim().toLowerCase() ?? "",
|
|
3236
3251
|
country: params?.account?.country ?? ""
|
|
3237
3252
|
},
|
|
3238
3253
|
successUrl: params?.successUrl,
|
|
3239
3254
|
cancelUrl: params?.cancelUrl,
|
|
3240
|
-
i: params?.items?.map((x) => `${x.providerItemId}:${x.totalAmount}:${x.overrideAmount ?? ""}:${x.quantity ?? 1}`).sort(),
|
|
3241
|
-
s: params?.subscriptions?.map((x) => `${x.providerPlanId}:${x.totalAmount}:${x.overrideAmount ?? ""}:${x.quantity ?? 1}`).sort(),
|
|
3255
|
+
i: params?.items?.map((x) => `${x.code ?? x.providerItemId ?? ""}:${x.totalAmount ?? ""}:${x.overrideAmount ?? ""}:${x.quantity ?? 1}`).sort(),
|
|
3256
|
+
s: params?.subscriptions?.map((x) => `${x.code ?? x.providerPlanId ?? ""}:${x.totalAmount ?? ""}:${x.overrideAmount ?? ""}:${x.quantity ?? 1}`).sort(),
|
|
3242
3257
|
couponCodes: params?.couponCodes,
|
|
3243
3258
|
tagsData: params?.tagsData,
|
|
3244
3259
|
utmMetadata: params?.utmMetadata,
|