checkout-intents 0.1.0 → 0.3.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 +49 -0
- package/LICENSE +4 -198
- package/README.md +155 -21
- package/client.d.mts +21 -7
- package/client.d.mts.map +1 -1
- package/client.d.ts +21 -7
- package/client.d.ts.map +1 -1
- package/client.js +37 -10
- package/client.js.map +1 -1
- package/client.mjs +37 -10
- package/client.mjs.map +1 -1
- package/internal/to-file.d.mts +1 -1
- package/internal/to-file.d.ts +1 -1
- package/internal/to-file.js +1 -1
- package/internal/to-file.mjs +1 -1
- package/internal/tslib.js +17 -17
- package/internal/utils/values.js +3 -3
- package/internal/utils/values.js.map +1 -1
- package/internal/utils/values.mjs +3 -3
- package/internal/utils/values.mjs.map +1 -1
- package/package.json +3 -3
- package/resources/brands.d.mts +31 -0
- package/resources/brands.d.mts.map +1 -0
- package/resources/brands.d.ts +31 -0
- package/resources/brands.d.ts.map +1 -0
- package/resources/{api/v1/brands.js → brands.js} +5 -5
- package/resources/brands.js.map +1 -0
- package/resources/brands.mjs +15 -0
- package/resources/brands.mjs.map +1 -0
- package/resources/checkout-intents.d.mts +320 -0
- package/resources/checkout-intents.d.mts.map +1 -0
- package/resources/checkout-intents.d.ts +320 -0
- package/resources/checkout-intents.d.ts.map +1 -0
- package/resources/checkout-intents.js +248 -0
- package/resources/checkout-intents.js.map +1 -0
- package/resources/checkout-intents.mjs +244 -0
- package/resources/checkout-intents.mjs.map +1 -0
- package/resources/index.d.mts +2 -2
- package/resources/index.d.mts.map +1 -1
- package/resources/index.d.ts +2 -2
- package/resources/index.d.ts.map +1 -1
- package/resources/index.js +5 -5
- package/resources/index.js.map +1 -1
- package/resources/index.mjs +2 -2
- package/resources/index.mjs.map +1 -1
- package/src/client.ts +84 -14
- package/src/internal/to-file.ts +1 -1
- package/src/internal/utils/values.ts +3 -3
- package/src/resources/{api/v1/brands.ts → brands.ts} +9 -9
- package/src/resources/checkout-intents.ts +531 -0
- package/src/resources/index.ts +14 -2
- 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
- package/resources/api/api.d.mts +0 -10
- package/resources/api/api.d.mts.map +0 -1
- package/resources/api/api.d.ts +0 -10
- package/resources/api/api.d.ts.map +0 -1
- package/resources/api/api.js +0 -17
- package/resources/api/api.js.map +0 -1
- package/resources/api/api.mjs +0 -12
- package/resources/api/api.mjs.map +0 -1
- package/resources/api/index.d.mts +0 -3
- package/resources/api/index.d.mts.map +0 -1
- package/resources/api/index.d.ts +0 -3
- package/resources/api/index.d.ts.map +0 -1
- package/resources/api/index.js +0 -9
- package/resources/api/index.js.map +0 -1
- package/resources/api/index.mjs +0 -4
- package/resources/api/index.mjs.map +0 -1
- package/resources/api/v1/brands.d.mts +0 -31
- package/resources/api/v1/brands.d.mts.map +0 -1
- package/resources/api/v1/brands.d.ts +0 -31
- package/resources/api/v1/brands.d.ts.map +0 -1
- package/resources/api/v1/brands.js.map +0 -1
- package/resources/api/v1/brands.mjs +0 -15
- package/resources/api/v1/brands.mjs.map +0 -1
- package/resources/api/v1/checkout-intents.d.mts +0 -117
- package/resources/api/v1/checkout-intents.d.mts.map +0 -1
- package/resources/api/v1/checkout-intents.d.ts +0 -117
- package/resources/api/v1/checkout-intents.d.ts.map +0 -1
- package/resources/api/v1/checkout-intents.js +0 -33
- package/resources/api/v1/checkout-intents.js.map +0 -1
- package/resources/api/v1/checkout-intents.mjs +0 -29
- package/resources/api/v1/checkout-intents.mjs.map +0 -1
- package/resources/api/v1/index.d.mts +0 -4
- package/resources/api/v1/index.d.mts.map +0 -1
- package/resources/api/v1/index.d.ts +0 -4
- package/resources/api/v1/index.d.ts.map +0 -1
- package/resources/api/v1/index.js +0 -11
- package/resources/api/v1/index.js.map +0 -1
- package/resources/api/v1/index.mjs +0 -5
- package/resources/api/v1/index.mjs.map +0 -1
- package/resources/api/v1/v1.d.mts +0 -14
- package/resources/api/v1/v1.d.mts.map +0 -1
- package/resources/api/v1/v1.d.ts +0 -14
- package/resources/api/v1/v1.d.ts.map +0 -1
- package/resources/api/v1/v1.js +0 -21
- package/resources/api/v1/v1.js.map +0 -1
- package/resources/api/v1/v1.mjs +0 -16
- package/resources/api/v1/v1.mjs.map +0 -1
- package/resources/api/v1.d.mts +0 -2
- package/resources/api/v1.d.mts.map +0 -1
- package/resources/api/v1.d.ts +0 -2
- package/resources/api/v1.d.ts.map +0 -1
- package/resources/api/v1.js +0 -6
- package/resources/api/v1.js.map +0 -1
- package/resources/api/v1.mjs +0 -3
- package/resources/api/v1.mjs.map +0 -1
- package/resources/api.d.mts +0 -2
- package/resources/api.d.mts.map +0 -1
- package/resources/api.d.ts +0 -2
- package/resources/api.d.ts.map +0 -1
- package/resources/api.js +0 -6
- package/resources/api.js.map +0 -1
- package/resources/api.mjs +0 -3
- package/resources/api.mjs.map +0 -1
- package/resources/health.d.mts +0 -17
- package/resources/health.d.mts.map +0 -1
- package/resources/health.d.ts +0 -17
- package/resources/health.d.ts.map +0 -1
- package/resources/health.js +0 -15
- package/resources/health.js.map +0 -1
- package/resources/health.mjs +0 -11
- package/resources/health.mjs.map +0 -1
- package/src/resources/api/api.ts +0 -15
- package/src/resources/api/index.ts +0 -4
- package/src/resources/api/v1/checkout-intents.ts +0 -207
- package/src/resources/api/v1/index.ts +0 -15
- package/src/resources/api/v1/v1.ts +0 -41
- package/src/resources/api/v1.ts +0 -3
- package/src/resources/api.ts +0 -3
- package/src/resources/health.ts +0 -24
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"brands.d.mts","sourceRoot":"","sources":["../src/resources/brands.ts"],"names":[],"mappings":"OAEO,EAAE,WAAW,EAAE;OACf,EAAE,UAAU,EAAE;OACd,EAAE,cAAc,EAAE;AAGzB,qBAAa,MAAO,SAAQ,WAAW;IACrC;;;;;OAKG;IACH,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,UAAU,CAAC,qBAAqB,CAAC;CAGtF;AAED,MAAM,WAAW,qBAAqB;IACpC;;OAEG;IACH,EAAE,EAAE,MAAM,CAAC;IAEX;;OAEG;IACH,WAAW,EAAE,QAAQ,GAAG,SAAS,GAAG,SAAS,CAAC;IAE9C;;;OAGG;IACH,SAAS,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,CAAC,OAAO,WAAW,MAAM,CAAC;IAC9B,OAAO,EAAE,KAAK,qBAAqB,IAAI,qBAAqB,EAAE,CAAC;CAChE"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { APIResource } from "../core/resource.js";
|
|
2
|
+
import { APIPromise } from "../core/api-promise.js";
|
|
3
|
+
import { RequestOptions } from "../internal/request-options.js";
|
|
4
|
+
export declare class Brands extends APIResource {
|
|
5
|
+
/**
|
|
6
|
+
* Retrieve brand information by domain name
|
|
7
|
+
*
|
|
8
|
+
* Look up a brand by its domain name (e.g. "aloyoga.com" or "www.amazon.com").
|
|
9
|
+
* Returns brand information including the marketplace type if the lookup succeeds.
|
|
10
|
+
*/
|
|
11
|
+
retrieve(domain: string, options?: RequestOptions): APIPromise<BrandRetrieveResponse>;
|
|
12
|
+
}
|
|
13
|
+
export interface BrandRetrieveResponse {
|
|
14
|
+
/**
|
|
15
|
+
* A unique identifier for the brand.
|
|
16
|
+
*/
|
|
17
|
+
id: string;
|
|
18
|
+
/**
|
|
19
|
+
* Indicates what ecommerce platform the brand uses.
|
|
20
|
+
*/
|
|
21
|
+
marketplace: 'AMAZON' | 'SHOPIFY' | 'UNKNOWN';
|
|
22
|
+
/**
|
|
23
|
+
* If `false`, then products from this brand cannot be purchased through the Sell
|
|
24
|
+
* Anything API.
|
|
25
|
+
*/
|
|
26
|
+
supported: boolean;
|
|
27
|
+
}
|
|
28
|
+
export declare namespace Brands {
|
|
29
|
+
export { type BrandRetrieveResponse as BrandRetrieveResponse };
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=brands.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"brands.d.ts","sourceRoot":"","sources":["../src/resources/brands.ts"],"names":[],"mappings":"OAEO,EAAE,WAAW,EAAE;OACf,EAAE,UAAU,EAAE;OACd,EAAE,cAAc,EAAE;AAGzB,qBAAa,MAAO,SAAQ,WAAW;IACrC;;;;;OAKG;IACH,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,UAAU,CAAC,qBAAqB,CAAC;CAGtF;AAED,MAAM,WAAW,qBAAqB;IACpC;;OAEG;IACH,EAAE,EAAE,MAAM,CAAC;IAEX;;OAEG;IACH,WAAW,EAAE,QAAQ,GAAG,SAAS,GAAG,SAAS,CAAC;IAE9C;;;OAGG;IACH,SAAS,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,CAAC,OAAO,WAAW,MAAM,CAAC;IAC9B,OAAO,EAAE,KAAK,qBAAqB,IAAI,qBAAqB,EAAE,CAAC;CAChE"}
|
|
@@ -2,16 +2,16 @@
|
|
|
2
2
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.Brands = void 0;
|
|
5
|
-
const resource_1 = require("
|
|
6
|
-
const path_1 = require("
|
|
5
|
+
const resource_1 = require("../core/resource.js");
|
|
6
|
+
const path_1 = require("../internal/utils/path.js");
|
|
7
7
|
class Brands extends resource_1.APIResource {
|
|
8
8
|
/**
|
|
9
9
|
* Retrieve brand information by domain name
|
|
10
10
|
*
|
|
11
|
-
* Look up a brand by its domain name (e.g. "aloyoga.com").
|
|
12
|
-
* information including the marketplace type if the lookup succeeds.
|
|
11
|
+
* Look up a brand by its domain name (e.g. "aloyoga.com" or "www.amazon.com").
|
|
12
|
+
* Returns brand information including the marketplace type if the lookup succeeds.
|
|
13
13
|
*/
|
|
14
|
-
|
|
14
|
+
retrieve(domain, options) {
|
|
15
15
|
return this._client.get((0, path_1.path) `/api/v1/brands/domain/${domain}`, options);
|
|
16
16
|
}
|
|
17
17
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"brands.js","sourceRoot":"","sources":["../src/resources/brands.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;AAEtF,kDAA+C;AAG/C,oDAA8C;AAE9C,MAAa,MAAO,SAAQ,sBAAW;IACrC;;;;;OAKG;IACH,QAAQ,CAAC,MAAc,EAAE,OAAwB;QAC/C,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAA,WAAI,EAAA,yBAAyB,MAAM,EAAE,EAAE,OAAO,CAAC,CAAC;IAC1E,CAAC;CACF;AAVD,wBAUC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
import { APIResource } from "../core/resource.mjs";
|
|
3
|
+
import { path } from "../internal/utils/path.mjs";
|
|
4
|
+
export class Brands extends APIResource {
|
|
5
|
+
/**
|
|
6
|
+
* Retrieve brand information by domain name
|
|
7
|
+
*
|
|
8
|
+
* Look up a brand by its domain name (e.g. "aloyoga.com" or "www.amazon.com").
|
|
9
|
+
* Returns brand information including the marketplace type if the lookup succeeds.
|
|
10
|
+
*/
|
|
11
|
+
retrieve(domain, options) {
|
|
12
|
+
return this._client.get(path `/api/v1/brands/domain/${domain}`, options);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=brands.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"brands.mjs","sourceRoot":"","sources":["../src/resources/brands.ts"],"names":[],"mappings":"AAAA,sFAAsF;OAE/E,EAAE,WAAW,EAAE;OAGf,EAAE,IAAI,EAAE;AAEf,MAAM,OAAO,MAAO,SAAQ,WAAW;IACrC;;;;;OAKG;IACH,QAAQ,CAAC,MAAc,EAAE,OAAwB;QAC/C,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAA,yBAAyB,MAAM,EAAE,EAAE,OAAO,CAAC,CAAC;IAC1E,CAAC;CACF"}
|
|
@@ -0,0 +1,320 @@
|
|
|
1
|
+
import { APIResource } from "../core/resource.mjs";
|
|
2
|
+
import * as CheckoutIntentsAPI from "./checkout-intents.mjs";
|
|
3
|
+
import { APIPromise } from "../core/api-promise.mjs";
|
|
4
|
+
import { RequestOptions } from "../internal/request-options.mjs";
|
|
5
|
+
/**
|
|
6
|
+
* Options for polling operations.
|
|
7
|
+
*/
|
|
8
|
+
export interface PollOptions {
|
|
9
|
+
/**
|
|
10
|
+
* The interval in milliseconds between polling attempts.
|
|
11
|
+
*/
|
|
12
|
+
pollIntervalMs?: number;
|
|
13
|
+
/**
|
|
14
|
+
* The maximum number of polling attempts before timing out.
|
|
15
|
+
*/
|
|
16
|
+
maxAttempts?: number;
|
|
17
|
+
}
|
|
18
|
+
export declare class CheckoutIntentsResource extends APIResource {
|
|
19
|
+
/**
|
|
20
|
+
* Create a checkout intent with the given request body.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```ts
|
|
24
|
+
* const checkoutIntent = await client.checkoutIntents.create({
|
|
25
|
+
* buyer: {
|
|
26
|
+
* address1: '123 Main St',
|
|
27
|
+
* city: 'New York',
|
|
28
|
+
* country: 'United States',
|
|
29
|
+
* email: 'john.doe@example.com',
|
|
30
|
+
* firstName: 'John',
|
|
31
|
+
* lastName: 'Doe',
|
|
32
|
+
* phone: '+1234567890',
|
|
33
|
+
* postalCode: '10001',
|
|
34
|
+
* province: 'NY',
|
|
35
|
+
* },
|
|
36
|
+
* productUrl: 'productUrl',
|
|
37
|
+
* quantity: 1,
|
|
38
|
+
* });
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
create(body: CheckoutIntentCreateParams, options?: RequestOptions): APIPromise<CheckoutIntent>;
|
|
42
|
+
/**
|
|
43
|
+
* Retrieve a checkout intent by id
|
|
44
|
+
*
|
|
45
|
+
* Returns checkout intent information if the lookup succeeds.
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```ts
|
|
49
|
+
* const checkoutIntent =
|
|
50
|
+
* await client.checkoutIntents.retrieve('id');
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
retrieve(id: string, options?: RequestOptions): APIPromise<CheckoutIntent>;
|
|
54
|
+
/**
|
|
55
|
+
* Add payment details to a checkout intent
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* ```ts
|
|
59
|
+
* const checkoutIntent =
|
|
60
|
+
* await client.checkoutIntents.addPayment('id', {
|
|
61
|
+
* paymentMethod: {
|
|
62
|
+
* stripeToken: 'tok_1RkrWWHGDlstla3f1Fc7ZrhH',
|
|
63
|
+
* type: 'stripe_token',
|
|
64
|
+
* },
|
|
65
|
+
* });
|
|
66
|
+
* ```
|
|
67
|
+
*/
|
|
68
|
+
addPayment(id: string, body: CheckoutIntentAddPaymentParams, options?: RequestOptions): APIPromise<CheckoutIntent>;
|
|
69
|
+
/**
|
|
70
|
+
* Confirm a checkout intent with provided payment information
|
|
71
|
+
*
|
|
72
|
+
* Confirm means we have buyer's name, address and payment info, so we can move
|
|
73
|
+
* forward to place the order.
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* ```ts
|
|
77
|
+
* const checkoutIntent = await client.checkoutIntents.confirm(
|
|
78
|
+
* 'id',
|
|
79
|
+
* {
|
|
80
|
+
* paymentMethod: {
|
|
81
|
+
* stripeToken: 'tok_1RkrWWHGDlstla3f1Fc7ZrhH',
|
|
82
|
+
* type: 'stripe_token',
|
|
83
|
+
* },
|
|
84
|
+
* },
|
|
85
|
+
* );
|
|
86
|
+
* ```
|
|
87
|
+
*/
|
|
88
|
+
confirm(id: string, body: CheckoutIntentConfirmParams, options?: RequestOptions): APIPromise<CheckoutIntent>;
|
|
89
|
+
/**
|
|
90
|
+
* A helper to poll a checkout intent until a specific condition is met.
|
|
91
|
+
*
|
|
92
|
+
* @example
|
|
93
|
+
* ```ts
|
|
94
|
+
* // Poll until completed or failed
|
|
95
|
+
* const checkoutIntent = await client.checkoutIntents.pollUntil(
|
|
96
|
+
* 'id',
|
|
97
|
+
* (intent) => intent.state === 'completed' || intent.state === 'failed'
|
|
98
|
+
* );
|
|
99
|
+
* ```
|
|
100
|
+
*/
|
|
101
|
+
private pollUntil;
|
|
102
|
+
/**
|
|
103
|
+
* A helper to poll a checkout intent until it reaches a completed state
|
|
104
|
+
* (completed or failed).
|
|
105
|
+
*
|
|
106
|
+
* @example
|
|
107
|
+
* ```ts
|
|
108
|
+
* const checkoutIntent = await client.checkoutIntents.pollUntilCompleted('id');
|
|
109
|
+
* if (checkoutIntent.state === 'completed') {
|
|
110
|
+
* console.log('Order placed successfully!');
|
|
111
|
+
* } else if (checkoutIntent.state === 'failed') {
|
|
112
|
+
* console.log('Order failed:', checkoutIntent.failureReason);
|
|
113
|
+
* }
|
|
114
|
+
* ```
|
|
115
|
+
*/
|
|
116
|
+
pollUntilCompleted(id: string, options?: RequestOptions & PollOptions): Promise<CheckoutIntent.CompletedCheckoutIntent | CheckoutIntent.FailedCheckoutIntent>;
|
|
117
|
+
/**
|
|
118
|
+
* A helper to poll a checkout intent until it's ready for confirmation
|
|
119
|
+
* (awaiting_confirmation state) or has failed. This is typically used after
|
|
120
|
+
* creating a checkout intent to wait for the offer to be retrieved from the merchant.
|
|
121
|
+
*
|
|
122
|
+
* The intent can reach awaiting_confirmation (success - ready to confirm) or failed
|
|
123
|
+
* (offer retrieval failed). Always check the state after polling.
|
|
124
|
+
*
|
|
125
|
+
* @example
|
|
126
|
+
* ```ts
|
|
127
|
+
* const intent = await client.checkoutIntents.pollUntilAwaitingConfirmation('id');
|
|
128
|
+
*
|
|
129
|
+
* if (intent.state === 'awaiting_confirmation') {
|
|
130
|
+
* // Review the offer before confirming
|
|
131
|
+
* console.log('Total:', intent.offer.cost.total);
|
|
132
|
+
* } else if (intent.state === 'failed') {
|
|
133
|
+
* // Handle failure (e.g., offer retrieval failed, product out of stock)
|
|
134
|
+
* console.log('Failed:', intent.failureReason);
|
|
135
|
+
* }
|
|
136
|
+
* ```
|
|
137
|
+
*/
|
|
138
|
+
pollUntilAwaitingConfirmation(id: string, options?: RequestOptions & PollOptions): Promise<CheckoutIntent.AwaitingConfirmationCheckoutIntent | CheckoutIntent.FailedCheckoutIntent>;
|
|
139
|
+
/**
|
|
140
|
+
* A helper to create a checkout intent and poll until it's ready for confirmation.
|
|
141
|
+
* This follows the Rye documented flow: create → poll until awaiting_confirmation.
|
|
142
|
+
*
|
|
143
|
+
* After this method completes, you should review the offer (pricing, shipping, taxes)
|
|
144
|
+
* with the user before calling confirm().
|
|
145
|
+
*
|
|
146
|
+
* @example
|
|
147
|
+
* ```ts
|
|
148
|
+
* // Phase 1: Create and wait for offer
|
|
149
|
+
* const intent = await client.checkoutIntents.createAndPoll({
|
|
150
|
+
* buyer: {
|
|
151
|
+
* address1: '123 Main St',
|
|
152
|
+
* city: 'New York',
|
|
153
|
+
* country: 'United States',
|
|
154
|
+
* email: 'john.doe@example.com',
|
|
155
|
+
* firstName: 'John',
|
|
156
|
+
* lastName: 'Doe',
|
|
157
|
+
* phone: '+1234567890',
|
|
158
|
+
* postalCode: '10001',
|
|
159
|
+
* province: 'NY',
|
|
160
|
+
* },
|
|
161
|
+
* productUrl: 'https://example.com/product',
|
|
162
|
+
* quantity: 1,
|
|
163
|
+
* });
|
|
164
|
+
*
|
|
165
|
+
* // Review the offer with the user
|
|
166
|
+
* console.log('Total:', intent.offer.cost.total);
|
|
167
|
+
*
|
|
168
|
+
* // Phase 2: Confirm with payment
|
|
169
|
+
* const completed = await client.checkoutIntents.confirmAndPoll(intent.id, {
|
|
170
|
+
* paymentMethod: { type: 'stripe_token', stripeToken: 'tok_visa' }
|
|
171
|
+
* });
|
|
172
|
+
* ```
|
|
173
|
+
*/
|
|
174
|
+
createAndPoll(body: CheckoutIntentCreateParams, options?: RequestOptions & PollOptions): Promise<CheckoutIntent.AwaitingConfirmationCheckoutIntent | CheckoutIntent.FailedCheckoutIntent>;
|
|
175
|
+
/**
|
|
176
|
+
* A helper to confirm a checkout intent and poll until it reaches a completed state
|
|
177
|
+
* (completed or failed).
|
|
178
|
+
*
|
|
179
|
+
* @example
|
|
180
|
+
* ```ts
|
|
181
|
+
* const checkoutIntent = await client.checkoutIntents.confirmAndPoll(
|
|
182
|
+
* 'id',
|
|
183
|
+
* {
|
|
184
|
+
* paymentMethod: {
|
|
185
|
+
* stripeToken: 'tok_1RkrWWHGDlstla3f1Fc7ZrhH',
|
|
186
|
+
* type: 'stripe_token',
|
|
187
|
+
* },
|
|
188
|
+
* }
|
|
189
|
+
* );
|
|
190
|
+
*
|
|
191
|
+
* if (checkoutIntent.state === 'completed') {
|
|
192
|
+
* console.log('Order placed successfully!');
|
|
193
|
+
* } else if (checkoutIntent.state === 'failed') {
|
|
194
|
+
* console.log('Order failed:', checkoutIntent.failureReason);
|
|
195
|
+
* }
|
|
196
|
+
* ```
|
|
197
|
+
*/
|
|
198
|
+
confirmAndPoll(id: string, body: CheckoutIntentConfirmParams, options?: RequestOptions & PollOptions): Promise<CheckoutIntent.CompletedCheckoutIntent | CheckoutIntent.FailedCheckoutIntent>;
|
|
199
|
+
}
|
|
200
|
+
export interface BaseCheckoutIntent {
|
|
201
|
+
id: string;
|
|
202
|
+
buyer: Buyer;
|
|
203
|
+
createdAt: string;
|
|
204
|
+
productUrl: string;
|
|
205
|
+
quantity: number;
|
|
206
|
+
variantSelections?: Array<VariantSelection>;
|
|
207
|
+
}
|
|
208
|
+
export interface Buyer {
|
|
209
|
+
address1: string;
|
|
210
|
+
city: string;
|
|
211
|
+
country: string;
|
|
212
|
+
email: string;
|
|
213
|
+
firstName: string;
|
|
214
|
+
lastName: string;
|
|
215
|
+
phone: string;
|
|
216
|
+
postalCode: string;
|
|
217
|
+
province: string;
|
|
218
|
+
address2?: string;
|
|
219
|
+
}
|
|
220
|
+
export type CheckoutIntent = CheckoutIntent.RetrievingOfferCheckoutIntent | CheckoutIntent.AwaitingConfirmationCheckoutIntent | CheckoutIntent.PlacingOrderCheckoutIntent | CheckoutIntent.CompletedCheckoutIntent | CheckoutIntent.FailedCheckoutIntent;
|
|
221
|
+
export declare namespace CheckoutIntent {
|
|
222
|
+
interface RetrievingOfferCheckoutIntent extends CheckoutIntentsAPI.BaseCheckoutIntent {
|
|
223
|
+
state: 'retrieving_offer';
|
|
224
|
+
}
|
|
225
|
+
interface AwaitingConfirmationCheckoutIntent extends CheckoutIntentsAPI.BaseCheckoutIntent {
|
|
226
|
+
offer: CheckoutIntentsAPI.Offer;
|
|
227
|
+
state: 'awaiting_confirmation';
|
|
228
|
+
paymentMethod?: CheckoutIntentsAPI.PaymentMethod;
|
|
229
|
+
}
|
|
230
|
+
interface PlacingOrderCheckoutIntent extends CheckoutIntentsAPI.BaseCheckoutIntent {
|
|
231
|
+
offer: CheckoutIntentsAPI.Offer;
|
|
232
|
+
paymentMethod: CheckoutIntentsAPI.PaymentMethod;
|
|
233
|
+
state: 'placing_order';
|
|
234
|
+
}
|
|
235
|
+
interface CompletedCheckoutIntent extends CheckoutIntentsAPI.BaseCheckoutIntent {
|
|
236
|
+
offer: CheckoutIntentsAPI.Offer;
|
|
237
|
+
paymentMethod: CheckoutIntentsAPI.PaymentMethod;
|
|
238
|
+
state: 'completed';
|
|
239
|
+
}
|
|
240
|
+
interface FailedCheckoutIntent extends CheckoutIntentsAPI.BaseCheckoutIntent {
|
|
241
|
+
failureReason: FailedCheckoutIntent.FailureReason;
|
|
242
|
+
state: 'failed';
|
|
243
|
+
offer?: CheckoutIntentsAPI.Offer;
|
|
244
|
+
paymentMethod?: CheckoutIntentsAPI.PaymentMethod;
|
|
245
|
+
}
|
|
246
|
+
namespace FailedCheckoutIntent {
|
|
247
|
+
interface FailureReason {
|
|
248
|
+
code: 'checkout_intent_expired' | 'payment_failed' | 'insufficient_stock' | 'product_out_of_stock' | 'offer_retrieval_failed' | 'order_placement_failed' | 'developer_not_found' | 'missing_shipping_method' | 'unsupported_currency' | 'unsupported_store_no_guest_checkout';
|
|
249
|
+
message: string;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
export interface Money {
|
|
254
|
+
amountSubunits: number;
|
|
255
|
+
currencyCode: string;
|
|
256
|
+
}
|
|
257
|
+
export interface Offer {
|
|
258
|
+
cost: Offer.Cost;
|
|
259
|
+
shipping: Offer.Shipping;
|
|
260
|
+
}
|
|
261
|
+
export declare namespace Offer {
|
|
262
|
+
interface Cost {
|
|
263
|
+
subtotal: CheckoutIntentsAPI.Money;
|
|
264
|
+
total: CheckoutIntentsAPI.Money;
|
|
265
|
+
discount?: CheckoutIntentsAPI.Money;
|
|
266
|
+
shipping?: CheckoutIntentsAPI.Money;
|
|
267
|
+
tax?: CheckoutIntentsAPI.Money;
|
|
268
|
+
}
|
|
269
|
+
interface Shipping {
|
|
270
|
+
availableOptions: Array<Shipping.AvailableOption>;
|
|
271
|
+
selectedOptionId?: string;
|
|
272
|
+
}
|
|
273
|
+
namespace Shipping {
|
|
274
|
+
interface AvailableOption {
|
|
275
|
+
id: string;
|
|
276
|
+
cost: CheckoutIntentsAPI.Money;
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
export type PaymentMethod = PaymentMethod.StripeTokenPaymentMethod | PaymentMethod.BasisTheoryPaymentMethod | PaymentMethod.NekudaPaymentMethod;
|
|
281
|
+
export declare namespace PaymentMethod {
|
|
282
|
+
interface StripeTokenPaymentMethod {
|
|
283
|
+
stripeToken: string;
|
|
284
|
+
type: 'stripe_token';
|
|
285
|
+
}
|
|
286
|
+
interface BasisTheoryPaymentMethod {
|
|
287
|
+
basisTheoryToken: string;
|
|
288
|
+
type: 'basis_theory_token';
|
|
289
|
+
}
|
|
290
|
+
interface NekudaPaymentMethod {
|
|
291
|
+
nekudaUserId: string;
|
|
292
|
+
type: 'nekuda_token';
|
|
293
|
+
/**
|
|
294
|
+
* Construct a type with a set of properties K of type T
|
|
295
|
+
*/
|
|
296
|
+
nekudaMandateData?: {
|
|
297
|
+
[key: string]: string | number;
|
|
298
|
+
};
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
export interface VariantSelection {
|
|
302
|
+
label: string;
|
|
303
|
+
value: string | number;
|
|
304
|
+
}
|
|
305
|
+
export interface CheckoutIntentCreateParams {
|
|
306
|
+
buyer: Buyer;
|
|
307
|
+
productUrl: string;
|
|
308
|
+
quantity: number;
|
|
309
|
+
variantSelections?: Array<VariantSelection>;
|
|
310
|
+
}
|
|
311
|
+
export interface CheckoutIntentAddPaymentParams {
|
|
312
|
+
paymentMethod: PaymentMethod;
|
|
313
|
+
}
|
|
314
|
+
export interface CheckoutIntentConfirmParams {
|
|
315
|
+
paymentMethod: PaymentMethod;
|
|
316
|
+
}
|
|
317
|
+
export declare namespace CheckoutIntentsResource {
|
|
318
|
+
export { type BaseCheckoutIntent as BaseCheckoutIntent, type Buyer as Buyer, type CheckoutIntent as CheckoutIntent, type Money as Money, type Offer as Offer, type PaymentMethod as PaymentMethod, type PollOptions as PollOptions, type VariantSelection as VariantSelection, type CheckoutIntentCreateParams as CheckoutIntentCreateParams, type CheckoutIntentAddPaymentParams as CheckoutIntentAddPaymentParams, type CheckoutIntentConfirmParams as CheckoutIntentConfirmParams, };
|
|
319
|
+
}
|
|
320
|
+
//# sourceMappingURL=checkout-intents.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checkout-intents.d.mts","sourceRoot":"","sources":["../src/resources/checkout-intents.ts"],"names":[],"mappings":"OAEO,EAAE,WAAW,EAAE;OACf,KAAK,kBAAkB;OACvB,EAAE,UAAU,EAAE;OACd,EAAE,cAAc,EAAE;AAKzB;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB;;OAEG;IACH,WAAW,CAAC,EAAE,MA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