@commercetools/connect-payments-sdk 0.23.1 → 0.24.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,5 +1,11 @@
1
1
  # @commercetools/connect-payments-sdk
2
2
 
3
+ ## 0.24.0
4
+
5
+ ### Minor Changes
6
+
7
+ - bdd4f33: Add a new api and service for interacting with the CT payment-methods APIs.
8
+
3
9
  ## 0.23.1
4
10
 
5
11
  ### Patch Changes
@@ -0,0 +1,12 @@
1
+ import { PaymentMethod, PaymentMethodDraft, PaymentMethodPagedQueryResponse } from '@commercetools/platform-sdk';
2
+ import { APIOpts, CheckIfExistsByPredicate, DeletePaymentMethod, FindPaymentMethods, GetPaymentMethod, PaymentMethodAPI, UpdatePaymentMethod } from '../types/api.type';
3
+ import { CommercetoolsBaseAPI } from './base-api';
4
+ export declare class CommercetoolsPaymentMethodAPI extends CommercetoolsBaseAPI implements PaymentMethodAPI {
5
+ constructor(opts: APIOpts);
6
+ get(opts: GetPaymentMethod): Promise<PaymentMethod>;
7
+ checkIfExistsByPredicate(opts: CheckIfExistsByPredicate): Promise<boolean>;
8
+ find(opts: FindPaymentMethods): Promise<PaymentMethodPagedQueryResponse>;
9
+ create(draft: PaymentMethodDraft): Promise<PaymentMethod>;
10
+ update(opts: UpdatePaymentMethod): Promise<PaymentMethod>;
11
+ delete(opts: DeletePaymentMethod): Promise<PaymentMethod>;
12
+ }
@@ -0,0 +1,78 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CommercetoolsPaymentMethodAPI = void 0;
4
+ const base_api_1 = require("./base-api");
5
+ const ct_api_error_1 = require("../errors/ct-api.error");
6
+ class CommercetoolsPaymentMethodAPI extends base_api_1.CommercetoolsBaseAPI {
7
+ constructor(opts) {
8
+ super(opts);
9
+ Object.setPrototypeOf(this, CommercetoolsPaymentMethodAPI.prototype);
10
+ }
11
+ get(opts) {
12
+ return this.executeCall(this.client.paymentMethods().withId({ ID: opts.id }).get().execute());
13
+ }
14
+ async checkIfExistsByPredicate(opts) {
15
+ try {
16
+ await this.executeCall(this.client
17
+ .paymentMethods()
18
+ .head({
19
+ queryArgs: {
20
+ where: opts.queryString,
21
+ },
22
+ })
23
+ .execute());
24
+ return true;
25
+ }
26
+ catch (error) {
27
+ // The HEAD call returns a 404 if the paymentMethod does not exist
28
+ if (error instanceof ct_api_error_1.CommercetoolsAPIError && error.httpErrorStatus === 404) {
29
+ return false;
30
+ }
31
+ else {
32
+ throw error;
33
+ }
34
+ }
35
+ }
36
+ find(opts) {
37
+ return this.executeCall(this.client
38
+ .paymentMethods()
39
+ .get({
40
+ queryArgs: {
41
+ where: opts.queryString,
42
+ },
43
+ })
44
+ .execute());
45
+ }
46
+ create(draft) {
47
+ return this.executeCall(this.client
48
+ .paymentMethods()
49
+ .post({
50
+ body: draft,
51
+ })
52
+ .execute());
53
+ }
54
+ update(opts) {
55
+ return this.executeCall(this.client
56
+ .paymentMethods()
57
+ .withId({ ID: opts.resource.id })
58
+ .post({
59
+ body: {
60
+ version: opts.resource.version,
61
+ actions: opts.actions,
62
+ },
63
+ })
64
+ .execute());
65
+ }
66
+ delete(opts) {
67
+ return this.executeCall(this.client
68
+ .paymentMethods()
69
+ .withId({ ID: opts.id })
70
+ .delete({
71
+ queryArgs: {
72
+ version: opts.version,
73
+ },
74
+ })
75
+ .execute());
76
+ }
77
+ }
78
+ exports.CommercetoolsPaymentMethodAPI = CommercetoolsPaymentMethodAPI;
@@ -1,11 +1,12 @@
1
1
  import { ContextProvider, RequestContextData } from '../../api';
