@commercetools/connect-payments-sdk
Advanced tools
Comparing version 0.2.1 to 0.2.2
# @commercetools/connect-payments-sdk | ||
## 0.2.2 | ||
### Patch Changes | ||
- b87b064: added support for retrieving the merchant return url from the session | ||
## 0.2.1 | ||
@@ -4,0 +10,0 @@ |
@@ -17,2 +17,3 @@ import { CartService, CartServiceOptions, GetCart, GetPaymentAmount } from '../types/cart.type'; | ||
private wasPaymentReverted; | ||
private isPaymentApproved; | ||
} |
@@ -85,6 +85,6 @@ "use strict"; | ||
} | ||
return payment.transactions | ||
.filter((transaction) => (transaction.state === 'Success' || transaction.state === 'Pending') && | ||
(transaction.type === 'Authorization' || transaction.type === 'Charge')) | ||
.reduce((total, transaction) => total + transaction.amount.centAmount, 0); | ||
if (this.isPaymentApproved(payment)) { | ||
return payment.amountPlanned.centAmount; | ||
} | ||
return 0; | ||
} | ||
@@ -95,3 +95,7 @@ wasPaymentReverted(payment) { | ||
} | ||
isPaymentApproved(payment) { | ||
return payment.transactions.some((transaction) => (transaction.state === 'Success' || transaction.state === 'Pending') && | ||
(transaction.type === 'Authorization' || transaction.type === 'Charge')); | ||
} | ||
} | ||
exports.DefaultCartService = DefaultCartService; |
@@ -18,2 +18,3 @@ import { AuthorizationService, CommercetoolsToken } from '../types/authorization.type'; | ||
getPaymentInterfaceFromSession(session: Session): string | undefined; | ||
getMerchantReturnUrlFromSession(session: Session): string | undefined; | ||
} |
@@ -50,3 +50,6 @@ "use strict"; | ||
} | ||
getMerchantReturnUrlFromSession(session) { | ||
return session.metadata?.merchantReturnUrl; | ||
} | ||
} | ||
exports.DefaultSessionService = DefaultSessionService; |
@@ -30,2 +30,3 @@ export type Session = { | ||
getPaymentInterfaceFromSession(session: Session): string | undefined; | ||
getMerchantReturnUrlFromSession(session: Session): string | undefined; | ||
} |
@@ -20,2 +20,3 @@ "use strict"; | ||
paymentInterface: this.sessionService.getPaymentInterfaceFromSession(session), | ||
merchantReturnUrl: this.sessionService.getMerchantReturnUrlFromSession(session), | ||
}); | ||
@@ -22,0 +23,0 @@ } |
@@ -20,2 +20,3 @@ export interface AuthenticationManager { | ||
paymentInterface?: string; | ||
merchantReturnUrl?: string; | ||
}; | ||
@@ -22,0 +23,0 @@ export type Oauth2Principal = { |
{ | ||
"name": "@commercetools/connect-payments-sdk", | ||
"version": "0.2.1", | ||
"version": "0.2.2", | ||
"description": "Payment SDK for commercetools payment connectors", | ||
@@ -18,3 +18,3 @@ "main": "dist/index.js", | ||
"dependencies": { | ||
"@commercetools/platform-sdk": "7.3.0", | ||
"@commercetools/platform-sdk": "7.4.0", | ||
"@commercetools/sdk-client-v2": "2.3.0", | ||
@@ -21,0 +21,0 @@ "jsonwebtoken": "9.0.2", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
98842
2584
+ Added@commercetools/platform-sdk@7.4.0(transitive)
+ Added@commercetools/ts-client@1.2.1(transitive)
+ Addedabort-controller@3.0.0(transitive)
+ Addedevent-target-shim@5.0.1(transitive)
+ Addeduuid@9.0.1(transitive)
- Removed@commercetools/platform-sdk@7.3.0(transitive)