@wearejh/m2-pwa-adyen 0.33.0 → 0.35.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 +27 -0
- package/lib/epics/adyenPayment.epic.ts +51 -8
- package/package.json +8 -8
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,33 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [0.35.0](https://github.com/WeareJH/mage-mono/compare/v0.34.0...v0.35.0) (2025-09-08)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @wearejh/m2-pwa-adyen
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
# [0.34.0](https://github.com/WeareJH/mage-mono/compare/v0.33.1...v0.34.0) (2025-09-08)
|
|
15
|
+
|
|
16
|
+
**Note:** Version bump only for package @wearejh/m2-pwa-adyen
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
## [0.33.1](https://github.com/WeareJH/mage-mono/compare/v0.33.0...v0.33.1) (2025-07-01)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
### Bug Fixes
|
|
26
|
+
|
|
27
|
+
* **m2-pwa-adyen:** add a retry loop to the order status API request to allow the server time to process (WOOD-2597) ([1173c66](https://github.com/WeareJH/mage-mono/commit/1173c66b3dff6cd946aeaad9807856d183a7a929))
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
6
33
|
# [0.33.0](https://github.com/WeareJH/mage-mono/compare/v0.32.0...v0.33.0) (2025-06-18)
|
|
7
34
|
|
|
8
35
|
**Note:** Version bump only for package @wearejh/m2-pwa-adyen
|
|
@@ -3,8 +3,8 @@ import { AppendState, CheckoutActions, CheckoutMsg, State, TypeMap as CheckoutTy
|
|
|
3
3
|
import { EpicDeps } from '@wearejh/m2-pwa-engine/lib/types';
|
|
4
4
|
import { extractErrorAndCode } from '@wearejh/swagger-rxjs/utils/ajax-helpers';
|
|
5
5
|
import { ofType } from 'redux-observable';
|
|
6
|
-
import { catchError, map, mergeMap, pluck, switchMap, take, withLatestFrom } from 'rxjs/operators';
|
|
7
|
-
import { concat, EMPTY, Observable, of, race } from 'rxjs';
|
|
6
|
+
import { catchError, map, mergeMap, pluck, retryWhen, scan, switchMap, take, withLatestFrom } from 'rxjs/operators';
|
|
7
|
+
import { concat, EMPTY, Observable, of, race, throwError, timer } from 'rxjs';
|
|
8
8
|
|
|
9
9
|
import { execute as getUserAdyenPaymentStatus } from '../rest/AdyenPaymentAdyenOrderPaymentStatusV1GetOrderPaymentStatusPost';
|
|
10
10
|
import { execute as getGuestAdyenPaymentStatus } from '../rest/AdyenPaymentGuestAdyenOrderPaymentStatusV1GetOrderPaymentStatusPost';
|
|
@@ -14,15 +14,58 @@ import { AdyenPayload, AdyenResponseParams } from '../adyen.types';
|
|
|
14
14
|
import { processAdyenResponse } from './utils/processAdyenResponse';
|
|
15
15
|
import { getAdyenCart } from './utils/getAdyenCart';
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
/**
|
|
18
|
+
* Number of retries for getting the order status.
|
|
19
|
+
*
|
|
20
|
+
* The retries allow the errors to be handled gracefully for X number of attempts.
|
|
21
|
+
* If the error persists, the error can be thrown to the user.
|
|
22
|
+
*/
|
|
23
|
+
const ORDER_STATUS_RETY_COUNT = 5;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Delay in milliseconds between retries for getting the order status.
|
|
27
|
+
*/
|
|
28
|
+
const ORDER_STATUS_RETRY_DELAY = 600;
|
|
29
|
+
|
|
30
|
+
function getOrderStatus({ cartVariant, orderId, cartId }, deps: EpicDeps): Observable<AdyenResponseParams> {
|
|
31
|
+
let apiRequest = getGuestAdyenPaymentStatus({ cartId }, { orderId }, deps);
|
|
32
|
+
|
|
18
33
|
if (cartVariant === CartVariant.Account) {
|
|
19
|
-
|
|
20
|
-
map((response) => JSON.parse(response) as AdyenResponseParams),
|
|
21
|
-
);
|
|
34
|
+
apiRequest = getUserAdyenPaymentStatus({ orderId }, deps);
|
|
22
35
|
}
|
|
23
36
|
|
|
24
|
-
|
|
25
|
-
|
|
37
|
+
if (!apiRequest) {
|
|
38
|
+
return throwError(new Error('Cannot proceed without order information'));
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return apiRequest.pipe(
|
|
42
|
+
retryWhen((errors) =>
|
|
43
|
+
errors.pipe(
|
|
44
|
+
scan((retryCount, error) => {
|
|
45
|
+
const { error: errorMessage } = extractErrorAndCode(error);
|
|
46
|
+
|
|
47
|
+
if (retryCount >= ORDER_STATUS_RETY_COUNT) {
|
|
48
|
+
throw error;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if (errorMessage.includes('Please try again')) {
|
|
52
|
+
return retryCount + 1;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
throw error;
|
|
56
|
+
}, 0),
|
|
57
|
+
mergeMap((retryCount) =>
|
|
58
|
+
retryCount <= ORDER_STATUS_RETY_COUNT ? timer(ORDER_STATUS_RETRY_DELAY) : of(null),
|
|
59
|
+
),
|
|
60
|
+
),
|
|
61
|
+
),
|
|
62
|
+
map((response) => {
|
|
63
|
+
if (typeof response !== 'string') {
|
|
64
|
+
throw new Error('Expected response to be a string');
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return JSON.parse(response) as AdyenResponseParams;
|
|
68
|
+
}),
|
|
26
69
|
);
|
|
27
70
|
}
|
|
28
71
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wearejh/m2-pwa-adyen",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.35.0",
|
|
4
4
|
"description": "> TODO: description",
|
|
5
5
|
"author": "Shane Osbourne <shane.osbourne8@gmail.com>",
|
|
6
6
|
"homepage": "",
|
|
@@ -22,13 +22,13 @@
|
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"@adyen/adyen-web": "5.59.0",
|
|
25
|
-
"@wearejh/m2-pwa-cart": "^0.
|
|
26
|
-
"@wearejh/m2-pwa-checkout": "^0.
|
|
27
|
-
"@wearejh/m2-pwa-engine": "^0.
|
|
28
|
-
"@wearejh/react-hooks": "^0.
|
|
29
|
-
"@wearejh/rx-form": "^0.
|
|
30
|
-
"@wearejh/swagger-rxjs": "^0.
|
|
25
|
+
"@wearejh/m2-pwa-cart": "^0.35.0",
|
|
26
|
+
"@wearejh/m2-pwa-checkout": "^0.35.0",
|
|
27
|
+
"@wearejh/m2-pwa-engine": "^0.35.0",
|
|
28
|
+
"@wearejh/react-hooks": "^0.35.0",
|
|
29
|
+
"@wearejh/rx-form": "^0.35.0",
|
|
30
|
+
"@wearejh/swagger-rxjs": "^0.35.0",
|
|
31
31
|
"load-js": "^3.0.3"
|
|
32
32
|
},
|
|
33
|
-
"gitHead": "
|
|
33
|
+
"gitHead": "c28fc34b4cd0b85fafe885cfdcd364f4c576e11b"
|
|
34
34
|
}
|