@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.mjs CHANGED
@@ -601,7 +601,7 @@ function PayPalButtonInner({
601
601
  event.reject();
602
602
  return;
603
603
  }
604
- const beforeClick = runBeforeButtonClick ? await runBeforeButtonClick("paypal", { deferInlineSessionPatch: true }) : { proceed: true };
604
+ const beforeClick = runBeforeButtonClick ? await runBeforeButtonClick("paypal") : { proceed: true };
605
605
  if (!beforeClick.proceed) {
606
606
  beforeClickRef.current = null;
607
607
  event.reject();
@@ -609,7 +609,7 @@ function PayPalButtonInner({
609
609
  }
610
610
  beforeClickRef.current = {
611
611
  accountPatch: beforeClick.accountPatch,
612
- pendingInlinePatch: beforeClick.pendingInlinePatch
612
+ sessionId: beforeClick.sessionId
613
613
  };
614
614
  event.resolve();
615
615
  }, [isProcessing, runBeforeButtonClick, submitting]);
@@ -625,15 +625,10 @@ function PayPalButtonInner({
625
625
  }
626
626
  prepared = {
627
627
  accountPatch: beforeClick.accountPatch,
628
- pendingInlinePatch: beforeClick.pendingInlinePatch ?? Promise.resolve({ error: null, sessionId: beforeClick.sessionId ?? sessionId })
628
+ sessionId: beforeClick.sessionId
629
629
  };
630
630
  }
631
- const patchResult = prepared?.pendingInlinePatch ? await prepared.pendingInlinePatch : { error: null, sessionId };
632
- if (patchResult.error) {
633
- event.paymentFailed({ reason: "fail", message: patchResult.error.message });
634
- return;
635
- }
636
- const effectiveSessionId = patchResult.sessionId ?? sessionId;
631
+ const effectiveSessionId = prepared?.sessionId ?? sessionId;
637
632
  const effectiveEmail = prepared?.accountPatch?.email ?? email;
638
633
  onButtonClick?.("paypal");
639
634
  try {
@@ -757,16 +752,11 @@ function WalletButtonInner({
757
752
  }
758
753
  prepared = {
759
754
  accountPatch: beforeClick.accountPatch,
760
- pendingInlinePatch: beforeClick.pendingInlinePatch ?? Promise.resolve({ error: null, sessionId: beforeClick.sessionId ?? sessionId })
755
+ sessionId: beforeClick.sessionId
761
756
  };
762
757
  }
763
- const patchResult = prepared?.pendingInlinePatch ? await prepared.pendingInlinePatch : { error: null, sessionId };
764
- if (patchResult.error) {
765
- event.paymentFailed({ reason: "fail", message: patchResult.error.message });
766
- return;
767
- }
768
758
  const method = walletType === "apple_pay" ? "apple_pay" : "google_pay";
769
- const effectiveSessionId = patchResult.sessionId ?? sessionId;
759
+ const effectiveSessionId = prepared?.sessionId ?? sessionId;
770
760
  const effectiveEmail = prepared?.accountPatch?.email ?? email;
771
761
  onButtonClick?.(walletType === "apple_pay" ? "apple_pay" : "google_pay");
772
762
  try {
@@ -835,7 +825,7 @@ function WalletButtonInner({
835
825
  onLoadError: () => setLoadState("unavailable"),
836
826
  onClick: async (event) => {
837
827
  lastWalletMethodRef.current = event.expressPaymentType === "apple_pay" ? "apple_pay" : "google_pay";
838
- const beforeClick = runBeforeButtonClick ? await runBeforeButtonClick(lastWalletMethodRef.current, { deferInlineSessionPatch: true }) : { proceed: true };
828
+ const beforeClick = runBeforeButtonClick ? await runBeforeButtonClick(lastWalletMethodRef.current) : { proceed: true };
839
829
  if (!beforeClick.proceed) {
840
830
  beforeClickRef.current = null;
841
831
  event.reject();
@@ -843,7 +833,7 @@ function WalletButtonInner({
843
833
  }
844
834
  beforeClickRef.current = {
845
835
  accountPatch: beforeClick.accountPatch,
846
- pendingInlinePatch: beforeClick.pendingInlinePatch
836
+ sessionId: beforeClick.sessionId
847
837
  };
848
838
  event.resolve();
849
839
  },
@@ -1028,7 +1018,7 @@ function SplitCardFormInner({
1028
1018
  },
1029
1019
  [checkout.applyInlineSessionPatch, onError, sessionId, updateError]
1030
1020
  );
1031
- const runBeforeButtonClick = useCallback(async (method, options) => {
1021
+ const runBeforeButtonClick = useCallback(async (method) => {
1032
1022
  if (!onBeforeButtonClick) return { proceed: true };
1033
1023
  try {
1034
1024
  const result = await onBeforeButtonClick({
@@ -1043,15 +1033,7 @@ function SplitCardFormInner({
1043
1033
  if (result.account) {
1044
1034
  setAccountPatch((prev) => ({ ...prev ?? {}, ...result.account }));
1045
1035
  }
1046
- const pendingInlinePatch = applyInlineSessionPatch(result, method);
1047
- if (options?.deferInlineSessionPatch) {
1048
- return {
1049
- proceed: true,
1050
- accountPatch: result.account,
1051
- pendingInlinePatch
1052
- };
1053
- }
1054
- const patchResult = await pendingInlinePatch;
1036
+ const patchResult = await applyInlineSessionPatch(result, method);
1055
1037
  if (patchResult.error) {
1056
1038
  return {
1057
1039
  proceed: false,