@akinon/pz-flow-payment 1.99.0-snapshot-ZERO-3640-20250919140935 → 1.99.0

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,10 +1,10 @@
1
1
  # @akinon/pz-flow-payment
2
2
 
3
- ## 1.99.0-snapshot-ZERO-3640-20250919140935
3
+ ## 1.99.0
4
4
 
5
5
  ### Minor Changes
6
6
 
7
- - ce2e9e2: ZERO-3640: Add error handling and WalletCompletePage request to FlowPayment
7
+ - d58538b: ZERO-3638: Enhance RC pipeline: add fetch, merge, and pre-release setup with conditional commit
8
8
 
9
9
  ## 1.98.0
10
10
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@akinon/pz-flow-payment",
3
3
  "license": "MIT",
4
- "version": "1.99.0-snapshot-ZERO-3640-20250919140935",
4
+ "version": "1.99.0",
5
5
  "main": "src/index.tsx",
6
6
  "dependencies": {
7
7
  "@checkout.com/checkout-web-components": "0.7.0-beta"
@@ -1,7 +1,5 @@
1
1
  import { checkoutApi } from '@akinon/next/data/client/checkout';
2
2
  import { useAppDispatch, useAppSelector } from '@akinon/next/redux/hooks';
3
- import { getCookie } from '@akinon/next/utils';
4
- import { getUrlPathWithLocale } from '@akinon/next/utils/localization';
5
3
  import {
6
4
  ComponentOptions,
7
5
  CustomTranslations,
@@ -9,7 +7,8 @@ import {
9
7
  PartialDesignTokens,
10
8
  PaymentSessionResponse
11
9
  } from '@checkout.com/checkout-web-components';
12
- import { useEffect, useRef, useMemo, useState } from 'react';
10
+ import { RootState } from '@theme/redux/store';
11
+ import { useEffect, useRef, useMemo } from 'react';
13
12
 
14
13
  export default function FlowPayment({
15
14
  options
@@ -17,7 +16,7 @@ export default function FlowPayment({
17
16
  options?: {
18
17
  /**
19
18
  * Environment to use for the payment components.
20
- * Defaults to 'sandbox'.
19
+ * Defaults to 'production'.
21
20
  * If you want to test the payment components, you can set this to 'sandbox'.
22
21
  */
23
22
  environment?: 'sandbox' | 'production';
@@ -54,16 +53,13 @@ export default function FlowPayment({
54
53
  };
55
54
  }) {
56
55
  const { preOrder, walletPaymentData } = useAppSelector(
57
- (state: any) => state.checkout
56
+ (state: RootState) => state.checkout
58
57
  );
59
58
  const dispatch = useAppDispatch();
60
59
  const flowComponentRef = useRef<any>(null);
61
60
  const lastAmountRef = useRef<string | null>(null);
62
61
  const isInitializingRef = useRef<boolean>(false);
63
62
  const walletPaymentInitialized = useRef<boolean>(false);
64
- const [errors, setErrors] = useState<any>(null);
65
-
66
- const environment = options?.environment || 'sandbox';
67
63
 
68
64
  // Memoize the amount to track actual changes
69
65
  const currentAmount = useMemo(() => {
@@ -93,65 +89,6 @@ export default function FlowPayment({
93
89
  }
94
90
  };
95
91
 
96
- const handlePaymentSuccess = async (paymentData: any) => {
97
- setErrors(null);
98
-
99
- try {
100
- const walletPaymentPageResponse = await dispatch(
101
- checkoutApi.endpoints.setWalletPaymentPage.initiate({
102
- payment_token: JSON.stringify(paymentData)
103
- })
104
- ).unwrap();
105
-
106
- if (walletPaymentPageResponse.errors) {
107
- setErrors(walletPaymentPageResponse.errors);
108
- return;
109
- }
110
-
111
- if (
112
- walletPaymentPageResponse.context_list.find(
113
- (c) => c.page_name === 'WalletCompletePage'
114
- )
115
- ) {
116
- const paymentCompleteResponse = await dispatch(
117
- checkoutApi.endpoints.setWalletCompletePage.initiate(true)
118
- ).unwrap();
119
-
120
- if (paymentCompleteResponse.errors) {
121
- setErrors(paymentCompleteResponse.errors);
122
- return;
123
- }
124
-
125
- if (
126
- paymentCompleteResponse.context_list.find(
127
- (c) => c.page_name === 'ThankYouPage'
128
- )
129
- ) {
130
- const redirectUrl = paymentCompleteResponse.context_list.find(
131
- (c) => c.page_name === 'ThankYouPage'
132
- )?.page_context.context_data.redirect_url;
133
-
134
- const redirectUrlWithLocale = `${
135
- window.location.origin
136
- }${getUrlPathWithLocale(
137
- redirectUrl,
138
- getCookie('pz-locale') || 'en'
139
- )}`;
140
-
141
- window.location.href = redirectUrlWithLocale;
142
- }
143
- }
144
- } catch (error) {
145
- console.error('Error processing payment completion:', error);
146
- setErrors(error);
147
- }
148
- };
149
-
150
- const handlePaymentError = async (error: any) => {
151
- console.error('Payment error occurred:', error);
152
- setErrors(error);
153
- };
154
-
155
92
  const initFlowPaymentWebComponents = async ({
156
93
  publicKey
157
94
  }: {
@@ -211,7 +148,7 @@ export default function FlowPayment({
211
148
 
212
149
  const checkout = await loadCheckoutWebComponents({
213
150
  publicKey,
214
- environment,
151
+ environment: options?.environment || 'production',
215
152
  locale: options?.locale || 'en',
216
153
  translations: options?.translations,
217
154
  paymentSession: paymentSession as PaymentSessionResponse,
@@ -221,14 +158,7 @@ export default function FlowPayment({
221
158
  : undefined
222
159
  });
223
160
 
224
- const flowComponent = checkout.create('flow', {
225
- onPaymentCompleted: async (_self, paymentResponse) => {
226
- handlePaymentSuccess(paymentResponse);
227
- },
228
- onError: async (_self, error) => {
229
- handlePaymentError(error);
230
- }
231
- });
161
+ const flowComponent = checkout.create('flow');
232
162
  flowComponentRef.current = flowComponent;
233
163
 
234
164
  if (container) {
@@ -280,20 +210,5 @@ export default function FlowPayment({
280
210
  };
281
211
  }, []);
282
212
 
283
- return (
284
- <div className="flow-payment-container">
285
- <div id="flow-container"></div>
286
- {errors && (
287
- <div className="text-error-100 text-xs mt-5">
288
- {typeof errors === 'string'
289
- ? errors
290
- : Array.isArray(errors)
291
- ? errors.join(', ')
292
- : typeof errors === 'object'
293
- ? Object.values(errors ?? {}).join(', ')
294
- : 'An error occurred during payment processing'}
295
- </div>
296
- )}
297
- </div>
298
- );
213
+ return <div id="flow-container" className="flow-payment-container"></div>;
299
214
  }