@commercetools/connect-payments-sdk 0.25.1 → 0.26.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
|
@@ -7,6 +7,6 @@ export { PaymentMethodService as CommercetoolsPaymentMethodService } from './typ
|
|
|
7
7
|
export { CustomTypeService as CommercetoolsCustomTypeService } from './types/custom-type.type';
|
|
8
8
|
export * as CommercetoolsPaymentMethodTypes from './types/payment-method.type';
|
|
9
9
|
export { CommercetoolsClient } from './types/api.type';
|
|
10
|
-
export { CustomFieldsDraft, Cart, Order, OrderPagedQueryResponse, Payment, PaymentDraft, PaymentMethodInfoDraft, Money, LineItem, CustomLineItem, Address, Transaction, TransactionType, TransactionState, ShippingInfo, PaymentMethod, PaymentMethodPagedQueryResponse, PaymentMethodToken, PaymentMethodStatus, Type, TypeDraft, TypePagedQueryResponse, LocalizedString, } from '@commercetools/platform-sdk';
|
|
10
|
+
export { CustomFields, CustomFieldsDraft, Cart, Order, OrderPagedQueryResponse, Payment, PaymentDraft, PaymentMethodInfoDraft, Money, LineItem, CustomLineItem, Address, Transaction, TransactionType, TransactionState, ShippingInfo, PaymentMethod, PaymentMethodPagedQueryResponse, PaymentMethodToken, PaymentMethodStatus, Type, TypeDraft, TypeUpdateAction, ProductTypeDraft, TypeAddFieldDefinitionAction, TypeRemoveFieldDefinitionAction, CustomerSetCustomFieldAction, CustomerSetCustomTypeAction, CustomerUpdateAction, TypePagedQueryResponse, LocalizedString, Customer, } from '@commercetools/platform-sdk';
|
|
11
11
|
export * as CurrencyConverters from './helpers/currency.converter';
|
|
12
12
|
export * as TaxRateConverter from './helpers/taxrate.converter';
|
|
@@ -28,6 +28,7 @@ export declare class DefaultCartService implements CartService {
|
|
|
28
28
|
*/
|
|
29
29
|
getNormalizedShipping(opts: GetNormalizedShipping): NormalizedShipping[];
|
|
30
30
|
addPayment(opts: AddPayment): Promise<Cart>;
|
|
31
|
+
isRecurringCart(cart: Cart): boolean;
|
|
31
32
|
private calculateTotalPaidAmount;
|
|
32
33
|
private calculatePaymentAmount;
|
|
33
34
|
private wasPaymentReverted;
|
|
@@ -170,6 +170,14 @@ class DefaultCartService {
|
|
|
170
170
|
}
|
|
171
171
|
throw err;
|
|
172
172
|
}
|
|
173
|
+
isRecurringCart(cart) {
|
|
174
|
+
if (!cart.customerId)
|
|
175
|
+
return false;
|
|
176
|
+
const cartOrigin = cart.origin === 'RecurringOrder';
|
|
177
|
+
const hasRecurringLineItems = cart.lineItems?.some((item) => item.recurrenceInfo) ?? false;
|
|
178
|
+
const hasRecurringCustomLineItems = cart.customLineItems?.some((item) => item.recurrenceInfo) ?? false;
|
|
179
|
+
return cartOrigin || hasRecurringLineItems || hasRecurringCustomLineItems;
|
|
180
|
+
}
|
|
173
181
|
async calculateTotalPaidAmount(cart) {
|
|
174
182
|
if (!cart.paymentInfo || cart.paymentInfo.payments.length === 0) {
|
|
175
183
|
return 0;
|
|
@@ -55,4 +55,11 @@ export interface CartService {
|
|
|
55
55
|
*/
|
|
56
56
|
getPlannedPaymentAmount(opts: GetPaymentAmount): Promise<PaymentAmount>;
|
|
57
57
|
addPayment(opts: AddPayment): Promise<Cart>;
|
|
58
|
+
/**
|
|
59
|
+
* Checks if the given cart contains items configured for recurring orders.
|
|
60
|
+
*
|
|
61
|
+
* @param cart - The cart to check
|
|
62
|
+
* @returns true if the cart contains recurring items, false otherwise
|
|
63
|
+
*/
|
|
64
|
+
isRecurringCart(cart: Cart): boolean;
|
|
58
65
|
}
|