@commercetools/checkout-sdk 1.0.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 (58) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/README.md +172 -0
  3. package/dist/commercetools-checkout-sdk.browser.cjs.js +499 -0
  4. package/dist/commercetools-checkout-sdk.browser.esm.js +481 -0
  5. package/dist/commercetools-checkout-sdk.cjs.d.ts +2 -0
  6. package/dist/commercetools-checkout-sdk.cjs.dev.js +499 -0
  7. package/dist/commercetools-checkout-sdk.cjs.js +7 -0
  8. package/dist/commercetools-checkout-sdk.cjs.prod.js +499 -0
  9. package/dist/commercetools-checkout-sdk.esm.js +481 -0
  10. package/dist/declarations/src/ctp/ctp-client.d.ts +3 -0
  11. package/dist/declarations/src/ctp/ctp-client.d.ts.map +1 -0
  12. package/dist/declarations/src/generated/client/api-root.d.ts +19 -0
  13. package/dist/declarations/src/generated/client/api-root.d.ts.map +1 -0
  14. package/dist/declarations/src/generated/client/by-project-key-request-builder.d.ts +29 -0
  15. package/dist/declarations/src/generated/client/by-project-key-request-builder.d.ts.map +1 -0
  16. package/dist/declarations/src/generated/client/payment-intents/by-project-key-payment-intents-by-payment-id-request-builder.d.ts +42 -0
  17. package/dist/declarations/src/generated/client/payment-intents/by-project-key-payment-intents-by-payment-id-request-builder.d.ts.map +1 -0
  18. package/dist/declarations/src/generated/client/payment-intents/by-project-key-payment-intents-request-builder.d.ts +29 -0
  19. package/dist/declarations/src/generated/client/payment-intents/by-project-key-payment-intents-request-builder.d.ts.map +1 -0
  20. package/dist/declarations/src/generated/client/transactions/by-project-key-transactions-by-id-request-builder.d.ts +40 -0
  21. package/dist/declarations/src/generated/client/transactions/by-project-key-transactions-by-id-request-builder.d.ts.map +1 -0
  22. package/dist/declarations/src/generated/client/transactions/by-project-key-transactions-key-by-key-request-builder.d.ts +40 -0
  23. package/dist/declarations/src/generated/client/transactions/by-project-key-transactions-key-by-key-request-builder.d.ts.map +1 -0
  24. package/dist/declarations/src/generated/client/transactions/by-project-key-transactions-request-builder.d.ts +50 -0
  25. package/dist/declarations/src/generated/client/transactions/by-project-key-transactions-request-builder.d.ts.map +1 -0
  26. package/dist/declarations/src/generated/index.d.ts +27 -0
  27. package/dist/declarations/src/generated/index.d.ts.map +1 -0
  28. package/dist/declarations/src/generated/models/application.d.ts +39 -0
  29. package/dist/declarations/src/generated/models/application.d.ts.map +1 -0
  30. package/dist/declarations/src/generated/models/cart.d.ts +52 -0
  31. package/dist/declarations/src/generated/models/cart.d.ts.map +1 -0
  32. package/dist/declarations/src/generated/models/common.d.ts +100 -0
  33. package/dist/declarations/src/generated/models/common.d.ts.map +1 -0
  34. package/dist/declarations/src/generated/models/error.d.ts +144 -0
  35. package/dist/declarations/src/generated/models/error.d.ts.map +1 -0
  36. package/dist/declarations/src/generated/models/order.d.ts +26 -0
  37. package/dist/declarations/src/generated/models/order.d.ts.map +1 -0
  38. package/dist/declarations/src/generated/models/payment-integration.d.ts +39 -0
  39. package/dist/declarations/src/generated/models/payment-integration.d.ts.map +1 -0
  40. package/dist/declarations/src/generated/models/payment-intents.d.ts +111 -0
  41. package/dist/declarations/src/generated/models/payment-intents.d.ts.map +1 -0
  42. package/dist/declarations/src/generated/models/payment.d.ts +39 -0
  43. package/dist/declarations/src/generated/models/payment.d.ts.map +1 -0
  44. package/dist/declarations/src/generated/models/responses.d.ts +1647 -0
  45. package/dist/declarations/src/generated/models/responses.d.ts.map +1 -0
  46. package/dist/declarations/src/generated/models/transaction.d.ts +170 -0
  47. package/dist/declarations/src/generated/models/transaction.d.ts.map +1 -0
  48. package/dist/declarations/src/generated/shared/utils/common-types.d.ts +56 -0
  49. package/dist/declarations/src/generated/shared/utils/common-types.d.ts.map +1 -0
  50. package/dist/declarations/src/generated/shared/utils/middleware.d.ts +9 -0
  51. package/dist/declarations/src/generated/shared/utils/middleware.d.ts.map +1 -0
  52. package/dist/declarations/src/generated/shared/utils/requests-utils.d.ts +14 -0
  53. package/dist/declarations/src/generated/shared/utils/requests-utils.d.ts.map +1 -0
  54. package/dist/declarations/src/generated/shared/utils/uri-utils.d.ts +8 -0
  55. package/dist/declarations/src/generated/shared/utils/uri-utils.d.ts.map +1 -0
  56. package/dist/declarations/src/index.d.ts +3 -0
  57. package/dist/declarations/src/index.d.ts.map +1 -0
  58. package/package.json +48 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,7 @@
