@commercetools/connect-payments-sdk 0.23.1 → 0.25.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.
Files changed (39) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/api/context/request-context.helper.d.ts +6 -0
  3. package/dist/api/context/request-context.helper.js +12 -0
  4. package/dist/commercetools/api/custom-type-api.d.ts +10 -0
  5. package/dist/commercetools/api/custom-type-api.js +45 -0
  6. package/dist/commercetools/api/payment-method-api.d.ts +12 -0
  7. package/dist/commercetools/api/payment-method-api.js +69 -0
  8. package/dist/commercetools/api/root-api.d.ts +3 -1
  9. package/dist/commercetools/api/root-api.js +7 -0
  10. package/dist/commercetools/index.d.ts +4 -1
  11. package/dist/commercetools/index.js +2 -1
  12. package/dist/commercetools/services/ct-custom-type.service.d.ts +34 -0
  13. package/dist/commercetools/services/ct-custom-type.service.js +91 -0
  14. package/dist/commercetools/services/ct-payment-method.service.d.ts +18 -0
  15. package/dist/commercetools/services/ct-payment-method.service.js +148 -0
  16. package/dist/commercetools/services/ct-payment.service.d.ts +16 -0
  17. package/dist/commercetools/services/ct-payment.service.js +101 -7
  18. package/dist/commercetools/types/api.type.d.ts +34 -1
  19. package/dist/commercetools/types/custom-type.type.d.ts +20 -0
  20. package/dist/commercetools/types/custom-type.type.js +2 -0
  21. package/dist/commercetools/types/payment-method.type.d.ts +109 -0
  22. package/dist/commercetools/types/payment-method.type.js +2 -0
  23. package/dist/commercetools/types/payment.type.d.ts +4 -1
  24. package/dist/custom-types/index.d.ts +4 -0
  25. package/dist/custom-types/index.js +20 -0
  26. package/dist/custom-types/payment-interface-interactions.d.ts +11 -0
  27. package/dist/custom-types/payment-interface-interactions.js +78 -0
  28. package/dist/custom-types/payment-methods/card.d.ts +12 -0
  29. package/dist/custom-types/payment-methods/card.js +75 -0
  30. package/dist/custom-types/payment-methods/sepa.d.ts +8 -0
  31. package/dist/custom-types/payment-methods/sepa.js +35 -0
  32. package/dist/custom-types/payment-methods/shared.d.ts +2 -0
  33. package/dist/custom-types/payment-methods/shared.js +13 -0
  34. package/dist/errorx/errorx.d.ts +2 -0
  35. package/dist/errorx/errorx.js +4 -0
  36. package/dist/index.d.ts +5 -0
  37. package/dist/index.js +7 -0
  38. package/dist/security/authn/types/authn.type.d.ts +4 -0
  39. package/package.json +4 -4
