@akinon/pz-flow-payment 1.108.0-rc.1 → 1.108.0-rc.10
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 +38 -0
- package/package.json +1 -1
- package/src/views/index.tsx +48 -31
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,43 @@
|
|
|
1
1
|
# @akinon/pz-flow-payment
|
|
2
2
|
|
|
3
|
+
## 1.108.0-rc.10
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 59ed7a7e: ZERO-3640: Add order number state and update FlowPayment component for wallet payment response handling
|
|
8
|
+
|
|
9
|
+
## 1.108.0-rc.9
|
|
10
|
+
|
|
11
|
+
## 1.108.0-rc.8
|
|
12
|
+
|
|
13
|
+
### Minor Changes
|
|
14
|
+
|
|
15
|
+
- f85464e9: ZERO-3640: Fix API call to use hyphenated key for payment ID in FlowPayment component
|
|
16
|
+
|
|
17
|
+
## 1.108.0-rc.7
|
|
18
|
+
|
|
19
|
+
## 1.108.0-rc.6
|
|
20
|
+
|
|
21
|
+
## 1.108.0-rc.5
|
|
22
|
+
|
|
23
|
+
### Minor Changes
|
|
24
|
+
|
|
25
|
+
- 31a2d35: ZERO-3640: Refactor checkout API call to include useFormData option; update FlowPayment component for improved error handling and code readability
|
|
26
|
+
|
|
27
|
+
## 1.108.0-rc.4
|
|
28
|
+
|
|
29
|
+
### Minor Changes
|
|
30
|
+
|
|
31
|
+
- d8883ce: ZERO-3640: Refactor wallet completion handling to accept additional parameters; update related API calls
|
|
32
|
+
|
|
33
|
+
## 1.108.0-rc.3
|
|
34
|
+
|
|
35
|
+
### Minor Changes
|
|
36
|
+
|
|
37
|
+
- e00b4a8: ZERO-3640: Refactor wallet selection initialization and error handling; streamline payment session management
|
|
38
|
+
|
|
39
|
+
## 1.108.0-rc.2
|
|
40
|
+
|
|
3
41
|
## 1.108.0-rc.1
|
|
4
42
|
|
|
5
43
|
### Minor Changes
|
package/package.json
CHANGED
package/src/views/index.tsx
CHANGED
|
@@ -77,8 +77,10 @@ export default function FlowPayment({
|
|
|
77
77
|
const flowComponentRef = useRef<any>(null);
|
|
78
78
|
const lastAmountRef = useRef<string | null>(null);
|
|
79
79
|
const isInitializingRef = useRef<boolean>(false);
|
|
80
|
-
const walletPaymentInitialized = useRef<boolean>(false);
|
|
81
80
|
const [errors, setErrors] = useState<any>(null);
|
|
81
|
+
const [walletSelectionReady, setWalletSelectionReady] =
|
|
82
|
+
useState<boolean>(false);
|
|
83
|
+
const [orderNumber, setOrderNumber] = useState<string | null>(null);
|
|
82
84
|
|
|
83
85
|
// Memoize the amount to track actual changes
|
|
84
86
|
const currentAmount = useMemo(() => {
|
|
@@ -98,22 +100,48 @@ export default function FlowPayment({
|
|
|
98
100
|
);
|
|
99
101
|
|
|
100
102
|
if (!walletPaymentPageContext) {
|
|
103
|
+
setErrors(
|
|
104
|
+
'Payment method not available. Please try a different payment option.'
|
|
105
|
+
);
|
|
106
|
+
setWalletSelectionReady(false);
|
|
101
107
|
return;
|
|
102
108
|
}
|
|
103
109
|
|
|
104
|
-
//
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
110
|
+
// Initialize wallet payment page to get payment session data
|
|
111
|
+
const walletPaymentPageResponse = await dispatch(
|
|
112
|
+
checkoutApi.endpoints.setWalletPaymentPage.initiate({
|
|
113
|
+
payment_method: 'checkout_flow',
|
|
114
|
+
wallet_method: preOrder.wallet_method
|
|
115
|
+
})
|
|
116
|
+
).unwrap();
|
|
117
|
+
|
|
118
|
+
if (walletPaymentPageResponse.errors) {
|
|
119
|
+
setErrors(walletPaymentPageResponse.errors);
|
|
120
|
+
setWalletSelectionReady(false);
|
|
121
|
+
return;
|
|
108
122
|
}
|
|
123
|
+
|
|
124
|
+
// Store the order number from the wallet payment page response
|
|
125
|
+
if (walletPaymentPageResponse.pre_order?.number) {
|
|
126
|
+
setOrderNumber(walletPaymentPageResponse.pre_order.number);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
setWalletSelectionReady(true);
|
|
109
130
|
};
|
|
110
131
|
|
|
111
132
|
const handlePaymentSuccess = async (paymentData: any) => {
|
|
112
133
|
setErrors(null);
|
|
113
134
|
|
|
114
135
|
try {
|
|
136
|
+
const ckoPaymentId = paymentData?.id;
|
|
137
|
+
const isSuccess = paymentData?.status === 'Approved';
|
|
138
|
+
|
|
115
139
|
const paymentCompleteResponse = await dispatch(
|
|
116
|
-
checkoutApi.endpoints.setWalletCompletePage.initiate(
|
|
140
|
+
checkoutApi.endpoints.setWalletCompletePage.initiate({
|
|
141
|
+
success: isSuccess,
|
|
142
|
+
'cko-payment-id': ckoPaymentId,
|
|
143
|
+
oid: orderNumber
|
|
144
|
+
})
|
|
117
145
|
).unwrap();
|
|
118
146
|
|
|
119
147
|
if (paymentCompleteResponse.errors) {
|
|
@@ -132,10 +160,7 @@ export default function FlowPayment({
|
|
|
132
160
|
|
|
133
161
|
const redirectUrlWithLocale = `${
|
|
134
162
|
window.location.origin
|
|
135
|
-
}${getUrlPathWithLocale(
|
|
136
|
-
redirectUrl,
|
|
137
|
-
getCookie('pz-locale') || 'en'
|
|
138
|
-
)}`;
|
|
163
|
+
}${getUrlPathWithLocale(redirectUrl, getCookie('pz-locale') || 'en')}`;
|
|
139
164
|
|
|
140
165
|
window.location.href = redirectUrlWithLocale;
|
|
141
166
|
}
|
|
@@ -184,24 +209,15 @@ export default function FlowPayment({
|
|
|
184
209
|
container.innerHTML = '';
|
|
185
210
|
}
|
|
186
211
|
|
|
187
|
-
// FIX: Use existing payment session
|
|
212
|
+
// FIX: Use existing payment session from preOrder.context_extras
|
|
188
213
|
let paymentSession = preOrder.context_extras;
|
|
189
214
|
|
|
190
|
-
//
|
|
191
|
-
if (!paymentSession
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
checkoutApi.endpoints.setWalletPaymentPage.initiate({})
|
|
197
|
-
).unwrap();
|
|
198
|
-
paymentSession =
|
|
199
|
-
walletPaymentResponse?.pre_order?.context_extras ||
|
|
200
|
-
preOrder.context_extras;
|
|
201
|
-
} else {
|
|
202
|
-
// Use existing context_extras if another call was already made
|
|
203
|
-
paymentSession = preOrder.context_extras;
|
|
204
|
-
}
|
|
215
|
+
// If we don't have payment session data, we need to wait for it
|
|
216
|
+
if (!paymentSession) {
|
|
217
|
+
console.warn(
|
|
218
|
+
'FlowPayment: Payment session not available yet, component will retry when data is ready'
|
|
219
|
+
);
|
|
220
|
+
return;
|
|
205
221
|
}
|
|
206
222
|
|
|
207
223
|
// Update the last amount reference after getting fresh data
|
|
@@ -246,9 +262,10 @@ export default function FlowPayment({
|
|
|
246
262
|
useEffect(() => {
|
|
247
263
|
if (
|
|
248
264
|
!preOrder.wallet_method ||
|
|
249
|
-
!preOrder.token ||
|
|
250
265
|
!walletPaymentData?.data?.public_key ||
|
|
251
|
-
preOrder.wallet_method !== 'checkout_flow'
|
|
266
|
+
preOrder.wallet_method !== 'checkout_flow' ||
|
|
267
|
+
!walletSelectionReady ||
|
|
268
|
+
!preOrder.context_extras
|
|
252
269
|
) {
|
|
253
270
|
return;
|
|
254
271
|
}
|
|
@@ -260,7 +277,9 @@ export default function FlowPayment({
|
|
|
260
277
|
preOrder.wallet_method,
|
|
261
278
|
preOrder.token,
|
|
262
279
|
currentAmount, // Use memoized amount instead of preOrder.total_amount
|
|
263
|
-
walletPaymentData?.data?.public_key
|
|
280
|
+
walletPaymentData?.data?.public_key,
|
|
281
|
+
walletSelectionReady,
|
|
282
|
+
preOrder.context_extras // Add payment session dependency
|
|
264
283
|
]);
|
|
265
284
|
|
|
266
285
|
// Cleanup function when component unmounts
|
|
@@ -273,8 +292,6 @@ export default function FlowPayment({
|
|
|
273
292
|
console.warn('Error destroying flow component on unmount:', error);
|
|
274
293
|
}
|
|
275
294
|
}
|
|
276
|
-
// Reset initialization flag on unmount
|
|
277
|
-
walletPaymentInitialized.current = false;
|
|
278
295
|
};
|
|
279
296
|
}, []);
|
|
280
297
|
|