@commercetools/connect-payments-sdk 0.2.1 → 0.2.2
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 +6 -0
- package/dist/commercetools/services/ct-cart.service.d.ts +1 -0
- package/dist/commercetools/services/ct-cart.service.js +8 -4
- package/dist/commercetools/services/ct-session.service.d.ts +1 -0
- package/dist/commercetools/services/ct-session.service.js +3 -0
- package/dist/commercetools/types/session.type.d.ts +1 -0
- package/dist/security/authn/session-authn-manager.js +1 -0
- package/dist/security/authn/types/authn.type.d.ts +1 -0
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -82,14 +82,18 @@ class DefaultCartService {
|
|
|
82
82
|
if (this.wasPaymentReverted(payment)) {
|
|
83
83
|
return 0;
|
|
84
84
|
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
85
|
+
if (this.isPaymentApproved(payment)) {
|
|
86
|
+
return payment.amountPlanned.centAmount;
|
|
87
|
+
}
|
|
88
|
+
return 0;
|
|
89
89
|
}
|
|
90
90
|
wasPaymentReverted(payment) {
|
|
91
91
|
return payment.transactions.some((tx) => (tx.type === 'CancelAuthorization' || tx.type === 'Refund') &&
|
|
92
92
|
(tx.state === 'Success' || tx.state === 'Pending'));
|
|
93
93
|
}
|
|
94
|
+
isPaymentApproved(payment) {
|
|
95
|
+
return payment.transactions.some((transaction) => (transaction.state === 'Success' || transaction.state === 'Pending') &&
|
|
96
|
+
(transaction.type === 'Authorization' || transaction.type === 'Charge'));
|
|
97
|
+
}
|
|
94
98
|
}
|
|
95
99
|
exports.DefaultCartService = DefaultCartService;
|
|
@@ -15,4 +15,5 @@ export declare class DefaultSessionService implements SessionService {
|
|
|
15
15
|
getAllowedPaymentMethodsFromSession(session: Session): string[];
|
|
16
16
|
getProcessorUrlFromSession(session: Session): string;
|
|
17
17
|
getPaymentInterfaceFromSession(session: Session): string | undefined;
|
|
18
|
+
getMerchantReturnUrlFromSession(session: Session): string | undefined;
|
|
18
19
|
}
|
|
@@ -47,5 +47,8 @@ class DefaultSessionService {
|
|
|
47
47
|
getPaymentInterfaceFromSession(session) {
|
|
48
48
|
return session.metadata?.paymentInterface;
|
|
49
49
|
}
|
|
50
|
+
getMerchantReturnUrlFromSession(session) {
|
|
51
|
+
return session.metadata?.merchantReturnUrl;
|
|
52
|
+
}
|
|
50
53
|
}
|
|
51
54
|
exports.DefaultSessionService = DefaultSessionService;
|
|
@@ -27,4 +27,5 @@ export interface SessionService {
|
|
|
27
27
|
getAllowedPaymentMethodsFromSession(session: Session): string[];
|
|
28
28
|
getProcessorUrlFromSession(session: Session): string;
|
|
29
29
|
getPaymentInterfaceFromSession(session: Session): string | undefined;
|
|
30
|
+
getMerchantReturnUrlFromSession(session: Session): string | undefined;
|
|
30
31
|
}
|
|
@@ -17,6 +17,7 @@ class SessionAuthenticationManager {
|
|
|
17
17
|
allowedPaymentMethods: this.sessionService.getAllowedPaymentMethodsFromSession(session),
|
|
18
18
|
processorUrl: this.sessionService.getProcessorUrlFromSession(session),
|
|
19
19
|
paymentInterface: this.sessionService.getPaymentInterfaceFromSession(session),
|
|
20
|
+
merchantReturnUrl: this.sessionService.getMerchantReturnUrlFromSession(session),
|
|
20
21
|
});
|
|
21
22
|
}
|
|
22
23
|
catch (e) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@commercetools/connect-payments-sdk",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "Payment SDK for commercetools payment connectors",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
],
|
|
16
16
|
"license": "ISC",
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@commercetools/platform-sdk": "7.
|
|
18
|
+
"@commercetools/platform-sdk": "7.4.0",
|
|
19
19
|
"@commercetools/sdk-client-v2": "2.3.0",
|
|
20
20
|
"jsonwebtoken": "9.0.2",
|
|
21
21
|
"jwks-rsa": "3.1.0"
|