2
- import { CartAPI, CommercetoolsAPI, CommercetoolsClient, OrderAPI, PaymentAPI } from '../types/api.type';
2
+ import { CartAPI, CommercetoolsAPI, CommercetoolsClient, OrderAPI, PaymentAPI, PaymentMethodAPI } from '../types/api.type';
3
3
  import { Logger } from '../..';
4
4
  export declare class DefaultCommercetoolsAPI implements CommercetoolsAPI {
5
5
  client: CommercetoolsClient;
6
6
  cart: CartAPI;
7
7
  payment: PaymentAPI;
8
8
  order: OrderAPI;
9
+ paymentMethod: PaymentMethodAPI;
9
10
  private logger;
10
11
  constructor(opts: {
11
12
  clientId: string;
@@ -5,6 +5,7 @@ const platform_sdk_1 = require("@commercetools/platform-sdk");
5
5
  const ts_client_1 = require("@commercetools/ts-client");
6
6
  const cart_api_1 = require("./cart-api");
7
7
  const payment_api_1 = require("./payment-api");
8
+ const payment_method_api_1 = require("./payment-method-api");
8
9
  const order_api_1 = require("./order-api");
9
10
  const crypto_1 = require("crypto");
10
11
  class DefaultCommercetoolsAPI {
@@ -12,12 +13,14 @@ class DefaultCommercetoolsAPI {
12
13
  cart;
13
14
  payment;
14
15
  order;
16
+ paymentMethod;
15
17
  logger;
16
18
  constructor(opts) {
17
19
  this.client = createClient(opts);
18
20
  this.cart = new cart_api_1.CommercetoolsCartAPI({ client: this.client });
19
21
  this.payment = new payment_api_1.CommercetoolsPaymentAPI({ client: this.client });
20
22
  this.order = new order_api_1.CommercetoolsOrderAPI({ client: this.client });
23
+ this.paymentMethod = new payment_method_api_1.CommercetoolsPaymentMethodAPI({ client: this.client });
21
24
  this.logger = opts.logger;
22
25
  }
23
26
  }
@@ -3,7 +3,9 @@ export { PaymentService as CommercetoolsPaymentService, TransactionData, UpdateP
3
3
  export { SessionService as CommercetoolsSessionService, Session } from './types/session.type';
4
4
  export { AuthorizationService as CommercetoolsAuthorizationService } from './types/authorization.type';
5
5
  export { OrderService as CommercetoolsOrderService } from './types/order.type';
6
+ export { PaymentMethodService as CommercetoolsPaymentMethodService } from './types/payment-method.type';
7
+ export * as CommercetoolsPaymentMethodTypes from './types/payment-method.type';
6
8
  export { CommercetoolsClient } from './types/api.type';
7
- export { CustomFieldsDraft, Cart, Order, OrderPagedQueryResponse, Payment, PaymentDraft, Money, LineItem, CustomLineItem, Address, Transaction, TransactionType, TransactionState, ShippingInfo, } from '@commercetools/platform-sdk';
9
+ export { CustomFieldsDraft, Cart, Order, OrderPagedQueryResponse, Payment, PaymentDraft, Money, LineItem, CustomLineItem, Address, Transaction, TransactionType, TransactionState, ShippingInfo, PaymentMethod, PaymentMethodToken, PaymentMethodStatus, } from '@commercetools/platform-sdk';
8
10
  export * as CurrencyConverters from './helpers/currency.converter';
9
11
  export * as TaxRateConverter from './helpers/taxrate.converter';
@@ -33,6 +33,7 @@ var __importStar = (this && this.__importStar) || (function () {
33
33
  };
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.TaxRateConverter = exports.CurrencyConverters = void 0;
36
+ exports.TaxRateConverter = exports.CurrencyConverters = exports.CommercetoolsPaymentMethodTypes = void 0;
37
+ exports.CommercetoolsPaymentMethodTypes = __importStar(require("./types/payment-method.type"));
37
38
  exports.CurrencyConverters = __importStar(require("./helpers/currency.converter"));
38
39
  exports.TaxRateConverter = __importStar(require("./helpers/taxrate.converter"));
@@ -0,0 +1,18 @@
1
+ import { FindPaymentMethod, GetPaymentMethod, DeletePaymentMethod, PaymentMethodService, PaymentMethodServiceOptions, UpdatePaymentMethod, DoesTokenBelongToCustomer, GetByTokenValuePaymentMethod, SavePaymentMethodDraft } from '../types/payment-method.type';
2
+ import { PaymentMethod, PaymentMethodPagedQueryResponse } from '@commercetools/platform-sdk';
3
+ /**
4
+ * This is the default implementation of the PamentMethodService interface.
5
+ */
6
+ export declare class DefaultPaymentMethodService implements PaymentMethodService {
7
+ private ctAPI;
8
+ private logger;
9
+ constructor(opts: PaymentMethodServiceOptions);
10
+ find(opts: FindPaymentMethod): Promise<PaymentMethodPagedQueryResponse>;
11
+ get(opts: GetPaymentMethod): Promise<PaymentMethod>;
12
+ getByTokenValue(opts: GetByTokenValuePaymentMethod): Promise<PaymentMethod>;
13
+ doesTokenBelongsToCustomer(opts: DoesTokenBelongToCustomer): Promise<boolean>;
14
+ update(opts: UpdatePaymentMethod): Promise<PaymentMethod>;
15
+ save(opts: SavePaymentMethodDraft): Promise<PaymentMethod>;
16
+ delete(opts: DeletePaymentMethod): Promise<PaymentMethod>;
17
+ private ensurePaymentMethodBelongsToGivenCustomer;
18
+ }
@@ -0,0 +1,147 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DefaultPaymentMethodService = void 0;
4
+ const errorx_1 = require("../../errorx");
5
+ /**
6
+ * This is the default implementation of the PamentMethodService interface.
7
+ */
8
+ class DefaultPaymentMethodService {
9
+ ctAPI;
10
+ logger;
11
+ constructor(opts) {
12
+ this.ctAPI = opts.ctAPI;
13
+ this.logger = opts.logger;
14
+ }
15
+ async find(opts) {
16
+ const whereFilters = [];
17
+ whereFilters.push(`customer(id="${opts.customerId}")`);
18
+ whereFilters.push(`paymentInterface="${opts.paymentInterface}"`);
19
+ if (opts.interfaceAccount) {
20
+ whereFilters.push(`interfaceAccount="${opts.interfaceAccount}"`);
21
+ }
22
+ const whereFilter = whereFilters.join(' and ');
23
+ return await this.ctAPI.paymentMethod.find({
24
+ queryString: whereFilter,
25
+ });
26
+ }
27
+ async get(opts) {
28
+ const paymentMethods = await this.find({
29
+ customerId: opts.customerId,
30
+ paymentInterface: opts.paymentInterface,
31
+ interfaceAccount: opts.interfaceAccount,
32
+ });
33
+ const paymentMethodMatchesId = paymentMethods.results.find((pm) => opts.id === pm.id);
34
+ if (!paymentMethodMatchesId) {
35
+ throw new errorx_1.ErrorResourceNotFound(opts.id);
36
+ }
37
+ return paymentMethodMatchesId;
38
+ }
39
+ async getByTokenValue(opts) {
40
+ const paymentMethods = await this.find({
41
+ customerId: opts.customerId,
42
+ paymentInterface: opts.paymentInterface,
43
+ interfaceAccount: opts.interfaceAccount,
44
+ });
45
+ const paymentMethodsMatchWithTokenValue = paymentMethods.results.filter((pm) => opts.tokenValue === pm.token?.value);
46
+ if (paymentMethodsMatchWithTokenValue.length > 1) {
47
+ throw new errorx_1.ErrorInternalConstraintViolated('Found more then one payment method with the same token value.', {
48
+ privateFields: {
49
+ customerId: opts.customerId,
50
+ paymentMethodIds: paymentMethodsMatchWithTokenValue.map((pm) => pm.id),
51
+ paymentInterface: opts.paymentInterface,
52
+ interfaceAccount: opts.interfaceAccount,
53
+ },
54
+ });
55
+ }
56
+ if (paymentMethodsMatchWithTokenValue.length === 0) {
57
+ throw new errorx_1.ErrorResourceNotFound(opts.customerId, {
58
+ privateFields: {
59
+ customerId: opts.customerId,
60
+ paymentInterface: opts.paymentInterface,
61
+ interfaceAccount: opts.interfaceAccount,
62
+ },
63
+ });
64
+ }
65
+ return paymentMethodsMatchWithTokenValue[0];
66
+ }
67
+ async doesTokenBelongsToCustomer(opts) {
68
+ try {
69
+ const paymentMethod = await this.getByTokenValue({
70
+ customerId: opts.customerId,
71
+ paymentInterface: opts.paymentInterface,
72
+ interfaceAccount: opts.interfaceAccount,
73
+ tokenValue: opts.tokenValue,
74
+ });
75
+ return paymentMethod !== undefined;
76
+ }
77
+ catch (error) {
78
+ if (error instanceof errorx_1.ErrorResourceNotFound) {
79
+ return false;
80
+ }
81
+ throw error;
82
+ }
83
+ }
84
+ async update(opts) {
85
+ await this.ensurePaymentMethodBelongsToGivenCustomer(opts.resource.id, opts.customerId);
86
+ return this.ctAPI.paymentMethod.update({
87
+ actions: opts.actions,
88
+ resource: opts.resource,
89
+ });
90
+ }
91
+ async save(opts) {
92
+ const paymentMethodExistsWithSameTokenValue = await this.doesTokenBelongsToCustomer({
93
+ customerId: opts.customerId,
94
+ paymentInterface: opts.paymentInterface,
95
+ interfaceAccount: opts.interfaceAccount,
96
+ tokenValue: opts.token,
97
+ });
98
+ if (paymentMethodExistsWithSameTokenValue) {
99
+ throw new errorx_1.ErrorInternalConstraintViolated('A payment method with the same "token.value" already exists.', {
100
+ privateFields: {
101
+ customerId: opts.customerId,
102
+ paymentInterface: opts.paymentInterface,
103
+ interfaceAccount: opts.interfaceAccount,
104
+ },
105
+ });
106
+ }
107
+ return await this.ctAPI.paymentMethod.create({
108
+ customer: {
109
+ id: opts.customerId,
110
+ typeId: 'customer',
111
+ },
112
+ paymentInterface: opts.paymentInterface,
113
+ interfaceAccount: opts.interfaceAccount,
114
+ method: opts.method,
115
+ default: false,
116
+ paymentMethodStatus: 'Active',
117
+ token: {
118
+ value: opts.token,
119
+ },
120
+ });
121
+ }
122
+ async delete(opts) {
123
+ await this.ensurePaymentMethodBelongsToGivenCustomer(opts.id, opts.customerId);
124
+ return await this.ctAPI.paymentMethod.delete({
125
+ id: opts.id,
126
+ version: opts.version,
127
+ });
128
+ }
129
+ async ensurePaymentMethodBelongsToGivenCustomer(paymentMethodId, customerId) {
130
+ const predicate = `id="${paymentMethodId}" and customer(id="${customerId}")`;
131
+ const doesGivenPaymentMethodBelongToGivenCustomer = await this.ctAPI.paymentMethod.checkIfExistsByPredicate({
132
+ queryString: predicate,
133
+ });
134
+ if (!doesGivenPaymentMethodBelongToGivenCustomer) {
135
+ throw new errorx_1.ErrorInternalConstraintViolated(`The provided payment-method '${paymentMethodId}' does not have a customer '${customerId}' set`, {
136
+ fields: {
137
+ paymentMethodId: paymentMethodId,
138
+ customerId: customerId,
139
+ },
140
+ privateFields: {
141
+ predicateQueryString: predicate,
142
+ },
143
+ });
144
+ }
145
+ }
146
+ }
147
+ exports.DefaultPaymentMethodService = DefaultPaymentMethodService;
@@ -17,6 +17,7 @@ export declare class DefaultPaymentService implements PaymentService {
17
17
  private populateAddTransactionAction;
18
18
  private populateChangeTransactionState;
19
19
  private populateSetPaymentMethod;
20
+ private populateSetMethodInfoToken;
20
21
  private populateSetCustomType;
21
22
  private populateAddInterfaceInteractions;
22
23
  findMatchingTransactions(payment: Payment, transaction: TransactionData): Transaction[];
@@ -67,6 +67,9 @@ class DefaultPaymentService {
67
67
  if (!payment.paymentMethodInfo?.method && updateInfo.paymentMethod) {
68
68
  actions.push(this.populateSetPaymentMethod(updateInfo.paymentMethod));
69
69
  }
70
+ if (!payment.paymentMethodInfo?.token && updateInfo.token) {
71
+ actions.push(this.populateSetMethodInfoToken(updateInfo.token));
72
+ }
70
73
  if (updateInfo.transaction) {
71
74
  const transactionChanges = this.consolidateTransactionChanges(payment, updateInfo.transaction);
72
75
  if (transactionChanges.length > 0) {
@@ -116,6 +119,14 @@ class DefaultPaymentService {
116
119
  method: paymentMethod,
117
120
  };
118
121
  }
122
+ populateSetMethodInfoToken(token) {
123
+ return {
124
+ action: 'setMethodInfoToken',
125
+ token: {
126
+ value: token,
127
+ },
128
+ };
129
+ }
119
130
  populateSetCustomType(customFields) {
120
131
  return {
121
132
  action: 'setCustomType',
@@ -1,4 +1,4 @@
1
- import { Cart, CartPagedQueryResponse, OrderPagedQueryResponse, Payment, PaymentDraft, PaymentPagedQueryResponse, PaymentUpdateAction } from '@commercetools/platform-sdk';
1
+ import { Cart, CartPagedQueryResponse, OrderPagedQueryResponse, Payment, PaymentDraft, PaymentPagedQueryResponse, PaymentUpdateAction, PaymentMethod, PaymentMethodDraft, PaymentMethodPagedQueryResponse, PaymentMethodUpdateAction } from '@commercetools/platform-sdk';
2
2
  import { ByProjectKeyRequestBuilder } from '@commercetools/platform-sdk/dist/declarations/src/generated/client/by-project-key-request-builder';
3
3
  export type CommercetoolsClient = ByProjectKeyRequestBuilder;
4
4
  export type CommercetoolsSessionClient = ByProjectKeyRequestBuilder;
@@ -24,6 +24,23 @@ export type OauthToken = {
24
24
  scope: string;
25
25
  refreshToken?: string;
26
26
  };
27
+ export type UpdatePaymentMethod = {
28
+ resource: UpdateResource;
29
+ actions: PaymentMethodUpdateAction[];
30
+ };
31
+ export type FindPaymentMethods = {
32
+ queryString: string;
33
+ };
34
+ export type GetPaymentMethod = {
35
+ id: string;
36
+ };
37
+ export type DeletePaymentMethod = {
38
+ id: string;
39
+ version: number;
40
+ };
41
+ export type CheckIfExistsByPredicate = {
42
+ queryString: string;
43
+ };
27
44
  export interface AuthorizationAPI {
28
45
  getToken(): Promise<OauthToken>;
29
46
  }
@@ -38,6 +55,14 @@ export interface PaymentAPI {
38
55
  createPayment(paymentDraft: PaymentDraft): Promise<Payment>;
39
56
  updatePayment(opts: UpdatePayment): Promise<Payment>;
40
57
  }
58
+ export interface PaymentMethodAPI {
59
+ find(opts: FindPaymentMethods): Promise<PaymentMethodPagedQueryResponse>;
60
+ get(opts: GetPaymentMethod): Promise<PaymentMethod>;
61
+ create(draft: PaymentMethodDraft): Promise<PaymentMethod>;
62
+ update(opts: UpdatePaymentMethod): Promise<PaymentMethod>;
63
+ delete(opts: DeletePaymentMethod): Promise<PaymentMethod>;
64
+ checkIfExistsByPredicate(opts: CheckIfExistsByPredicate): Promise<boolean>;
65
+ }
41
66
  export interface OrderAPI {
42
67
  find(queryPredicate: string): Promise<OrderPagedQueryResponse>;
43
68
  }
@@ -45,4 +70,5 @@ export interface CommercetoolsAPI {
45
70
  cart: CartAPI;
46
71
  payment: PaymentAPI;
47
72
  order: OrderAPI;
73
+ paymentMethod: PaymentMethodAPI;
48
74
  }
@@ -0,0 +1,108 @@
1
+ import { CommercetoolsAPI, UpdateResource } from './api.type';
2
+ import { Logger } from '../../logger';
3
+ import { PaymentMethod, PaymentMethodPagedQueryResponse, PaymentMethodUpdateAction } from '@commercetools/platform-sdk';
4
+ export type PaymentMethodServiceOptions = {
5
+ ctAPI: CommercetoolsAPI;
6
+ logger: Logger;
7
+ };
8
+ export type FindPaymentMethod = {
9
+ customerId: string;
10
+ paymentInterface: string;
11
+ interfaceAccount?: string;
12
+ };
13
+ export type GetPaymentMethod = {
14
+ customerId: string;
15
+ id: string;
16
+ paymentInterface: string;
17
+ interfaceAccount?: string;
18
+ };
19
+ export type GetByTokenValuePaymentMethod = {
20
+ customerId: string;
21
+ tokenValue: string;
22
+ paymentInterface: string;
23
+ interfaceAccount?: string;
24
+ };
25
+ export type DoesTokenBelongToCustomer = {
26
+ customerId: string;
27
+ tokenValue: string;
28
+ paymentInterface: string;
29
+ interfaceAccount?: string;
30
+ };
31
+ export type DeletePaymentMethod = {
32
+ customerId: string;
33
+ id: string;
34
+ version: number;
35
+ };
36
+ export type UpdatePaymentMethod = {
37
+ customerId: string;
38
+ resource: UpdateResource;
39
+ actions: PaymentMethodUpdateAction[];
40
+ };
41
+ export type SavePaymentMethodDraft = {
42
+ customerId: string;
43
+ token: string;
44
+ paymentInterface: string;
45
+ interfaceAccount?: string;
46
+ method: string;
47
+ };
48
+ /**
49
+ * Payment methods service interface exposes methods to interact with the commercetools platform API.
50
+ */
51
+ export interface PaymentMethodService {
52
+ /**
53
+ * Finds all of the payment-methods that match with the given parameters.
54
+ *
55
+ * @param opts the parameters to search by
56
+ *
57
+ * @returns a paged list of payment-methods
58
+ */
59
+ find(opts: FindPaymentMethod): Promise<PaymentMethodPagedQueryResponse>;
60
+ /**
61
+ * Returns a payment-method by the given ID which must belong to the given customerId.
62
+ *
63
+ * @param opts
64
+ *
65
+ * @returns the payment-method
66
+ */
67
+ get(opts: GetPaymentMethod): Promise<PaymentMethod>;
68
+ /**
69
+ * Returns a payment-method by the given tokenValue which must belong to the given customerId and must be unique.
70
+ *
71
+ * @param opts
72
+ *
73
+ * @returns the payment-method
74
+ */
75
+ getByTokenValue(opts: GetByTokenValuePaymentMethod): Promise<PaymentMethod>;
76
+ /**
77
+ * Returns true if the given token belongs to the given customer for any payment-method.
78
+ *
79
+ * @param opts
80
+ *
81
+ * @returns true if the given token belongs to the customer for any payment method, false otherwise.
82
+ */
83
+ doesTokenBelongsToCustomer(opts: DoesTokenBelongToCustomer): Promise<boolean>;
84
+ /**
85
+ * Saves a new payment-method given the draft payload. The customer attribute is mandatory.
86
+ *
87
+ * @param opts the payment-method draft
88
+ *
89
+ * @returns the newly created payment-method
90
+ */
91
+ save(opts: SavePaymentMethodDraft): Promise<PaymentMethod>;
92
+ /**
93
+ * Updates an existing payment-method with the given list of update actions. The payment-method must belong to the given customerId.
94
+ *
95
+ * @param opts the list of update actions to apply
96
+ *
97
+ * @returns the updated payment-method
98
+ */
99
+ update(opts: UpdatePaymentMethod): Promise<PaymentMethod>;
100
+ /**
101
+ * Deletes the given payment-method
102
+ *
103
+ * @param opts the payment-method to delete
104
+ *
105
+ * @returns returns the final state of the payment-method before it's deleted
106
+ */
107
+ delete(opts: DeletePaymentMethod): Promise<PaymentMethod>;
108
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -34,6 +34,7 @@ export type UpdatePayment = {
34
34
  transaction?: TransactionData;
35
35
  paymentMethod?: string;
36
36
  customFields?: CustomFieldsDraft;
37
+ token?: string;
37
38
  };
38
39
  export type FindTransaction = {
39
40
  payment: Payment;
package/dist/index.d.ts CHANGED
@@ -4,6 +4,7 @@ import { DefaultAuthorizationService } from './commercetools/services/ct-authori
4
4
  import { DefaultCartService } from './commercetools/services/ct-cart.service';
5
5
  import { DefaultOrderService } from './commercetools/services/ct-order.service';
6
6
  import { DefaultPaymentService } from './commercetools/services/ct-payment.service';
7
+ import { DefaultPaymentMethodService } from './commercetools/services/ct-payment-method.service';
7
8
  import { Logger } from './logger';
8
9
  export * from './api';
9
10
  export * from './commercetools';
@@ -27,6 +28,7 @@ export declare const setupPaymentSDK: (opts: {
27
28
  ctCartService: DefaultCartService;
28
29
  ctOrderService: DefaultOrderService;
29
30
  ctPaymentService: DefaultPaymentService;
31
+ ctPaymentMethodService: DefaultPaymentMethodService;
30
32
  ctAuthorizationService: DefaultAuthorizationService;
31
33
  contextProvider: RequestContextProvider;
32
34
  sessionHeaderAuthHookFn: SessionHeaderAuthenticationHook;
package/dist/index.js CHANGED
@@ -21,6 +21,7 @@ const ct_authorization_service_1 = require("./commercetools/services/ct-authoriz
21
21
  const ct_cart_service_1 = require("./commercetools/services/ct-cart.service");
22
22
  const ct_order_service_1 = require("./commercetools/services/ct-order.service");
23
23
  const ct_payment_service_1 = require("./commercetools/services/ct-payment.service");
24
+ const ct_payment_method_service_1 = require("./commercetools/services/ct-payment-method.service");
24
25
  const ct_session_service_1 = require("./commercetools/services/ct-session.service");
25
26
  const base_decorator_1 = require("./fetch/decorators/base.decorator");
26
27
  const monitoring_decorator_1 = require("./fetch/decorators/monitoring.decorator");
@@ -64,6 +65,7 @@ const setupPaymentSDK = (opts) => {
64
65
  const ctCartService = new ct_cart_service_1.DefaultCartService({ ctAPI, logger, contextProvider });
65
66
  const ctOrderService = new ct_order_service_1.DefaultOrderService({ ctAPI, logger });
66
67
  const ctPaymentService = new ct_payment_service_1.DefaultPaymentService({ ctAPI, logger });
68
+ const ctPaymentMethodService = new ct_payment_method_service_1.DefaultPaymentMethodService({ ctAPI, logger });
67
69
  const oauth2Service = new security_1.DefaultOauth2Service({ logger });
68
70
  const jwtService = new security_1.DefaultJWTService({
69
71
  jwksUrl: opts.jwksUrl,
@@ -132,6 +134,7 @@ const setupPaymentSDK = (opts) => {
132
134
  ctCartService,
133
135
  ctOrderService,
134
136
  ctPaymentService,
137
+ ctPaymentMethodService,
135
138
  ctAuthorizationService,
136
139
  contextProvider,
137
140
  sessionHeaderAuthHookFn,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@commercetools/connect-payments-sdk",
3
- "version": "0.23.1",
3
+ "version": "0.24.0",
4
4
  "description": "Payment SDK for commercetools payment connectors",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -15,9 +15,9 @@
15
15
  ],
16
16
  "license": "ISC",
17
17
  "dependencies": {
18
- "@commercetools-backend/loggers": "24.1.0",
19
- "@commercetools/platform-sdk": "8.10.0",
20
- "@commercetools/ts-client": "3.4.0",
18
+ "@commercetools-backend/loggers": "24.5.0",
19
+ "@commercetools/platform-sdk": "8.14.0",
20
+ "@commercetools/ts-client": "3.4.1",
21
21
  "jsonwebtoken": "9.0.2",
22
22
  "jwks-rsa": "3.2.0",
23
23
  "lodash": "4.17.21",