@@ -64,9 +64,36 @@ class DefaultPaymentService {
64
64
  if (!payment.interfaceId && updateInfo.pspReference) {
65
65
  actions.push(this.populateSetInterfaceIdAction(updateInfo.pspReference));
66
66
  }
67
+ /**
68
+ * old way
69
+ */
67
70
  if (!payment.paymentMethodInfo?.method && updateInfo.paymentMethod) {
68
71
  actions.push(this.populateSetPaymentMethod(updateInfo.paymentMethod));
69
72
  }
73
+ if (!payment.paymentMethodInfo?.token && updateInfo.token) {
74
+ actions.push(this.populateSetMethodInfoToken(updateInfo.token));
75
+ }
76
+ /**
77
+ * New way
78
+ */
79
+ if (!payment.paymentMethodInfo?.method && updateInfo.paymentMethodInfo?.method) {
80
+ actions.push(this.populateSetPaymentMethod(updateInfo.paymentMethodInfo.method));
81
+ }
82
+ if (!payment.paymentMethodInfo?.token && updateInfo.paymentMethodInfo?.token?.value) {
83
+ actions.push(this.populateSetMethodInfoToken(updateInfo.paymentMethodInfo.token.value));
84
+ }
85
+ if (!payment.paymentMethodInfo?.name && updateInfo.paymentMethodInfo?.name) {
86
+ actions.push(this.populateSetMethodInfoName(updateInfo.paymentMethodInfo.name));
87
+ }
88
+ if (!payment.paymentMethodInfo?.paymentInterface && updateInfo.paymentMethodInfo?.paymentInterface) {
89
+ actions.push(this.populateSetMethodInfoInterface(updateInfo.paymentMethodInfo.paymentInterface));
90
+ }
91
+ if (!payment.paymentMethodInfo?.interfaceAccount && updateInfo.paymentMethodInfo?.interfaceAccount) {
92
+ actions.push(this.populateSetMethodInfoInterfaceAccount(updateInfo.paymentMethodInfo.interfaceAccount));
93
+ }
94
+ if (updateInfo.paymentMethodInfo?.custom) {
95
+ actions.push(this.populateSetMethodInfoCustomType(updateInfo.paymentMethodInfo.custom));
96
+ }
70
97
  if (updateInfo.transaction) {
71
98
  const transactionChanges = this.consolidateTransactionChanges(payment, updateInfo.transaction);
72
99
  if (transactionChanges.length > 0) {
@@ -94,6 +121,13 @@ class DefaultPaymentService {
94
121
  interactionId,
95
122
  };
96
123
  }
124
+ populateSetTransactionInterfaceId(txId, interfaceId) {
125
+ return {
126
+ action: 'setTransactionInterfaceId',
127
+ transactionId: txId,
128
+ interfaceId,
129
+ }; // TypeScript does not have this action in the SDK yet
130
+ }
97
131
  populateAddTransactionAction(draft) {
98
132
  return {
99
133
  action: 'addTransaction',
@@ -116,6 +150,45 @@ class DefaultPaymentService {
116
150
  method: paymentMethod,
117
151
  };
118
152
  }
153
+ populateSetMethodInfoToken(token) {
154
+ return {
155
+ action: 'setMethodInfoToken',
156
+ token: {
157
+ value: token,
158
+ },
159
+ };
160
+ }
161
+ populateSetMethodInfoInterface(paymentInterface) {
162
+ return {
163
+ action: 'setMethodInfoInterface',
164
+ interface: paymentInterface,
165
+ };
166
+ }
167
+ populateSetMethodInfoName(name) {
168
+ return {
169
+ action: 'setMethodInfoName',
170
+ name,
171
+ };
172
+ }
173
+ populateSetMethodInfoInterfaceAccount(interfaceAccount) {
174
+ return {
175
+ action: 'setMethodInfoInterfaceAccount',
176
+ interfaceAccount,
177
+ };
178
+ }
179
+ populateSetMethodInfoCustomType(customType) {
180
+ return {
181
+ action: 'setMethodInfoCustomType',
182
+ ...customType,
183
+ };
184
+ }
185
+ populateSetMethodInfoCustomField(name, value) {
186
+ return {
187
+ action: 'setMethodInfoCustomField',
188
+ name,
189
+ value,
190
+ };
191
+ }
119
192
  populateSetCustomType(customFields) {
120
193
  return {
121
194
  action: 'setCustomType',
@@ -132,13 +205,28 @@ class DefaultPaymentService {
132
205
  }
133
206
  findMatchingTransactions(payment, transaction) {
134
207
  return payment.transactions.filter((tx) => {
135
- return (tx.type === transaction.type &&
136
- transaction.interactionId &&
137
- (tx.interactionId === transaction.interactionId ||
138
- (tx.amount.centAmount === transaction.amount.centAmount &&
139
- tx.amount.currencyCode === transaction.amount.currencyCode &&
140
- !tx.interactionId &&
141
- tx.state === 'Initial')));
208
+ // Must match transaction type
209
+ if (tx.type !== transaction.type) {
210
+ return false;
211
+ }
212
+ // New transaction must have at least one PSP identifier. InteractionId is for retro compatibility.
213
+ if (!transaction.interactionId && !transaction.interfaceId) {
214
+ return false;
215
+ }
216
+ // Match by interactionId
217
+ if (transaction.interactionId && tx.interactionId === transaction.interactionId) {
218
+ return true;
219
+ }
220
+ // Match by interfaceId
221
+ if (transaction.interfaceId && tx.interfaceId === transaction.interfaceId) {
222
+ return true;
223
+ }
224
+ // Match Initial transactions missing at least one ID by amount
225
+ // This allows reusing an Initial transaction when we get a PSP response with an ID
226
+ const isInitialMissingIds = tx.state === 'Initial' && (!tx.interactionId || !tx.interfaceId);
227
+ const hasMatchingAmount = tx.amount.centAmount === transaction.amount.centAmount &&
228
+ tx.amount.currencyCode === transaction.amount.currencyCode;
229
+ return isInitialMissingIds && hasMatchingAmount;
142
230
  });
143
231
  }
144
232
  hasTransactionInState(opts) {
@@ -176,6 +264,9 @@ class DefaultPaymentService {
176
264
  if (this.shouldUpdateInteractionId(existingTx, newTransaction)) {
177
265
  actions.push(this.populateChangeTransactionInteractionId(existingTx.id, newTransaction.interactionId));
178
266
  }
267
+ if (this.shouldUpdateTransactionInterfaceId(existingTx, newTransaction)) {
268
+ actions.push(this.populateSetTransactionInterfaceId(existingTx.id, newTransaction.interfaceId));
269
+ }
179
270
  }
180
271
  shouldUpdateTransactionState(existingTx, newTransaction) {
181
272
  const { state: currentState } = existingTx;
@@ -192,6 +283,9 @@ class DefaultPaymentService {
192
283
  shouldUpdateInteractionId(existingTx, newTransaction) {
193
284
  return !existingTx.interactionId && !!newTransaction.interactionId;
194
285
  }
286
+ shouldUpdateTransactionInterfaceId(existingTx, newTransaction) {
287
+ return !existingTx.interfaceId && !!newTransaction.interfaceId;
288
+ }
195
289
  throwMultipleMatchingTransactionsError(payment, newTransaction, matchingTxs) {
196
290
  this.logger.error({
197
291
  paymentId: payment.id,
@@ -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, Type, TypeDraft, TypeUpdate } 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,11 +55,27 @@ 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
  }
69
+ export interface CustomTypeAPI {
70
+ getByKey(key: string): Promise<Type>;
71
+ existsByKey(key: string): Promise<boolean>;
72
+ create(draft: TypeDraft): Promise<Type>;
73
+ update(key: string, update: TypeUpdate): Promise<Type>;
74
+ }
44
75
  export interface CommercetoolsAPI {
45
76
  cart: CartAPI;
46
77
  payment: PaymentAPI;
47
78
  order: OrderAPI;
79
+ paymentMethod: PaymentMethodAPI;
80
+ customType: CustomTypeAPI;
48
81
  }
@@ -0,0 +1,20 @@
1
+ import { Type, TypeDraft, TypeUpdate } from '@commercetools/platform-sdk';
2
+ export type GetByKeyCustomType = {
3
+ key: string;
4
+ };
5
+ export type ExistsByKeyCustomType = {
6
+ key: string;
7
+ };
8
+ export type UpdateCustomType = {
9
+ key: string;
10
+ updateActions: TypeUpdate;
11
+ };
12
+ export interface CustomTypeService {
13
+ getByKey(opts: GetByKeyCustomType): Promise<Type>;
14
+ existsByKey(opts: GetByKeyCustomType): Promise<boolean>;
15
+ create(draft: TypeDraft): Promise<Type>;
16
+ update(opts: UpdateCustomType): Promise<Type>;
17
+ createOrUpdate(customTypeDraft: TypeDraft): Promise<Type>;
18
+ createOrUpdatePredefinedPaymentMethodTypes(): Promise<Type[]>;
19
+ createOrUpdatePredefinedInterfaceInteractionType(): Promise<Type>;
20
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,109 @@
1
+ import { CommercetoolsAPI, UpdateResource } from './api.type';
2
+ import { Logger } from '../../logger';
3
+ import { CustomFieldsDraft, 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
+ customFields?: CustomFieldsDraft;
48
+ };
49
+ /**
50
+ * Payment methods service interface exposes methods to interact with the commercetools platform API.
51
+ */
52
+ export interface PaymentMethodService {
53
+ /**
54
+ * Finds all of the payment-methods that match with the given parameters.
55
+ *
56
+ * @param opts the parameters to search by
57
+ *
58
+ * @returns a paged list of payment-methods
59
+ */
60
+ find(opts: FindPaymentMethod): Promise<PaymentMethodPagedQueryResponse>;
61
+ /**
62
+ * Returns a payment-method by the given ID which must belong to the given customerId.
63
+ *
64
+ * @param opts
65
+ *
66
+ * @returns the payment-method
67
+ */
68
+ get(opts: GetPaymentMethod): Promise<PaymentMethod>;
69
+ /**
70
+ * Returns a payment-method by the given tokenValue which must belong to the given customerId and must be unique.
71
+ *
72
+ * @param opts
73
+ *
74
+ * @returns the payment-method
75
+ */
76
+ getByTokenValue(opts: GetByTokenValuePaymentMethod): Promise<PaymentMethod>;
77
+ /**
78
+ * Returns true if the given token belongs to the given customer for any payment-method.
79
+ *
80
+ * @param opts
81
+ *
82
+ * @returns true if the given token belongs to the customer for any payment method, false otherwise.
83
+ */
84
+ doesTokenBelongsToCustomer(opts: DoesTokenBelongToCustomer): Promise<boolean>;
85
+ /**
86
+ * Saves a new payment-method given the draft payload. The customer attribute is mandatory.
87
+ *
88
+ * @param opts the payment-method draft
89
+ *
90
+ * @returns the newly created payment-method
91
+ */
92
+ save(opts: SavePaymentMethodDraft): Promise<PaymentMethod>;
93
+ /**
94
+ * Updates an existing payment-method with the given list of update actions. The payment-method must belong to the given customerId.
95
+ *
96
+ * @param opts the list of update actions to apply
97
+ *
98
+ * @returns the updated payment-method
99
+ */
100
+ update(opts: UpdatePaymentMethod): Promise<PaymentMethod>;
101
+ /**
102
+ * Deletes the given payment-method
103
+ *
104
+ * @param opts the payment-method to delete
105
+ *
106
+ * @returns returns the final state of the payment-method before it's deleted
107
+ */
108
+ delete(opts: DeletePaymentMethod): Promise<PaymentMethod>;
109
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,4 +1,4 @@
1
- import { CustomFieldsDraft, Money, Payment, PaymentDraft, TransactionState, TransactionType } from '@commercetools/platform-sdk';
1
+ import { CustomFieldsDraft, Money, Payment, PaymentDraft, PaymentMethodInfoDraft, TransactionState, TransactionType } from '@commercetools/platform-sdk';
2
2
  import { CommercetoolsAPI } from './api.type';
3
3
  import { Logger } from '../../logger';
4
4
  export type PaymentAmount = {
@@ -25,6 +25,7 @@ export type TransactionData = {
25
25
  type: TransactionType;
26
26
  amount: Money;
27
27
  interactionId?: string;
28
+ interfaceId?: string;
28
29
  state: TransactionState;
29
30
  };
30
31
  export type UpdatePayment = {
@@ -33,7 +34,9 @@ export type UpdatePayment = {
33
34
  pspInteractions?: CustomFieldsDraft[];
34
35
  transaction?: TransactionData;
35
36
  paymentMethod?: string;
37
+ paymentMethodInfo?: PaymentMethodInfoDraft;
36
38
  customFields?: CustomFieldsDraft;
39
+ token?: string;
37
40
  };
38
41
  export type FindTransaction = {
39
42
  payment: Payment;
@@ -0,0 +1,4 @@
1
+ export * from './payment-methods/card';
2
+ export * from './payment-methods/sepa';
3
+ export * from './payment-methods/shared';
4
+ export * from './payment-interface-interactions';
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./payment-methods/card"), exports);
18
+ __exportStar(require("./payment-methods/sepa"), exports);
19
+ __exportStar(require("./payment-methods/shared"), exports);
20
+ __exportStar(require("./payment-interface-interactions"), exports);
@@ -0,0 +1,11 @@
1
+ import { CustomFieldsDraft, TypeDraft } from '@commercetools/platform-sdk';
2
+ export declare const PaymentInterfaceInteractionTypeKey = "commercetools-checkout-payment-interface-interaction";
3
+ export declare const PaymentInterfaceInteractionTypeDraft: TypeDraft;
4
+ export type InterfaceInteractionFields = {
5
+ interactionId: string;
6
+ createdAt: string;
7
+ request?: string;
8
+ response?: string;
9
+ type: string;
10
+ };
11
+ export declare const GenerateInterfaceInteractionCustomFieldsDraft: (fields: InterfaceInteractionFields) => CustomFieldsDraft;
@@ -0,0 +1,78 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GenerateInterfaceInteractionCustomFieldsDraft = exports.PaymentInterfaceInteractionTypeDraft = exports.PaymentInterfaceInteractionTypeKey = void 0;
4
+ exports.PaymentInterfaceInteractionTypeKey = 'commercetools-checkout-payment-interface-interaction';
5
+ exports.PaymentInterfaceInteractionTypeDraft = {
6
+ key: exports.PaymentInterfaceInteractionTypeKey,
7
+ name: {
8
+ en: 'commercetools Checkout Payment Interface Interaction Type',
9
+ },
10
+ resourceTypeIds: ['payment-interface-interaction'],
11
+ fieldDefinitions: [
12
+ {
13
+ name: 'interactionId',
14
+ label: {
15
+ en: 'Interaction ID',
16
+ },
17
+ required: true,
18
+ type: {
19
+ name: 'String',
20
+ },
21
+ inputHint: 'SingleLine',
22
+ },
23
+ {
24
+ name: 'createdAt',
25
+ label: {
26
+ en: 'Created At',
27
+ },
28
+ required: true,
29
+ type: {
30
+ name: 'DateTime',
31
+ },
32
+ inputHint: 'SingleLine',
33
+ },
34
+ {
35
+ name: 'request',
36
+ label: {
37
+ en: 'Request',
38
+ },
39
+ required: false,
40
+ type: {
41
+ name: 'String',
42
+ },
43
+ inputHint: 'MultiLine',
44
+ },
45
+ {
46
+ name: 'response',
47
+ label: {
48
+ en: 'Response',
49
+ },
50
+ required: false,
51
+ type: {
52
+ name: 'String',
53
+ },
54
+ inputHint: 'MultiLine',
55
+ },
56
+ {
57
+ name: 'type',
58
+ label: {
59
+ en: 'Type',
60
+ },
61
+ required: true,
62
+ type: {
63
+ name: 'String',
64
+ },
65
+ inputHint: 'SingleLine',
66
+ },
67
+ ],
68
+ };
69
+ const GenerateInterfaceInteractionCustomFieldsDraft = (fields) => {
70
+ return {
71
+ type: {
72
+ key: exports.PaymentInterfaceInteractionTypeKey,
73
+ typeId: 'type',
74
+ },
75
+ fields: fields,
76
+ };
77
+ };
78
+ exports.GenerateInterfaceInteractionCustomFieldsDraft = GenerateInterfaceInteractionCustomFieldsDraft;
@@ -0,0 +1,12 @@
1
+ import { CustomFieldsDraft, TypeDraft } from '@commercetools/platform-sdk';
2
+ export declare const CardDetailsTypeKey = "commercetools-checkout-card-details";
3
+ export declare const CardDetailsTypeDraft: TypeDraft;
4
+ export type CardDetailsFields = {
5
+ brand?: string;
6
+ lastFour?: string;
7
+ bin?: string;
8
+ expiryMonth?: number;
9
+ expiryYear?: number;
10
+ storePaymentMethod?: boolean;
11
+ };
12
+ export declare const GenerateCardDetailsCustomFieldsDraft: (fields: CardDetailsFields) => CustomFieldsDraft;
@@ -0,0 +1,75 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GenerateCardDetailsCustomFieldsDraft = exports.CardDetailsTypeDraft = exports.CardDetailsTypeKey = void 0;
4
+ const shared_1 = require("./shared");
5
+ exports.CardDetailsTypeKey = 'commercetools-checkout-card-details';
6
+ exports.CardDetailsTypeDraft = {
7
+ key: exports.CardDetailsTypeKey,
8
+ name: {
9
+ en: 'Card payment details',
10
+ },
11
+ resourceTypeIds: ['payment-method-info', 'payment-method'],
12
+ fieldDefinitions: [
13
+ {
14
+ name: 'brand',
15
+ label: {
16
+ en: 'Card Brand',
17
+ },
18
+ type: {
19
+ name: 'String',
20
+ },
21
+ required: false,
22
+ },
23
+ {
24
+ name: 'lastFour',
25
+ label: {
26
+ en: 'Last four digits of the card',
27
+ },
28
+ type: {
29
+ name: 'String',
30
+ },
31
+ required: false,
32
+ },
33
+ {
34
+ name: 'bin',
35
+ label: {
36
+ en: 'Card BIN',
37
+ },
38
+ type: {
39
+ name: 'String',
40
+ },
41
+ required: false,
42
+ },
43
+ {
44
+ name: 'expiryMonth',
45
+ label: {
46
+ en: 'Expiry Month',
47
+ },
48
+ type: {
49
+ name: 'Number',
50
+ },
51
+ required: false,
52
+ },
53
+ {
54
+ name: 'expiryYear',
55
+ label: {
56
+ en: 'Expiry Year',
57
+ },
58
+ type: {
59
+ name: 'Number',
60
+ },
61
+ required: false,
62
+ },
63
+ shared_1.StorePaymentMethodFieldDefinition,
64
+ ],
65
+ };
66
+ const GenerateCardDetailsCustomFieldsDraft = (fields) => {
67
+ return {
68
+ type: {
69
+ key: exports.CardDetailsTypeKey,
70
+ typeId: 'type',
71
+ },
72
+ fields: fields,
73
+ };
74
+ };
75
+ exports.GenerateCardDetailsCustomFieldsDraft = GenerateCardDetailsCustomFieldsDraft;
@@ -0,0 +1,8 @@
1
+ import { CustomFieldsDraft, TypeDraft } from '@commercetools/platform-sdk';
2
+ export declare const SepaDetailsTypeKey = "commercetools-checkout-sepa-details";
3
+ export declare const SepaDetailsTypeDraft: TypeDraft;
4
+ export type SepaDetailsFields = {
5
+ lastFour?: string;
6
+ storePaymentMethod?: boolean;
7
+ };
8
+ export declare const GenerateSepaDetailsCustomFieldsDraft: (fields: SepaDetailsFields) => CustomFieldsDraft;
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GenerateSepaDetailsCustomFieldsDraft = exports.SepaDetailsTypeDraft = exports.SepaDetailsTypeKey = void 0;
4
+ const shared_1 = require("./shared");
5
+ exports.SepaDetailsTypeKey = 'commercetools-checkout-sepa-details';
6
+ exports.SepaDetailsTypeDraft = {
7
+ key: exports.SepaDetailsTypeKey,
8
+ name: {
9
+ en: 'SEPA Direct Debit details',
10
+ },
11
+ resourceTypeIds: ['payment-method-info', 'payment-method'],
12
+ fieldDefinitions: [
13
+ {
14
+ name: 'lastFour',
15
+ label: {
16
+ en: 'Last four digits of IBAN',
17
+ },
18
+ type: {
19
+ name: 'String',
20
+ },
21
+ required: false,
22
+ },
23
+ shared_1.StorePaymentMethodFieldDefinition,
24
+ ],
25
+ };
26
+ const GenerateSepaDetailsCustomFieldsDraft = (fields) => {
27
+ return {
28
+ type: {
29
+ key: exports.SepaDetailsTypeKey,
30
+ typeId: 'type',
31
+ },
32
+ fields: fields,
33
+ };
34
+ };
35
+ exports.GenerateSepaDetailsCustomFieldsDraft = GenerateSepaDetailsCustomFieldsDraft;
@@ -0,0 +1,2 @@
1
+ import { FieldDefinition } from '@commercetools/platform-sdk';
2
+ export declare const StorePaymentMethodFieldDefinition: FieldDefinition;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.StorePaymentMethodFieldDefinition = void 0;
4
+ exports.StorePaymentMethodFieldDefinition = {
5
+ name: 'storePaymentMethod',
6
+ label: {
7
+ en: 'Store the payment method',
8
+ },
9
+ type: {
10
+ name: 'Boolean',
11
+ },
12
+ required: false,
13
+ };
@@ -9,6 +9,7 @@ export type ErrorxBaseOpts = {
9
9
  message: string;
10
10
  code: string;
11
11
  httpErrorStatus: number;
12
+ detailedErrorMessage?: string;
12
13
  };
13
14
  export type ErrorxOpts = ErrorxBaseOpts & ErrorxAdditionalOpts;
14
15
  /**
@@ -18,6 +19,7 @@ export declare class Errorx extends Error {
18
19
  code: string;
19
20
  httpErrorStatus: number;
20
21
  cause?: Error | unknown;
22
+ detailedErrorMessage?: string;
21
23
  privateFields?: object;
22
24
  privateMessage?: string;
23
25
  fields?: object;
@@ -8,6 +8,7 @@ class Errorx extends Error {
8
8
  code;
9
9
  httpErrorStatus;
10
10
  cause;
11
+ detailedErrorMessage;
11
12
  privateFields;
12
13
  privateMessage;
13
14
  fields;
@@ -20,6 +21,9 @@ class Errorx extends Error {
20
21
  if (opts.cause) {
21
22
  this.cause = opts.cause;
22
23
  }
24
+ if (opts.detailedErrorMessage) {
25
+ this.detailedErrorMessage = opts.detailedErrorMessage;
26
+ }
23
27
  if (opts.privateFields) {
24
28
  this.privateFields = opts.privateFields;
25
29
  }