@flopay/react 0.5.19 → 1.0.2

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 CHANGED
@@ -498,7 +498,7 @@ function buildSyntheticSession(params, checkoutModeOverride) {
498
498
  ...(params.items ?? []).map((item) => item.overrideAmount ?? item.totalAmount ?? 0),
499
499
  ...(params.subscriptions ?? []).map((subscription) => subscription.overrideAmount ?? subscription.totalAmount ?? 0)
500
500
  ].reduce((sum, value) => sum + value, 0);
501
- const currency = params.items?.[0]?.currency ?? params.subscriptions?.[0]?.currency ?? "USD";
501
+ const currency = params.currency ?? params.items?.find((i) => i.currency)?.currency ?? params.subscriptions?.find((s) => s.currency)?.currency ?? "USD";
502
502
  return {
503
503
  id: "",
504
504
  clientSecret: "",
@@ -520,26 +520,40 @@ function buildSyntheticSession(params, checkoutModeOverride) {
520
520
  successUrl: params.successUrl,
521
521
  cancelUrl: params.cancelUrl,
522
522
  checkoutMode: checkoutModeOverride ?? params.checkoutMode ?? "full",
523
- items: (params.items ?? []).map((item, idx) => ({
524
- uuid: `synthetic-item-${idx}`,
525
- checkoutSessionId: "",
526
- providerItemId: item.providerItemId,
527
- providerItemName: item.providerItemName ?? item.providerItemId,
528
- quantity: item.quantity ?? 1,
529
- totalAmount: item.totalAmount,
530
- overrideAmount: item.overrideAmount ?? null,
531
- currency: item.currency ?? currency
532
- })),
533
- subscriptions: (params.subscriptions ?? []).map((subscription, idx) => ({
534
- uuid: `synthetic-sub-${idx}`,
535
- checkoutSessionId: "",
536
- providerPlanId: subscription.providerPlanId,
537
- providerPlanName: subscription.providerPlanName ?? subscription.providerPlanId,
538
- quantity: subscription.quantity ?? 1,
539
- totalAmount: subscription.totalAmount,
540
- overrideAmount: subscription.overrideAmount ?? null,
541
- currency: subscription.currency ?? currency
542
- }))
523
+ items: (params.items ?? []).map((item, idx) => {
524
+ const code = item.code ?? item.providerItemId;
525
+ const itemName = item.itemName ?? item.providerItemName ?? code;
526
+ return {
527
+ uuid: `synthetic-item-${idx}`,
528
+ checkoutSessionId: "",
529
+ code,
530
+ providerItemId: code,
531
+ itemName,
532
+ providerItemName: itemName,
533
+ quantity: item.quantity ?? 1,
534
+ totalAmount: item.totalAmount,
535
+ overrideAmount: item.overrideAmount ?? null,
536
+ currency: item.currency ?? currency,
537
+ metadata: item.metadata ?? null
538
+ };
539
+ }),
540
+ subscriptions: (params.subscriptions ?? []).map((subscription, idx) => {
541
+ const code = subscription.code ?? subscription.providerPlanId;
542
+ const subscriptionName = subscription.subscriptionName ?? subscription.providerPlanName ?? code;
543
+ return {
544
+ uuid: `synthetic-sub-${idx}`,
545
+ checkoutSessionId: "",
546
+ code,
547
+ providerPlanId: code,
548
+ subscriptionName,
549
+ providerPlanName: subscriptionName,
550
+ quantity: subscription.quantity ?? 1,
551
+ totalAmount: subscription.totalAmount,
552
+ overrideAmount: subscription.overrideAmount ?? null,
553
+ currency: subscription.currency ?? currency,
554
+ metadata: subscription.metadata ?? null
555
+ };
556
+ })
543
557
  };
544
558
  }
545
559
  function mergeAccountPatch(base, patch) {
@@ -3268,14 +3282,15 @@ function FloPayCheckout({
3268
3282
  function hashCreateParams(params) {
3269
3283
  const key = JSON.stringify({
3270
3284
  c: params?.clientId,
3285
+ cur: params?.currency ?? "",
3271
3286
  a: {
3272
3287
  e: params?.account?.email?.trim().toLowerCase() ?? "",
3273
3288
  country: params?.account?.country ?? ""
3274
3289
  },
3275
3290
  successUrl: params?.successUrl,
3276
3291
  cancelUrl: params?.cancelUrl,
3277
- i: params?.items?.map((x) => `${x.providerItemId}:${x.totalAmount}:${x.overrideAmount ?? ""}:${x.quantity ?? 1}`).sort(),
3278
- s: params?.subscriptions?.map((x) => `${x.providerPlanId}:${x.totalAmount}:${x.overrideAmount ?? ""}:${x.quantity ?? 1}`).sort(),
3292
+ i: params?.items?.map((x) => `${x.code ?? x.providerItemId ?? ""}:${x.totalAmount ?? ""}:${x.overrideAmount ?? ""}:${x.quantity ?? 1}`).sort(),
3293
+ s: params?.subscriptions?.map((x) => `${x.code ?? x.providerPlanId ?? ""}:${x.totalAmount ?? ""}:${x.overrideAmount ?? ""}:${x.quantity ?? 1}`).sort(),
3279
3294
  couponCodes: params?.couponCodes,
3280
3295
  tagsData: params?.tagsData,
3281
3296
  utmMetadata: params?.utmMetadata,