checkout-intents 0.3.0 → 0.5.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 +38 -0
- package/README.md +128 -15
- package/client.d.mts +8 -5
- package/client.d.mts.map +1 -1
- package/client.d.ts +8 -5
- package/client.d.ts.map +1 -1
- package/client.js +10 -15
- package/client.js.map +1 -1
- package/client.mjs +10 -15
- package/client.mjs.map +1 -1
- package/core/error.d.mts +17 -0
- package/core/error.d.mts.map +1 -1
- package/core/error.d.ts +17 -0
- package/core/error.d.ts.map +1 -1
- package/core/error.js +18 -1
- package/core/error.js.map +1 -1
- package/core/error.mjs +16 -0
- package/core/error.mjs.map +1 -1
- package/core/pagination.d.mts +63 -0
- package/core/pagination.d.mts.map +1 -0
- package/core/pagination.d.ts +63 -0
- package/core/pagination.d.ts.map +1 -0
- package/core/pagination.js +115 -0
- package/core/pagination.js.map +1 -0
- package/core/pagination.mjs +109 -0
- package/core/pagination.mjs.map +1 -0
- package/index.d.mts +2 -1
- package/index.d.mts.map +1 -1
- package/index.d.ts +2 -1
- package/index.d.ts.map +1 -1
- package/index.js +4 -1
- package/index.js.map +1 -1
- package/index.mjs +2 -1
- package/index.mjs.map +1 -1
- package/internal/qs/formats.d.mts +7 -0
- package/internal/qs/formats.d.mts.map +1 -0
- package/internal/qs/formats.d.ts +7 -0
- package/internal/qs/formats.d.ts.map +1 -0
- package/internal/qs/formats.js +13 -0
- package/internal/qs/formats.js.map +1 -0
- package/internal/qs/formats.mjs +9 -0
- package/internal/qs/formats.mjs.map +1 -0
- package/internal/qs/index.d.mts +10 -0
- package/internal/qs/index.d.mts.map +1 -0
- package/internal/qs/index.d.ts +10 -0
- package/internal/qs/index.d.ts.map +1 -0
- package/internal/qs/index.js +14 -0
- package/internal/qs/index.js.map +1 -0
- package/internal/qs/index.mjs +10 -0
- package/internal/qs/index.mjs.map +1 -0
- package/internal/qs/stringify.d.mts +3 -0
- package/internal/qs/stringify.d.mts.map +1 -0
- package/internal/qs/stringify.d.ts +3 -0
- package/internal/qs/stringify.d.ts.map +1 -0
- package/internal/qs/stringify.js +277 -0
- package/internal/qs/stringify.js.map +1 -0
- package/internal/qs/stringify.mjs +274 -0
- package/internal/qs/stringify.mjs.map +1 -0
- package/internal/qs/types.d.mts +57 -0
- package/internal/qs/types.d.mts.map +1 -0
- package/internal/qs/types.d.ts +57 -0
- package/internal/qs/types.d.ts.map +1 -0
- package/internal/qs/types.js +3 -0
- package/internal/qs/types.js.map +1 -0
- package/internal/qs/types.mjs +2 -0
- package/internal/qs/types.mjs.map +1 -0
- package/internal/qs/utils.d.mts +15 -0
- package/internal/qs/utils.d.mts.map +1 -0
- package/internal/qs/utils.d.ts +15 -0
- package/internal/qs/utils.d.ts.map +1 -0
- package/internal/qs/utils.js +230 -0
- package/internal/qs/utils.js.map +1 -0
- package/internal/qs/utils.mjs +217 -0
- package/internal/qs/utils.mjs.map +1 -0
- package/package.json +11 -1
- package/pagination.d.mts +2 -0
- package/pagination.d.mts.map +1 -0
- package/pagination.d.ts +2 -0
- package/pagination.d.ts.map +1 -0
- package/pagination.js +6 -0
- package/pagination.js.map +1 -0
- package/pagination.mjs +2 -0
- package/pagination.mjs.map +1 -0
- package/resources/checkout-intents.d.mts +28 -6
- package/resources/checkout-intents.d.mts.map +1 -1
- package/resources/checkout-intents.d.ts +28 -6
- package/resources/checkout-intents.d.ts.map +1 -1
- package/resources/checkout-intents.js +50 -9
- package/resources/checkout-intents.js.map +1 -1
- package/resources/checkout-intents.mjs +50 -9
- package/resources/checkout-intents.mjs.map +1 -1
- package/resources/index.d.mts +1 -1
- package/resources/index.d.mts.map +1 -1
- package/resources/index.d.ts +1 -1
- package/resources/index.d.ts.map +1 -1
- package/resources/index.js.map +1 -1
- package/resources/index.mjs.map +1 -1
- package/src/client.ts +33 -17
- package/src/core/error.ts +43 -0
- package/src/core/pagination.ts +187 -0
- package/src/index.ts +2 -0
- package/src/internal/qs/LICENSE.md +13 -0
- package/src/internal/qs/README.md +3 -0
- package/src/internal/qs/formats.ts +10 -0
- package/src/internal/qs/index.ts +13 -0
- package/src/internal/qs/stringify.ts +385 -0
- package/src/internal/qs/types.ts +71 -0
- package/src/internal/qs/utils.ts +265 -0
- package/src/pagination.ts +2 -0
- package/src/resources/checkout-intents.ts +73 -11
- package/src/resources/index.ts +2 -0
- package/src/version.ts +1 -1
- package/version.d.mts +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/version.mjs +1 -1
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
import { RFC1738 } from './formats';
|
|
2
|
+
import type { DefaultEncoder, Format } from './types';
|
|
3
|
+
import { isArray } from '../utils/values';
|
|
4
|
+
|
|
5
|
+
export let has = (obj: object, key: PropertyKey): boolean => (
|
|
6
|
+
(has = (Object as any).hasOwn ?? Function.prototype.call.bind(Object.prototype.hasOwnProperty)),
|
|
7
|
+
has(obj, key)
|
|
8
|
+
);
|
|
9
|
+
|
|
10
|
+
const hex_table = /* @__PURE__ */ (() => {
|
|
11
|
+
const array = [];
|
|
12
|
+
for (let i = 0; i < 256; ++i) {
|
|
13
|
+
array.push('%' + ((i < 16 ? '0' : '') + i.toString(16)).toUpperCase());
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
return array;
|
|
17
|
+
})();
|
|
18
|
+
|
|
19
|
+
function compact_queue<T extends Record<string, any>>(queue: Array<{ obj: T; prop: string }>) {
|
|
20
|
+
while (queue.length > 1) {
|
|
21
|
+
const item = queue.pop();
|
|
22
|
+
if (!item) continue;
|
|
23
|
+
|
|
24
|
+
const obj = item.obj[item.prop];
|
|
25
|
+
|
|
26
|
+
if (isArray(obj)) {
|
|
27
|
+
const compacted: unknown[] = [];
|
|
28
|
+
|
|
29
|
+
for (let j = 0; j < obj.length; ++j) {
|
|
30
|
+
if (typeof obj[j] !== 'undefined') {
|
|
31
|
+
compacted.push(obj[j]);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// @ts-ignore
|
|
36
|
+
item.obj[item.prop] = compacted;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function array_to_object(source: any[], options: { plainObjects: boolean }) {
|
|
42
|
+
const obj = options && options.plainObjects ? Object.create(null) : {};
|
|
43
|
+
for (let i = 0; i < source.length; ++i) {
|
|
44
|
+
if (typeof source[i] !== 'undefined') {
|
|
45
|
+
obj[i] = source[i];
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return obj;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export function merge(
|
|
53
|
+
target: any,
|
|
54
|
+
source: any,
|
|
55
|
+
options: { plainObjects?: boolean; allowPrototypes?: boolean } = {},
|
|
56
|
+
) {
|
|
57
|
+
if (!source) {
|
|
58
|
+
return target;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (typeof source !== 'object') {
|
|
62
|
+
if (isArray(target)) {
|
|
63
|
+
target.push(source);
|
|
64
|
+
} else if (target && typeof target === 'object') {
|
|
65
|
+
if ((options && (options.plainObjects || options.allowPrototypes)) || !has(Object.prototype, source)) {
|
|
66
|
+
target[source] = true;
|
|
67
|
+
}
|
|
68
|
+
} else {
|
|
69
|
+
return [target, source];
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return target;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
if (!target || typeof target !== 'object') {
|
|
76
|
+
return [target].concat(source);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
let mergeTarget = target;
|
|
80
|
+
if (isArray(target) && !isArray(source)) {
|
|
81
|
+
// @ts-ignore
|
|
82
|
+
mergeTarget = array_to_object(target, options);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if (isArray(target) && isArray(source)) {
|
|
86
|
+
source.forEach(function (item, i) {
|
|
87
|
+
if (has(target, i)) {
|
|
88
|
+
const targetItem = target[i];
|
|
89
|
+
if (targetItem && typeof targetItem === 'object' && item && typeof item === 'object') {
|
|
90
|
+
target[i] = merge(targetItem, item, options);
|
|
91
|
+
} else {
|
|
92
|
+
target.push(item);
|
|
93
|
+
}
|
|
94
|
+
} else {
|
|
95
|
+
target[i] = item;
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
return target;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
return Object.keys(source).reduce(function (acc, key) {
|
|
102
|
+
const value = source[key];
|
|
103
|
+
|
|
104
|
+
if (has(acc, key)) {
|
|
105
|
+
acc[key] = merge(acc[key], value, options);
|
|
106
|
+
} else {
|
|
107
|
+
acc[key] = value;
|
|
108
|
+
}
|
|
109
|
+
return acc;
|
|
110
|
+
}, mergeTarget);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export function assign_single_source(target: any, source: any) {
|
|
114
|
+
return Object.keys(source).reduce(function (acc, key) {
|
|
115
|
+
acc[key] = source[key];
|
|
116
|
+
return acc;
|
|
117
|
+
}, target);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export function decode(str: string, _: any, charset: string) {
|
|
121
|
+
const strWithoutPlus = str.replace(/\+/g, ' ');
|
|
122
|
+
if (charset === 'iso-8859-1') {
|
|
123
|
+
// unescape never throws, no try...catch needed:
|
|
124
|
+
return strWithoutPlus.replace(/%[0-9a-f]{2}/gi, unescape);
|
|
125
|
+
}
|
|
126
|
+
// utf-8
|
|
127
|
+
try {
|
|
128
|
+
return decodeURIComponent(strWithoutPlus);
|
|
129
|
+
} catch (e) {
|
|
130
|
+
return strWithoutPlus;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
const limit = 1024;
|
|
135
|
+
|
|
136
|
+
export const encode: (
|
|
137
|
+
str: any,
|
|
138
|
+
defaultEncoder: DefaultEncoder,
|
|
139
|
+
charset: string,
|
|
140
|
+
type: 'key' | 'value',
|
|
141
|
+
format: Format,
|
|
142
|
+
) => string = (str, _defaultEncoder, charset, _kind, format: Format) => {
|
|
143
|
+
// This code was originally written by Brian White for the io.js core querystring library.
|
|
144
|
+
// It has been adapted here for stricter adherence to RFC 3986
|
|
145
|
+
if (str.length === 0) {
|
|
146
|
+
return str;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
let string = str;
|
|
150
|
+
if (typeof str === 'symbol') {
|
|
151
|
+
string = Symbol.prototype.toString.call(str);
|
|
152
|
+
} else if (typeof str !== 'string') {
|
|
153
|
+
string = String(str);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
if (charset === 'iso-8859-1') {
|
|
157
|
+
return escape(string).replace(/%u[0-9a-f]{4}/gi, function ($0) {
|
|
158
|
+
return '%26%23' + parseInt($0.slice(2), 16) + '%3B';
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
let out = '';
|
|
163
|
+
for (let j = 0; j < string.length; j += limit) {
|
|
164
|
+
const segment = string.length >= limit ? string.slice(j, j + limit) : string;
|
|
165
|
+
const arr = [];
|
|
166
|
+
|
|
167
|
+
for (let i = 0; i < segment.length; ++i) {
|
|
168
|
+
let c = segment.charCodeAt(i);
|
|
169
|
+
if (
|
|
170
|
+
c === 0x2d || // -
|
|
171
|
+
c === 0x2e || // .
|
|
172
|
+
c === 0x5f || // _
|
|
173
|
+
c === 0x7e || // ~
|
|
174
|
+
(c >= 0x30 && c <= 0x39) || // 0-9
|
|
175
|
+
(c >= 0x41 && c <= 0x5a) || // a-z
|
|
176
|
+
(c >= 0x61 && c <= 0x7a) || // A-Z
|
|
177
|
+
(format === RFC1738 && (c === 0x28 || c === 0x29)) // ( )
|
|
178
|
+
) {
|
|
179
|
+
arr[arr.length] = segment.charAt(i);
|
|
180
|
+
continue;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
if (c < 0x80) {
|
|
184
|
+
arr[arr.length] = hex_table[c];
|
|
185
|
+
continue;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
if (c < 0x800) {
|
|
189
|
+
arr[arr.length] = hex_table[0xc0 | (c >> 6)]! + hex_table[0x80 | (c & 0x3f)];
|
|
190
|
+
continue;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
if (c < 0xd800 || c >= 0xe000) {
|
|
194
|
+
arr[arr.length] =
|
|
195
|
+
hex_table[0xe0 | (c >> 12)]! + hex_table[0x80 | ((c >> 6) & 0x3f)] + hex_table[0x80 | (c & 0x3f)];
|
|
196
|
+
continue;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
i += 1;
|
|
200
|
+
c = 0x10000 + (((c & 0x3ff) << 10) | (segment.charCodeAt(i) & 0x3ff));
|
|
201
|
+
|
|
202
|
+
arr[arr.length] =
|
|
203
|
+
hex_table[0xf0 | (c >> 18)]! +
|
|
204
|
+
hex_table[0x80 | ((c >> 12) & 0x3f)] +
|
|
205
|
+
hex_table[0x80 | ((c >> 6) & 0x3f)] +
|
|
206
|
+
hex_table[0x80 | (c & 0x3f)];
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
out += arr.join('');
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
return out;
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
export function compact(value: any) {
|
|
216
|
+
const queue = [{ obj: { o: value }, prop: 'o' }];
|
|
217
|
+
const refs = [];
|
|
218
|
+
|
|
219
|
+
for (let i = 0; i < queue.length; ++i) {
|
|
220
|
+
const item = queue[i];
|
|
221
|
+
// @ts-ignore
|
|
222
|
+
const obj = item.obj[item.prop];
|
|
223
|
+
|
|
224
|
+
const keys = Object.keys(obj);
|
|
225
|
+
for (let j = 0; j < keys.length; ++j) {
|
|
226
|
+
const key = keys[j]!;
|
|
227
|
+
const val = obj[key];
|
|
228
|
+
if (typeof val === 'object' && val !== null && refs.indexOf(val) === -1) {
|
|
229
|
+
queue.push({ obj: obj, prop: key });
|
|
230
|
+
refs.push(val);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
compact_queue(queue);
|
|
236
|
+
|
|
237
|
+
return value;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
export function is_regexp(obj: any) {
|
|
241
|
+
return Object.prototype.toString.call(obj) === '[object RegExp]';
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
export function is_buffer(obj: any) {
|
|
245
|
+
if (!obj || typeof obj !== 'object') {
|
|
246
|
+
return false;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
return !!(obj.constructor && obj.constructor.isBuffer && obj.constructor.isBuffer(obj));
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
export function combine(a: any, b: any) {
|
|
253
|
+
return [].concat(a, b);
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
export function maybe_map<T>(val: T[], fn: (v: T) => T) {
|
|
257
|
+
if (isArray(val)) {
|
|
258
|
+
const mapped = [];
|
|
259
|
+
for (let i = 0; i < val.length; i += 1) {
|
|
260
|
+
mapped.push(fn(val[i]!));
|
|
261
|
+
}
|
|
262
|
+
return mapped;
|
|
263
|
+
}
|
|
264
|
+
return fn(val);
|
|
265
|
+
}
|
|
@@ -2,11 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
import { APIResource } from '../core/resource';
|
|
4
4
|
import * as CheckoutIntentsAPI from './checkout-intents';
|
|
5
|
+
import { PollTimeoutError } from '../core/error';
|
|
5
6
|
import { APIPromise } from '../core/api-promise';
|
|
7
|
+
import { CursorPagination, type CursorPaginationParams, PagePromise } from '../core/pagination';
|
|
6
8
|
import { RequestOptions } from '../internal/request-options';
|
|
7
9
|
import { path } from '../internal/utils/path';
|
|
8
10
|
import { sleep } from '../internal/utils/sleep';
|
|
9
11
|
import { buildHeaders } from '../internal/headers';
|
|
12
|
+
import { loggerFor } from '../internal/utils/log';
|
|
10
13
|
|
|
11
14
|
/**
|
|
12
15
|
* Options for polling operations.
|
|
@@ -33,11 +36,11 @@ export class CheckoutIntentsResource extends APIResource {
|
|
|
33
36
|
* buyer: {
|
|
34
37
|
* address1: '123 Main St',
|
|
35
38
|
* city: 'New York',
|
|
36
|
-
* country: '
|
|
39
|
+
* country: 'US',
|
|
37
40
|
* email: 'john.doe@example.com',
|
|
38
41
|
* firstName: 'John',
|
|
39
42
|
* lastName: 'Doe',
|
|
40
|
-
* phone: '
|
|
43
|
+
* phone: '1234567890',
|
|
41
44
|
* postalCode: '10001',
|
|
42
45
|
* province: 'NY',
|
|
43
46
|
* },
|
|
@@ -65,6 +68,30 @@ export class CheckoutIntentsResource extends APIResource {
|
|
|
65
68
|
return this._client.get(path`/api/v1/checkout-intents/${id}`, options);
|
|
66
69
|
}
|
|
67
70
|
|
|
71
|
+
/**
|
|
72
|
+
* Retrieve a paginated list of checkout intents
|
|
73
|
+
*
|
|
74
|
+
* Enables developers to query checkout intents associated with their account, with
|
|
75
|
+
* filters and cursor-based pagination.
|
|
76
|
+
*
|
|
77
|
+
* @example
|
|
78
|
+
* ```ts
|
|
79
|
+
* // Automatically fetches more pages as needed.
|
|
80
|
+
* for await (const checkoutIntent of client.checkoutIntents.list()) {
|
|
81
|
+
* // ...
|
|
82
|
+
* }
|
|
83
|
+
* ```
|
|
84
|
+
*/
|
|
85
|
+
list(
|
|
86
|
+
query: CheckoutIntentListParams | null | undefined = {},
|
|
87
|
+
options?: RequestOptions,
|
|
88
|
+
): PagePromise<CheckoutIntentsCursorPagination, CheckoutIntent> {
|
|
89
|
+
return this._client.getAPIList('/api/v1/checkout-intents', CursorPagination<CheckoutIntent>, {
|
|
90
|
+
query,
|
|
91
|
+
...options,
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
|
|
68
95
|
/**
|
|
69
96
|
* Add payment details to a checkout intent
|
|
70
97
|
*
|
|
@@ -131,9 +158,16 @@ export class CheckoutIntentsResource extends APIResource {
|
|
|
131
158
|
condition: (intent: CheckoutIntent) => intent is T,
|
|
132
159
|
options?: RequestOptions & PollOptions,
|
|
133
160
|
): Promise<T> {
|
|
134
|
-
|
|
161
|
+
let maxAttempts = options?.maxAttempts ?? 120; // Default: 120 attempts
|
|
135
162
|
const pollIntervalMs = options?.pollIntervalMs ?? 5000; // Default: 5 seconds
|
|
136
|
-
|
|
163
|
+
|
|
164
|
+
if (maxAttempts < 1) {
|
|
165
|
+
loggerFor(this._client).warn(
|
|
166
|
+
`[Checkout Intents SDK] Invalid maxAttempts value: ${maxAttempts}. maxAttempts must be >= 1. Defaulting to 1 to ensure at least one polling attempt.`,
|
|
167
|
+
);
|
|
168
|
+
|
|
169
|
+
maxAttempts = 1;
|
|
170
|
+
}
|
|
137
171
|
|
|
138
172
|
const headers = buildHeaders([
|
|
139
173
|
options?.headers,
|
|
@@ -143,12 +177,17 @@ export class CheckoutIntentsResource extends APIResource {
|
|
|
143
177
|
},
|
|
144
178
|
]);
|
|
145
179
|
|
|
180
|
+
let intent: CheckoutIntentsAPI.CheckoutIntent;
|
|
181
|
+
let attempts = 0;
|
|
182
|
+
|
|
146
183
|
while (attempts < maxAttempts) {
|
|
147
|
-
const { data
|
|
184
|
+
const { data, response } = await this.retrieve(id, {
|
|
148
185
|
...options,
|
|
149
186
|
headers: { ...options?.headers, ...headers.values },
|
|
150
187
|
}).withResponse();
|
|
151
188
|
|
|
189
|
+
intent = data;
|
|
190
|
+
|
|
152
191
|
// Check if condition is met
|
|
153
192
|
if (condition(intent)) {
|
|
154
193
|
return intent;
|
|
@@ -158,11 +197,15 @@ export class CheckoutIntentsResource extends APIResource {
|
|
|
158
197
|
|
|
159
198
|
// If we've reached max attempts, throw an error
|
|
160
199
|
if (attempts >= maxAttempts) {
|
|
161
|
-
throw new
|
|
162
|
-
|
|
200
|
+
throw new PollTimeoutError({
|
|
201
|
+
intentId: intent.id,
|
|
202
|
+
attempts,
|
|
203
|
+
maxAttempts,
|
|
204
|
+
pollIntervalMs,
|
|
205
|
+
message: `Polling timeout: condition not met after ${maxAttempts} attempts (${
|
|
163
206
|
(maxAttempts * pollIntervalMs) / 1000
|
|
164
207
|
}s)`,
|
|
165
|
-
);
|
|
208
|
+
});
|
|
166
209
|
}
|
|
167
210
|
|
|
168
211
|
// Check if server suggests a polling interval
|
|
@@ -179,7 +222,13 @@ export class CheckoutIntentsResource extends APIResource {
|
|
|
179
222
|
}
|
|
180
223
|
|
|
181
224
|
// This should never be reached due to the throw above, but TypeScript needs it
|
|
182
|
-
throw new
|
|
225
|
+
throw new PollTimeoutError({
|
|
226
|
+
intentId: intent!.id,
|
|
227
|
+
attempts,
|
|
228
|
+
maxAttempts,
|
|
229
|
+
pollIntervalMs,
|
|
230
|
+
message: `Polling timeout: condition not met after ${maxAttempts} attempts`,
|
|
231
|
+
});
|
|
183
232
|
}
|
|
184
233
|
|
|
185
234
|
/**
|
|
@@ -257,11 +306,11 @@ export class CheckoutIntentsResource extends APIResource {
|
|
|
257
306
|
* buyer: {
|
|
258
307
|
* address1: '123 Main St',
|
|
259
308
|
* city: 'New York',
|
|
260
|
-
* country: '
|
|
309
|
+
* country: 'US',
|
|
261
310
|
* email: 'john.doe@example.com',
|
|
262
311
|
* firstName: 'John',
|
|
263
312
|
* lastName: 'Doe',
|
|
264
|
-
* phone: '
|
|
313
|
+
* phone: '1234567890',
|
|
265
314
|
* postalCode: '10001',
|
|
266
315
|
* province: 'NY',
|
|
267
316
|
* },
|
|
@@ -319,6 +368,8 @@ export class CheckoutIntentsResource extends APIResource {
|
|
|
319
368
|
}
|
|
320
369
|
}
|
|
321
370
|
|
|
371
|
+
export type CheckoutIntentsCursorPagination = CursorPagination<CheckoutIntent>;
|
|
372
|
+
|
|
322
373
|
export interface BaseCheckoutIntent {
|
|
323
374
|
id: string;
|
|
324
375
|
|
|
@@ -386,6 +437,8 @@ export namespace CheckoutIntent {
|
|
|
386
437
|
export interface CompletedCheckoutIntent extends CheckoutIntentsAPI.BaseCheckoutIntent {
|
|
387
438
|
offer: CheckoutIntentsAPI.Offer;
|
|
388
439
|
|
|
440
|
+
orderId: string | null;
|
|
441
|
+
|
|
389
442
|
paymentMethod: CheckoutIntentsAPI.PaymentMethod;
|
|
390
443
|
|
|
391
444
|
state: 'completed';
|
|
@@ -413,6 +466,7 @@ export namespace CheckoutIntent {
|
|
|
413
466
|
| 'developer_not_found'
|
|
414
467
|
| 'missing_shipping_method'
|
|
415
468
|
| 'unsupported_currency'
|
|
469
|
+
| 'invalid_input'
|
|
416
470
|
| 'unsupported_store_no_guest_checkout';
|
|
417
471
|
|
|
418
472
|
message: string;
|
|
@@ -506,6 +560,12 @@ export interface CheckoutIntentCreateParams {
|
|
|
506
560
|
variantSelections?: Array<VariantSelection>;
|
|
507
561
|
}
|
|
508
562
|
|
|
563
|
+
export interface CheckoutIntentListParams extends CursorPaginationParams {
|
|
564
|
+
id?: Array<string>;
|
|
565
|
+
|
|
566
|
+
state?: Array<'retrieving_offer' | 'awaiting_confirmation' | 'placing_order' | 'completed' | 'failed'>;
|
|
567
|
+
}
|
|
568
|
+
|
|
509
569
|
export interface CheckoutIntentAddPaymentParams {
|
|
510
570
|
paymentMethod: PaymentMethod;
|
|
511
571
|
}
|
|
@@ -524,7 +584,9 @@ export declare namespace CheckoutIntentsResource {
|
|
|
524
584
|
type PaymentMethod as PaymentMethod,
|
|
525
585
|
type PollOptions as PollOptions,
|
|
526
586
|
type VariantSelection as VariantSelection,
|
|
587
|
+
type CheckoutIntentsCursorPagination as CheckoutIntentsCursorPagination,
|
|
527
588
|
type CheckoutIntentCreateParams as CheckoutIntentCreateParams,
|
|
589
|
+
type CheckoutIntentListParams as CheckoutIntentListParams,
|
|
528
590
|
type CheckoutIntentAddPaymentParams as CheckoutIntentAddPaymentParams,
|
|
529
591
|
type CheckoutIntentConfirmParams as CheckoutIntentConfirmParams,
|
|
530
592
|
};
|
package/src/resources/index.ts
CHANGED
|
@@ -11,6 +11,8 @@ export {
|
|
|
11
11
|
type PaymentMethod,
|
|
12
12
|
type VariantSelection,
|
|
13
13
|
type CheckoutIntentCreateParams,
|
|
14
|
+
type CheckoutIntentListParams,
|
|
14
15
|
type CheckoutIntentAddPaymentParams,
|
|
15
16
|
type CheckoutIntentConfirmParams,
|
|
17
|
+
type CheckoutIntentsCursorPagination,
|
|
16
18
|
} from './checkout-intents';
|
package/src/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = '0.
|
|
1
|
+
export const VERSION = '0.5.0'; // x-release-please-version
|
package/version.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "0.
|
|
1
|
+
export declare const VERSION = "0.5.0";
|
|
2
2
|
//# sourceMappingURL=version.d.mts.map
|
package/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "0.
|
|
1
|
+
export declare const VERSION = "0.5.0";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/version.js
CHANGED
package/version.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const VERSION = '0.
|
|
1
|
+
export const VERSION = '0.5.0'; // x-release-please-version
|
|
2
2
|
//# sourceMappingURL=version.mjs.map
|