1
+ # @commercetools/checkout-sdk
2
+
3
+ ## 1.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - [#1174](https://github.com/commercetools/commercetools-sdk-typescript/pull/1174) [`b054dbb`](https://github.com/commercetools/commercetools-sdk-typescript/commit/b054dbb195bea7bb19b52e3cbe70afe65bfe5010) Thanks [@ajimae](https://github.com/ajimae)! - [Feat][DEVX-630] Add Checkout API
package/README.md ADDED
@@ -0,0 +1,172 @@
1
+ # Typescript SDK for Composable Commerce Checkout APIs.
2
+
3
+ ## Usage examples
4
+
5
+ ### Browser environment
6
+
7
+ ```html
8
+ <script src="https://unpkg.com/@commercetools/ts-client@latest/dist/commercetools-sdk-client-v3.umd.js"></script>
9
+ <script src="https://unpkg.com/@commercetools/checkout-sdk@latest/dist/commercetools-checkout-sdk.umd.js"></script>
10
+ ```
11
+
12
+ ```html
13
+ <script>
14
+ // global: @commercetools/ts-client
15
+ // global: @commercetools/checkout-sdk
16
+ ;(function () {
17
+ // We can now access the ts-client and checkout-sdk object as:
18
+ // const { ClientBuilder } = this['@commercetools/ts-client']
19
+ // const { createApiBuilderFromCtpClient } = this['@commercetools/checkout-sdk']
20
+ // or
21
+ // const { ClientBuilder } = window['@commercetools/ts-client']
22
+ // const { createApiBuilderFromCtpClient } = window['@commercetools/checkout-sdk']
23
+ })()
24
+ </script>
25
+ ```
26
+
27
+ ### Node environment
28
+
29
+ ```bash
30
+ npm install --save @commercetools/ts-client
31
+ npm install --save @commercetools/checkout-sdk
32
+ ```
33
+
34
+ ```ts
35
+ const {
36
+ ClientBuilder,
37
+ createAuthForClientCredentialsFlow,
38
+ createHttpClient,
39
+ } = require('@commercetools/ts-client')
40
+ const { createApiBuilderFromCtpClient } = require('@commercetools/checkout-sdk')
41
+
42
+ const projectKey = 'mc-project-key'
43
+ const authMiddlewareOptions = {
44
+ host: 'https://auth.europe-west1.gcp.commercetools.com',
45
+ projectKey,
46
+ credentials: {
47
+ clientId: 'mc-client-id',
48
+ clientSecret: 'mc-client-secrets',
49
+ },
50
+ oauthUri: '/oauth/token', // - optional: custom oauthUri
51
+ scopes: [`manage_project:${projectKey}`],
52
+ fetch,
53
+ }
54
+
55
+ const httpMiddlewareOptions = {
56
+ host: 'https://checkout.europe-west1.gcp.commercetools.com',
57
+ fetch,
58
+ }
59
+
60
+ const client = new ClientBuilder()
61
+ .withProjectKey(projectKey)
62
+ .withMiddleware(createAuthForClientCredentialsFlow(authMiddlewareOptions))
63
+ .withMiddleware(createHttpClient(httpMiddlewareOptions))
64
+ .withUserAgentMiddleware()
65
+ .build()
66
+
67
+ // or
68
+ const client = new ClientBuilder()
69
+ .withProjectKey(projectKey)
70
+ .withClientCredentialsFlow(authMiddlewareOptions)
71
+ .withHttpMiddleware(httpMiddlewareOptions)
72
+ .withUserAgentMiddleware()
73
+ .build()
74
+
75
+ const apiRoot = createApiBuilderFromCtpClient(client)
76
+
77
+ // calling the checkout-sdk functions
78
+ // create a new transaction using the checkout sdk
79
+ apiRoot
80
+ .withProjectKey({ projectKey })
81
+ .transactions()
82
+ .post({
83
+ body: {
84
+ application: {
85
+ typeId: 'application',
86
+ key: 'checkout-application-key',
87
+ },
88
+ transactionItems: [
89
+ {
90
+ paymentIntegration: {
91
+ typeId: 'payment-integration',
92
+ id: 'payment-integration-id',
93
+ },
94
+ amount: {
95
+ centAmount: 1000,
96
+ currencyCode: 'EUR',
97
+ },
98
+ },
99
+ ],
100
+ cart: {
101
+ typeId: 'cart',
102
+ id: 'cart-id',
103
+ },
104
+ },
105
+ })
106
+ .execute()
107
+ .then(...)
108
+ .catch(...)
109
+
110
+ -----------------------------------------------------------------------
111
+ // The ts-client also has support for the old syntax
112
+ import {
113
+ createClient,
114
+ createHttpClient,
115
+ createAuthForClientCredentialsFlow,
116
+ } from '@commercetools/ts-client'
117
+ import { createApiBuilderFromCtpClient } from '@commercetools/checkout-sdk'
118
+
119
+ const projectKey = 'some_project_key'
120
+
121
+ const authMiddleware = createAuthForClientCredentialsFlow({
122
+ host: 'https://auth.europe-west1.gcp.commercetools.com',
123
+ projectKey,
124
+ credentials: {
125
+ clientId: 'some_id',
126
+ clientSecret: 'some_secret',
127
+ },
128
+ httpClient: fetch,
129
+ })
130
+
131
+ const httpMiddleware = createHttpClient({
132
+ host: 'https://checkout.europe-west1.gcp.commercetools.com',
133
+ httpClient: fetch,
134
+ })
135
+
136
+ const ctpClient = createClient({
137
+ middlewares: [authMiddleware, httpMiddleware],
138
+ })
139
+
140
+ const apiRoot = createApiBuilderFromCtpClient(ctpClient)
141
+
142
+ apiRoot
143
+ .withProjectKey({ projectKey })
144
+ .transactions()
145
+ .post({
146
+ body: {
147
+ application: {
148
+ typeId: 'application',
149
+ key: 'checkout-application-key',
150
+ },
151
+ transactionItems: [
152
+ {
153
+ paymentIntegration: {
154
+ typeId: 'payment-integration',
155
+ id: 'payment-integration-id',
156
+ },
157
+ amount: {
158
+ centAmount: 1000,
159
+ currencyCode: 'EUR',
160
+ },
161
+ },
162
+ ],
163
+ cart: {
164
+ typeId: 'cart',
165
+ id: 'cart-id',
166
+ },
167
+ },
168
+ })
169
+ .execute()
170
+ .then(...)
171
+ .catch(...)
172
+ ```
@@ -0,0 +1,499 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ function _toPrimitive(t, r) {
6
+ if ("object" != typeof t || !t) return t;
7
+ var e = t[Symbol.toPrimitive];
8
+ if (void 0 !== e) {
9
+ var i = e.call(t, r || "default");
10
+ if ("object" != typeof i) return i;
11
+ throw new TypeError("@@toPrimitive must return a primitive value.");
12
+ }
13
+ return ("string" === r ? String : Number)(t);
14
+ }
15
+
16
+ function _toPropertyKey(t) {
17
+ var i = _toPrimitive(t, "string");
18
+ return "symbol" == typeof i ? i : i + "";
19
+ }
20
+
21
+ function _defineProperty(e, r, t) {
22
+ return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
23
+ value: t,
24
+ enumerable: !0,
25
+ configurable: !0,
26
+ writable: !0
27
+ }) : e[r] = t, e;
28
+ }
29
+
30
+ /**
31
+ * Code generated by [commercetools RMF-Codegen](https://github.com/commercetools/rmf-codegen). DO NOT EDIT.
32
+ * Please don't change this file manually but run `rmf-codegen generate <raml_file_path> -o <output_path> -t typescript_client` to update it.
33
+ * For more information about the commercetools platform APIs, visit https://docs.commercetools.com/.
34
+ */
35
+
36
+ function isDefined(value) {
37
+ return typeof value !== 'undefined' && value !== null;
38
+ }
39
+ function stringify(object) {
40
+ const params = new URLSearchParams(object);
41
+ for (const [key, value] of Object.entries(object)) {
42
+ if (Array.isArray(value)) {
43
+ params.delete(key);
44
+ value.filter(Boolean).forEach(v => params.append(key, v));
45
+ }
46
+ }
47
+ return params.toString();
48
+ }
49
+ function cleanObject(obj) {
50
+ return Object.keys(obj).reduce((result, key) => {
51
+ const value = obj[key];
52
+ if (Array.isArray(value)) {
53
+ const values = value.filter(isDefined);
54
+ if (!values.length) {
55
+ return result;
56
+ }
57
+ return {
58
+ ...result,
59
+ [key]: values
60
+ };
61
+ }
62
+ if (isDefined(value)) {
63
+ return {
64
+ ...result,
65
+ [key]: value
66
+ };
67
+ }
68
+ return result;
69
+ }, {});
70
+ }
71
+ function formatQueryString(variableMap) {
72
+ const map = cleanObject(variableMap);
73
+ const result = stringify(map);
74
+ if (result === '') {
75
+ return '';
76
+ }
77
+ return `?${result}`;
78
+ }
79
+ function buildRelativeUri(commonRequest) {
80
+ const pathMap = commonRequest.pathVariables;
81
+ var uri = commonRequest.uriTemplate;
82
+ for (const param in pathMap) {
83
+ const value = encodeURIComponent(`${pathMap[param]}`);
84
+ uri = uri.replace(`{${param}}`, `${value}`);
85
+ }
86
+ const resQuery = formatQueryString(commonRequest.queryParams || {});
87
+ return `${uri}${resQuery}`;
88
+ }
89
+
90
+ class ApiRequest {
91
+ constructor(request, requestExecutor) {
92
+ this.requestExecutor = requestExecutor;
93
+ _defineProperty(this, "request", void 0);
94
+ this.request = {
95
+ ...request,
96
+ uri: buildRelativeUri(request)
97
+ };
98
+ }
99
+ clientRequest() {
100
+ return this.request;
101
+ }
102
+ execute() {
103
+ return this.requestExecutor(this.request);
104
+ }
105
+ }
106
+
107
+ /**
108
+ * Code generated by [commercetools RMF-Codegen](https://github.com/commercetools/rmf-codegen). DO NOT EDIT.
109
+ * Please don't change this file manually but run `rmf-codegen generate raml_file_path -o output_path -t typescript_client` to update it.
110
+ * For more information about the commercetools platform APIs, visit https://docs.commercetools.com/.
111
+ */
112
+ /**
113
+ **/
114
+ class ByProjectKeyPaymentIntentsByPaymentIdRequestBuilder {
115
+ constructor(args) {
116
+ this.args = args;
117
+ }
118
+ /**
119
+ * Specific Error Codes:
120
+ * - [MultipleActionsNotAllowed](ctp:checkout:type:MultipleActionsNotAllowedError)
121
+ * - [RequiredField](ctp:checkout:type:RequiredFieldError)
122
+ * - [ResourceNotFound](ctp:checkout:type:ResourceNotFoundError)
123
+ *
124
+ */
125
+ post(methodArgs) {
126
+ return new ApiRequest({
127
+ baseUri: this.args.baseUri,
128
+ method: 'POST',
129
+ uriTemplate: '/{projectKey}/payment-intents/{paymentId}',
130
+ pathVariables: this.args.pathArgs,
131
+ headers: {
132
+ 'Content-Type': 'application/json',
133
+ ...methodArgs?.headers
134
+ },
135
+ body: methodArgs?.body
136
+ }, this.args.executeRequest);
137
+ }
138
+ }
139
+
140
+ /**
141
+ * Code generated by [commercetools RMF-Codegen](https://github.com/commercetools/rmf-codegen). DO NOT EDIT.
142
+ * Please don't change this file manually but run `rmf-codegen generate raml_file_path -o output_path -t typescript_client` to update it.
143
+ * For more information about the commercetools platform APIs, visit https://docs.commercetools.com/.
144
+ */
145
+ /**
146
+ **/
147
+ class ByProjectKeyPaymentIntentsRequestBuilder {
148
+ constructor(args) {
149
+ this.args = args;
150
+ }
151
+ withPaymentId(childPathArgs) {
152
+ return new ByProjectKeyPaymentIntentsByPaymentIdRequestBuilder({
153
+ pathArgs: {
154
+ ...this.args.pathArgs,
155
+ ...childPathArgs
156
+ },
157
+ executeRequest: this.args.executeRequest,
158
+ baseUri: this.args.baseUri
159
+ });
160
+ }
161
+ }
162
+
163
+ /**
164
+ * Code generated by [commercetools RMF-Codegen](https://github.com/commercetools/rmf-codegen). DO NOT EDIT.
165
+ * Please don't change this file manually but run `rmf-codegen generate raml_file_path -o output_path -t typescript_client` to update it.
166
+ * For more information about the commercetools platform APIs, visit https://docs.commercetools.com/.
167
+ */
168
+ /**
169
+ **/
170
+ class ByProjectKeyTransactionsByIdRequestBuilder {
171
+ constructor(args) {
172
+ this.args = args;
173
+ }
174
+ /**
175
+ * Returns a Transaction with a given `id`. Specific Error Codes:
176
+ * - [ResourceNotFound](ctp:checkout:type:ResourceNotFoundError)
177
+ * - [GeneralError](ctp:checkout:type:GeneralError)
178
+ *
179
+ */
180
+ get(methodArgs) {
181
+ return new ApiRequest({
182
+ baseUri: this.args.baseUri,
183
+ method: 'GET',
184
+ uriTemplate: '/{projectKey}/transactions/{id}',
185
+ pathVariables: this.args.pathArgs,
186
+ headers: {
187
+ ...methodArgs?.headers
188
+ }
189
+ }, this.args.executeRequest);
190
+ }
191
+ }
192
+
193
+ /**
194
+ * Code generated by [commercetools RMF-Codegen](https://github.com/commercetools/rmf-codegen). DO NOT EDIT.
195
+ * Please don't change this file manually but run `rmf-codegen generate raml_file_path -o output_path -t typescript_client` to update it.
196
+ * For more information about the commercetools platform APIs, visit https://docs.commercetools.com/.
197
+ */
198
+ /**
199
+ **/
200
+ class ByProjectKeyTransactionsKeyByKeyRequestBuilder {
201
+ constructor(args) {
202
+ this.args = args;
203
+ }
204
+ /**
205
+ * Returns a Transaction with a given `key`. Specific Error Codes:
206
+ * - [ResourceNotFound](ctp:checkout:type:ResourceNotFoundError)
207
+ * - [GeneralError](ctp:checkout:type:GeneralError)
208
+ *
209
+ */
210
+ get(methodArgs) {
211
+ return new ApiRequest({
212
+ baseUri: this.args.baseUri,
213
+ method: 'GET',
214
+ uriTemplate: '/{projectKey}/transactions/key={key}',
215
+ pathVariables: this.args.pathArgs,
216
+ headers: {
217
+ ...methodArgs?.headers
218
+ }
219
+ }, this.args.executeRequest);
220
+ }
221
+ }
222
+
223
+ /**
224
+ * Code generated by [commercetools RMF-Codegen](https://github.com/commercetools/rmf-codegen). DO NOT EDIT.
225
+ * Please don't change this file manually but run `rmf-codegen generate raml_file_path -o output_path -t typescript_client` to update it.
226
+ * For more information about the commercetools platform APIs, visit https://docs.commercetools.com/.
227
+ */
228
+ /**
229
+ **/
230
+ class ByProjectKeyTransactionsRequestBuilder {
231
+ constructor(args) {
232
+ this.args = args;
233
+ }
234
+ withId(childPathArgs) {
235
+ return new ByProjectKeyTransactionsByIdRequestBuilder({
236
+ pathArgs: {
237
+ ...this.args.pathArgs,
238
+ ...childPathArgs
239
+ },
240
+ executeRequest: this.args.executeRequest,
241
+ baseUri: this.args.baseUri
242
+ });
243
+ }
244
+ withKey(childPathArgs) {
245
+ return new ByProjectKeyTransactionsKeyByKeyRequestBuilder({
246
+ pathArgs: {
247
+ ...this.args.pathArgs,
248
+ ...childPathArgs
249
+ },
250
+ executeRequest: this.args.executeRequest,
251
+ baseUri: this.args.baseUri
252
+ });
253
+ }
254
+
255
+ /**
256
+ * Creates a Transaction on Checkout. Specific Error Codes:
257
+ * - [InvalidInput](ctp:checkout:type:InvalidInputError)
258
+ * - [ResourceNotFound](ctp:checkout:type:ResourceNotFoundError)
259
+ * - [ConnectorFailed](ctp:checkout:type:ConnectorFailedError)
260
+ * - [PaymentFailure](ctp:checkout:type:PaymentFailureError)
261
+ * - [RequiredField](ctp:checkout:type:RequiredFieldError)
262
+ *
263
+ */
264
+ post(methodArgs) {
265
+ return new ApiRequest({
266
+ baseUri: this.args.baseUri,
267
+ method: 'POST',
268
+ uriTemplate: '/{projectKey}/transactions',
269
+ pathVariables: this.args.pathArgs,
270
+ headers: {
271
+ 'Content-Type': 'application/json',
272
+ ...methodArgs?.headers
273
+ },
274
+ body: methodArgs?.body
275
+ }, this.args.executeRequest);
276
+ }
277
+ }
278
+
279
+ /**
280
+ * Code generated by [commercetools RMF-Codegen](https://github.com/commercetools/rmf-codegen). DO NOT EDIT.
281
+ * Please don't change this file manually but run `rmf-codegen generate raml_file_path -o output_path -t typescript_client` to update it.
282
+ * For more information about the commercetools platform APIs, visit https://docs.commercetools.com/.
283
+ */
284
+ /**
285
+ **/
286
+ class ByProjectKeyRequestBuilder {
287
+ constructor(args) {
288
+ this.args = args;
289
+ }
290
+ paymentIntents() {
291
+ return new ByProjectKeyPaymentIntentsRequestBuilder({
292
+ pathArgs: {
293
+ ...this.args.pathArgs
294
+ },
295
+ executeRequest: this.args.executeRequest,
296
+ baseUri: this.args.baseUri
297
+ });
298
+ }
299
+ transactions() {
300
+ return new ByProjectKeyTransactionsRequestBuilder({
301
+ pathArgs: {
302
+ ...this.args.pathArgs
303
+ },
304
+ executeRequest: this.args.executeRequest,
305
+ baseUri: this.args.baseUri
306
+ });
307
+ }
308
+ }
309
+
310
+ class ApiRoot {
311
+ constructor(args) {
312
+ _defineProperty(this, "executeRequest", void 0);
313
+ _defineProperty(this, "baseUri", void 0);
314
+ this.executeRequest = args.executeRequest;
315
+ this.baseUri = args.baseUri || 'https://checkout.europe-west1.gcp.commercetools.com';
316
+ }
317
+ withProjectKey(childPathArgs) {
318
+ return new ByProjectKeyRequestBuilder({
319
+ pathArgs: {
320
+ ...childPathArgs
321
+ },
322
+ executeRequest: this.executeRequest,
323
+ baseUri: this.baseUri
324
+ });
325
+ }
326
+ }
327
+
328
+ /**
329
+ * Code generated by [commercetools RMF-Codegen](https://github.com/commercetools/rmf-codegen). DO NOT EDIT.
330
+ * Please don't change this file manually but run `rmf-codegen generate raml_file_path -o output_path -t typescript_client` to update it.
331
+ * For more information about the commercetools platform APIs, visit https://docs.commercetools.com/.
332
+ */
333
+
334
+ /**
335
+ * A Reference represents a loose reference to another resource in the same Project identified by its `id`. The `typeId` indicates the type of the referenced resource. Each resource type has its corresponding Reference type, like [ChannelReference](ctp:api:type:ChannelReference). A referenced resource can be embedded through [Reference Expansion](/general-concepts#reference-expansion). The expanded reference is the value of an additional `obj` field then.
336
+ *
337
+ */
338
+
339
+ /**
340
+ * Type of resource the value should reference. Supported resource type identifiers are:
341
+ *
342
+ */
343
+ let ReferenceTypeIdValues = /*#__PURE__*/function (ReferenceTypeIdValues) {
344
+ ReferenceTypeIdValues["Application"] = "application";
345
+ ReferenceTypeIdValues["Cart"] = "cart";
346
+ ReferenceTypeIdValues["Order"] = "order";
347
+ ReferenceTypeIdValues["Payment"] = "payment";
348
+ ReferenceTypeIdValues["PaymentIntegration"] = "payment-integration";
349
+ return ReferenceTypeIdValues;
350
+ }({});
351
+
352
+ /**
353
+ * Draft type to create a [Reference](ctp:api:type:Reference) or a [KeyReference](ctp:api:type:KeyReference) to a resource. Provide either the `id` or (wherever supported) the `key` of the resource to reference, but depending on the API endpoint the response returns either a Reference or a KeyReference. For example, the field `parent` of a [CategoryDraft](ctp:api:type:CategoryDraft) takes a ResourceIdentifier for its value while the value of the corresponding field of a [Category](ctp:api:type:Category) is a Reference.
354
+ *
355
+ * Each resource type has its corresponding ResourceIdentifier, like [ChannelResourceIdentifier](ctp:api:type:ChannelResourceIdentifier).
356
+ *
357
+ */
358
+
359
+ /**
360
+ * Money in cent amounts for a specific currency.
361
+ *
362
+ */
363
+
364
+ /**
365
+ * The Region in which the Checkout application is [hosted](/hosts-and-authorization).
366
+ *
367
+ */
368
+ let RegionValues = /*#__PURE__*/function (RegionValues) {
369
+ RegionValues["AustraliaSoutheast1Gcp"] = "australia-southeast1.gcp";
370
+ RegionValues["EuropeWest1Gcp"] = "europe-west1.gcp";
371
+ RegionValues["UsCentral1Gcp"] = "us-central1.gcp";
372
+ return RegionValues;
373
+ }({});
374
+
375
+ /**
376
+ * Code generated by [commercetools RMF-Codegen](https://github.com/commercetools/rmf-codegen). DO NOT EDIT.
377
+ * Please don't change this file manually but run `rmf-codegen generate raml_file_path -o output_path -t typescript_client` to update it.
378
+ * For more information about the commercetools platform APIs, visit https://docs.commercetools.com/.
379
+ */
380
+
381
+ /**
382
+ * Depending on the action specified, Checkout requests the [payment service provider](/connectors-and-applications#supported-psps-payment-integration-types-and-payment-methods) (PSP) or gift card management system to capture, refund, or cancel the authorization for the given Payment.
383
+ *
384
+ */
385
+
386
+ /**
387
+ * Requests to [cancel the authorization](/payments-lifecycle#authorization-cancellation) for a Payment. Checkout will cancel the [Payment](/../api/projects/payments#payment) and will request the PSP or gift card management system to proceed with the financial process to cancel the authorization.
388
+ *
389
+ * You cannot request to cancel the authorization for a Payment that has already been [captured](/payments-lifecycle#payment-capture).
390
+ *
391
+ */
392
+
393
+ /**
394
+ * Requests to [capture](/payments-lifecycle#payment-capture) the given amount from the customer. Checkout will request the PSP or gift card management system to proceed with the financial process to capture the amount.
395
+ *
396
+ */
397
+
398
+ /**
399
+ * The possible values for a [Payment Intent Action](ctp:checkout:type:PaymentIntentAction).
400
+ *
401
+ */
402
+ let PaymentIntentOperationValues = /*#__PURE__*/function (PaymentIntentOperationValues) {
403
+ PaymentIntentOperationValues["CancelPayment"] = "cancelPayment";
404
+ PaymentIntentOperationValues["CapturePayment"] = "capturePayment";
405
+ PaymentIntentOperationValues["RefundPayment"] = "refundPayment";
406
+ PaymentIntentOperationValues["ReversePayment"] = "reversePayment";
407
+ return PaymentIntentOperationValues;
408
+ }({});
409
+
410
+ /**
411
+ * Requests to [refund](/payments-lifecycle#refund) the given amount to the customer. Checkout will request the PSP or gift card management system to proceed with the financial process to refund the amount.
412
+ *
413
+ */
414
+
415
+ /**
416
+ * Requests to [reverse](/payment-integration-predicates) a [Payment](/../api/projects/payments#payment). Checkout reverses the Payment, and then requests the PSP or gift card management system to proceed with the relevant process to reverse the Payment.
417
+ *
418
+ */
419
+
420
+ /**
421
+ * Code generated by [commercetools RMF-Codegen](https://github.com/commercetools/rmf-codegen). DO NOT EDIT.
422
+ * Please don't change this file manually but run `rmf-codegen generate raml_file_path -o output_path -t typescript_client` to update it.
423
+ * For more information about the commercetools platform APIs, visit https://docs.commercetools.com/.
424
+ */
425
+
426
+ /**
427
+ * Information for the request to the [Connector](/connectors-and-applications#payment-connectors) to initiate the payment for a specific [Cart](/../api/projects/carts).
428
+ *
429
+ */
430
+
431
+ /**
432
+ * A single error on the [Transaction](/transactions-api#transaction). Multiple errors may be included in the [Transaction Status](/transactions-api#transactionstatus).
433
+ *
434
+ */
435
+
436
+ /**
437
+ * Payment information related to the [Transaction](/transactions-api#transaction).
438
+ *
439
+ */
440
+
441
+ /**
442
+ * The state of the [Transaction](/transactions-api#transaction).
443
+ *
444
+ */
445
+ let TransactionStateValues = /*#__PURE__*/function (TransactionStateValues) {
446
+ TransactionStateValues["Completed"] = "Completed";
447
+ TransactionStateValues["Failed"] = "Failed";
448
+ TransactionStateValues["Initial"] = "Initial";
449
+ TransactionStateValues["Pending"] = "Pending";
450
+ return TransactionStateValues;
451
+ }({});
452
+
453
+ /**
454
+ * The state of the [Transaction](/transactions-api#transaction) and the related errors in case of a failed Transaction.
455
+ *
456
+ */
457
+
458
+ /**
459
+ * Code generated by [commercetools RMF-Codegen](https://github.com/commercetools/rmf-codegen). DO NOT EDIT.
460
+ * Please don't change this file manually but run `rmf-codegen generate <raml_file_path> -o <output_path> -t typescript_client` to update it.
461
+ * For more information about the commercetools platform APIs, visit https://docs.commercetools.com/.
462
+ */
463
+
464
+ const createExecutorFromMiddlewares = (executor, midds) => {
465
+ if (!midds || midds.length == 0) {
466
+ return executor;
467
+ }
468
+ const reduced = midds.reduce(reduceMiddleware);
469
+ return middlewareToExecutor(reduced, executor);
470
+ };
471
+ function reduceMiddleware(middleware1, middleware2) {
472
+ return (request, executor) => middleware1(request, middlewareToExecutor(middleware2, executor));
473
+ }
474
+ function middlewareToExecutor(middleware, executor) {
475
+ return request => middleware(request, executor);
476
+ }
477
+
478
+ function createApiBuilderFromCtpClient(ctpClient, baseUri) {
479
+ return new ApiRoot({
480
+ executeRequest: ctpClient.execute,
481
+ baseUri: baseUri
482
+ });
483
+ }
484
+
485
+ exports.ApiRequest = ApiRequest;
486
+ exports.ApiRoot = ApiRoot;
487
+ exports.ByProjectKeyPaymentIntentsByPaymentIdRequestBuilder = ByProjectKeyPaymentIntentsByPaymentIdRequestBuilder;
488
+ exports.ByProjectKeyPaymentIntentsRequestBuilder = ByProjectKeyPaymentIntentsRequestBuilder;
489
+ exports.ByProjectKeyRequestBuilder = ByProjectKeyRequestBuilder;
490
+ exports.ByProjectKeyTransactionsByIdRequestBuilder = ByProjectKeyTransactionsByIdRequestBuilder;
491
+ exports.ByProjectKeyTransactionsKeyByKeyRequestBuilder = ByProjectKeyTransactionsKeyByKeyRequestBuilder;
492
+ exports.ByProjectKeyTransactionsRequestBuilder = ByProjectKeyTransactionsRequestBuilder;
493
+ exports.PaymentIntentOperationValues = PaymentIntentOperationValues;
494
+ exports.ReferenceTypeIdValues = ReferenceTypeIdValues;
495
+ exports.RegionValues = RegionValues;
496
+ exports.TransactionStateValues = TransactionStateValues;
497
+ exports.buildRelativeUri = buildRelativeUri;
498
+ exports.createApiBuilderFromCtpClient = createApiBuilderFromCtpClient;
499
+ exports.createExecutorFromMiddlewares = createExecutorFromMiddlewares;