@akinon/pz-flow-payment 1.96.0-rc.61 → 1.96.0-snapshot-ZERO-3620-20250915165755

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/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # @akinon/pz-flow-payment
2
2
 
3
+ ## 1.96.0-snapshot-ZERO-3620-20250915165755
4
+
5
+ ### Minor Changes
6
+
7
+ - 69e4cc5: BRDG-14604: Refactor FlowPayment component to optimize flow initialization and cleanup logic
8
+ - d8be48fb: ZERO-3422: Update fetch method to use dynamic request method in wallet complete redirection middleware
9
+ - 8b1d24eb: ZERO-3422: Update fetch method to use dynamic request method in wallet complete redirection middleware
10
+
3
11
  ## 1.96.0-rc.61
4
12
 
5
13
  ### Minor Changes
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@akinon/pz-flow-payment",
3
3
  "license": "MIT",
4
- "version": "1.96.0-rc.61",
4
+ "version": "1.96.0-snapshot-ZERO-3620-20250915165755",
5
5
  "main": "src/index.tsx",
6
6
  "dependencies": {
7
7
  "@checkout.com/checkout-web-components": "0.7.0-beta"
@@ -59,6 +59,7 @@ export default function FlowPayment({
59
59
  const flowComponentRef = useRef<any>(null);
60
60
  const lastAmountRef = useRef<string | null>(null);
61
61
  const isInitializingRef = useRef<boolean>(false);
62
+ const walletPaymentInitialized = useRef<boolean>(false);
62
63
 
63
64
  // Memoize the amount to track actual changes
64
65
  const currentAmount = useMemo(() => {
@@ -81,7 +82,11 @@ export default function FlowPayment({
81
82
  return;
82
83
  }
83
84
 
84
- dispatch(checkoutApi.endpoints.setWalletPaymentPage.initiate({}));
85
+ // FIX: Only call setWalletPaymentPage if not already initialized
86
+ if (!walletPaymentInitialized.current) {
87
+ walletPaymentInitialized.current = true;
88
+ dispatch(checkoutApi.endpoints.setWalletPaymentPage.initiate({}));
89
+ }
85
90
  };
86
91
 
87
92
  const initFlowPaymentWebComponents = async ({
@@ -118,16 +123,24 @@ export default function FlowPayment({
118
123
  container.innerHTML = '';
119
124
  }
120
125
 
121
- // Only get fresh payment data when amount has changed from the last recorded amount
126
+ // FIX: Use existing payment session instead of making another API call
122
127
  let paymentSession = preOrder.context_extras;
123
128
 
124
- if (lastAmountRef.current !== currentAmount || !paymentSession) {
125
- const walletPaymentResponse = await dispatch(
126
- checkoutApi.endpoints.setWalletPaymentPage.initiate({})
127
- ).unwrap();
128
- paymentSession =
129
- walletPaymentResponse?.pre_order?.context_extras ||
130
- preOrder.context_extras;
129
+ // Only get fresh payment data if we don't have a valid session
130
+ if (!paymentSession && lastAmountRef.current !== currentAmount) {
131
+ // Check if another call is already in progress
132
+ if (!walletPaymentInitialized.current) {
133
+ walletPaymentInitialized.current = true;
134
+ const walletPaymentResponse = await dispatch(
135
+ checkoutApi.endpoints.setWalletPaymentPage.initiate({})
136
+ ).unwrap();
137
+ paymentSession =
138
+ walletPaymentResponse?.pre_order?.context_extras ||
139
+ preOrder.context_extras;
140
+ } else {
141
+ // Use existing context_extras if another call was already made
142
+ paymentSession = preOrder.context_extras;
143
+ }
131
144
  }
132
145
 
133
146
  // Update the last amount reference after getting fresh data
@@ -192,6 +205,8 @@ export default function FlowPayment({
192
205
  console.warn('Error destroying flow component on unmount:', error);
193
206
  }
194
207
  }
208
+ // Reset initialization flag on unmount
209
+ walletPaymentInitialized.current = false;
195
210
  };
196
211
  }, []);
197
212