@flopay/react 0.3.19 → 0.3.20

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
@@ -645,7 +645,7 @@ function PayPalButtonInner({
645
645
  event.reject();
646
646
  return;
647
647
  }
648
- const beforeClick = runBeforeButtonClick ? await runBeforeButtonClick("paypal", { deferInlineSessionPatch: true }) : { proceed: true };
648
+ const beforeClick = runBeforeButtonClick ? await runBeforeButtonClick("paypal") : { proceed: true };
649
649
  if (!beforeClick.proceed) {
650
650
  beforeClickRef.current = null;
651
651
  event.reject();
@@ -653,7 +653,7 @@ function PayPalButtonInner({
653
653
  }
654
654
  beforeClickRef.current = {
655
655
  accountPatch: beforeClick.accountPatch,
656
- pendingInlinePatch: beforeClick.pendingInlinePatch
656
+ sessionId: beforeClick.sessionId
657
657
  };
658
658
  event.resolve();
659
659
  }, [isProcessing, runBeforeButtonClick, submitting]);
@@ -669,15 +669,10 @@ function PayPalButtonInner({
669
669
  }
670
670
  prepared = {
671
671
  accountPatch: beforeClick.accountPatch,
672
- pendingInlinePatch: beforeClick.pendingInlinePatch ?? Promise.resolve({ error: null, sessionId: beforeClick.sessionId ?? sessionId })
672
+ sessionId: beforeClick.sessionId
673
673
  };
674
674
  }
675
- const patchResult = prepared?.pendingInlinePatch ? await prepared.pendingInlinePatch : { error: null, sessionId };
676
- if (patchResult.error) {
677
- event.paymentFailed({ reason: "fail", message: patchResult.error.message });
678
- return;
679
- }
680
- const effectiveSessionId = patchResult.sessionId ?? sessionId;
675
+ const effectiveSessionId = prepared?.sessionId ?? sessionId;
681
676
  const effectiveEmail = prepared?.accountPatch?.email ?? email;
682
677
  onButtonClick?.("paypal");
683
678
  try {
@@ -801,16 +796,11 @@ function WalletButtonInner({
801
796
  }
802
797
  prepared = {
803
798
  accountPatch: beforeClick.accountPatch,
804
- pendingInlinePatch: beforeClick.pendingInlinePatch ?? Promise.resolve({ error: null, sessionId: beforeClick.sessionId ?? sessionId })
799
+ sessionId: beforeClick.sessionId
805
800
  };
806
801
  }
807
- const patchResult = prepared?.pendingInlinePatch ? await prepared.pendingInlinePatch : { error: null, sessionId };
808
- if (patchResult.error) {
809
- event.paymentFailed({ reason: "fail", message: patchResult.error.message });
810
- return;
811
- }
812
802
  const method = walletType === "apple_pay" ? "apple_pay" : "google_pay";
813
- const effectiveSessionId = patchResult.sessionId ?? sessionId;
803
+ const effectiveSessionId = prepared?.sessionId ?? sessionId;
814
804
  const effectiveEmail = prepared?.accountPatch?.email ?? email;
815
805
  onButtonClick?.(walletType === "apple_pay" ? "apple_pay" : "google_pay");
816
806
  try {
@@ -879,7 +869,7 @@ function WalletButtonInner({
879
869
  onLoadError: () => setLoadState("unavailable"),
880
870
  onClick: async (event) => {
881
871
  lastWalletMethodRef.current = event.expressPaymentType === "apple_pay" ? "apple_pay" : "google_pay";
882
- const beforeClick = runBeforeButtonClick ? await runBeforeButtonClick(lastWalletMethodRef.current, { deferInlineSessionPatch: true }) : { proceed: true };
872
+ const beforeClick = runBeforeButtonClick ? await runBeforeButtonClick(lastWalletMethodRef.current) : { proceed: true };
883
873
  if (!beforeClick.proceed) {
884
874
  beforeClickRef.current = null;
885
875
  event.reject();
@@ -887,7 +877,7 @@ function WalletButtonInner({
887
877
  }
888
878
  beforeClickRef.current = {
889
879
  accountPatch: beforeClick.accountPatch,
890
- pendingInlinePatch: beforeClick.pendingInlinePatch
880
+ sessionId: beforeClick.sessionId
891
881
  };
892
882
  event.resolve();
893
883
  },
@@ -1072,7 +1062,7 @@ function SplitCardFormInner({
1072
1062
  },
1073
1063
  [checkout.applyInlineSessionPatch, onError, sessionId, updateError]
1074
1064
  );
1075
- const runBeforeButtonClick = (0, import_react6.useCallback)(async (method, options) => {
1065
+ const runBeforeButtonClick = (0, import_react6.useCallback)(async (method) => {
1076
1066
  if (!onBeforeButtonClick) return { proceed: true };
1077
1067
  try {
1078
1068
  const result = await onBeforeButtonClick({
@@ -1087,15 +1077,7 @@ function SplitCardFormInner({
1087
1077
  if (result.account) {
1088
1078
  setAccountPatch((prev) => ({ ...prev ?? {}, ...result.account }));
1089
1079
  }
1090
- const pendingInlinePatch = applyInlineSessionPatch(result, method);
1091
- if (options?.deferInlineSessionPatch) {
1092
- return {
1093
- proceed: true,
1094
- accountPatch: result.account,
1095
- pendingInlinePatch
1096
- };
1097
- }
1098
- const patchResult = await pendingInlinePatch;
1080
+ const patchResult = await applyInlineSessionPatch(result, method);
1099
1081
  if (patchResult.error) {
1100
1082
  return {
1101
1083
  proceed: false,