@bates-solutions/squareup 1.0.0 → 1.2.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/dist/core/client.d.ts +2 -0
- package/dist/core/client.d.ts.map +1 -1
- package/dist/core/client.js +3 -0
- package/dist/core/client.js.map +1 -1
- package/dist/core/index.d.ts +1 -0
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +1 -0
- package/dist/core/index.js.map +1 -1
- package/dist/core/services/catalog.service.d.ts +61 -1
- package/dist/core/services/catalog.service.d.ts.map +1 -1
- package/dist/core/services/catalog.service.js +47 -0
- package/dist/core/services/catalog.service.js.map +1 -1
- package/dist/core/services/checkout.service.d.ts +271 -0
- package/dist/core/services/checkout.service.d.ts.map +1 -0
- package/dist/core/services/checkout.service.js +229 -0
- package/dist/core/services/checkout.service.js.map +1 -0
- package/package.json +1 -1
package/dist/core/client.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ import { InventoryService } from './services/inventory.service.js';
|
|
|
8
8
|
import { SubscriptionsService } from './services/subscriptions.service.js';
|
|
9
9
|
import { InvoicesService } from './services/invoices.service.js';
|
|
10
10
|
import { LoyaltyService } from './services/loyalty.service.js';
|
|
11
|
+
import { CheckoutService } from './services/checkout.service.js';
|
|
11
12
|
/**
|
|
12
13
|
* Configuration options for the Square client
|
|
13
14
|
*/
|
|
@@ -60,6 +61,7 @@ export declare class SquareClient {
|
|
|
60
61
|
readonly subscriptions: SubscriptionsService;
|
|
61
62
|
readonly invoices: InvoicesService;
|
|
62
63
|
readonly loyalty: LoyaltyService;
|
|
64
|
+
readonly checkout: CheckoutService;
|
|
63
65
|
constructor(config: SquareClientConfig);
|
|
64
66
|
/**
|
|
65
67
|
* Get the underlying Square SDK client
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/core/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,IAAI,SAAS,E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AAE,MAAM,CAAC;IAEpB;;;OAGG;IACH,WAAW,CAAC,EAAE,iBAAiB,CAAC;IAEhC;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;;OAGG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAY;IACnC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAErB;IAEF,SAAgB,QAAQ,EAAE,eAAe,CAAC;IAC1C,SAAgB,MAAM,EAAE,aAAa,CAAC;IACtC,SAAgB,SAAS,EAAE,gBAAgB,CAAC;IAC5C,SAAgB,OAAO,EAAE,cAAc,CAAC;IACxC,SAAgB,SAAS,EAAE,gBAAgB,CAAC;IAC5C,SAAgB,aAAa,EAAE,oBAAoB,CAAC;IACpD,SAAgB,QAAQ,EAAE,eAAe,CAAC;IAC1C,SAAgB,OAAO,EAAE,cAAc,CAAC;IACxC,SAAgB,QAAQ,EAAE,eAAe,CAAC;gBAE9B,MAAM,EAAE,kBAAkB;IA4BtC;;;OAGG;IACH,IAAI,GAAG,IAAI,SAAS,CAEnB;IAED;;OAEG;IACH,IAAI,UAAU,IAAI,MAAM,GAAG,SAAS,CAEnC;IAED;;OAEG;IACH,IAAI,WAAW,IAAI,iBAAiB,CAEnC;CACF;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,kBAAkB,GAAG,YAAY,CAE3E"}
|
package/dist/core/client.js
CHANGED
|
@@ -7,6 +7,7 @@ import { InventoryService } from './services/inventory.service.js';
|
|
|
7
7
|
import { SubscriptionsService } from './services/subscriptions.service.js';
|
|
8
8
|
import { InvoicesService } from './services/invoices.service.js';
|
|
9
9
|
import { LoyaltyService } from './services/loyalty.service.js';
|
|
10
|
+
import { CheckoutService } from './services/checkout.service.js';
|
|
10
11
|
/**
|
|
11
12
|
* Main Square client wrapper
|
|
12
13
|
*
|
|
@@ -36,6 +37,7 @@ export class SquareClient {
|
|
|
36
37
|
subscriptions;
|
|
37
38
|
invoices;
|
|
38
39
|
loyalty;
|
|
40
|
+
checkout;
|
|
39
41
|
constructor(config) {
|
|
40
42
|
this.config = {
|
|
41
43
|
accessToken: config.accessToken,
|
|
@@ -58,6 +60,7 @@ export class SquareClient {
|
|
|
58
60
|
this.subscriptions = new SubscriptionsService(this.client, this.config.locationId);
|
|
59
61
|
this.invoices = new InvoicesService(this.client, this.config.locationId);
|
|
60
62
|
this.loyalty = new LoyaltyService(this.client, this.config.locationId);
|
|
63
|
+
this.checkout = new CheckoutService(this.client);
|
|
61
64
|
}
|
|
62
65
|
/**
|
|
63
66
|
* Get the underlying Square SDK client
|
package/dist/core/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/core/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,IAAI,SAAS,EAAE,iBAAiB,IAAI,cAAc,EAAE,MAAM,QAAQ,CAAC;AAExF,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAC7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,qCAAqC,CAAC;AAC3E,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/core/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,IAAI,SAAS,EAAE,iBAAiB,IAAI,cAAc,EAAE,MAA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AED;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,kBAAkB,CAAC,MAA0B;IAC3D,OAAO,IAAI,YAAY,CAAC,MAAM,CAAC,CAAC;AAClC,CAAC"}
|
package/dist/core/index.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ export { InventoryService } from './services/inventory.service.js';
|
|
|
8
8
|
export { SubscriptionsService } from './services/subscriptions.service.js';
|
|
9
9
|
export { InvoicesService } from './services/invoices.service.js';
|
|
10
10
|
export { LoyaltyService } from './services/loyalty.service.js';
|
|
11
|
+
export { CheckoutService } from './services/checkout.service.js';
|
|
11
12
|
export { OrderBuilder } from './builders/order.builder.js';
|
|
12
13
|
export { SquareError, SquareApiError, SquareAuthError, SquarePaymentError, SquareValidationError, } from './errors.js';
|
|
13
14
|
export type { SquareErrorCode } from './errors.js';
|
package/dist/core/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC/D,YAAY,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAGtD,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAC7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,qCAAqC,CAAC;AAC3E,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC/D,YAAY,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAGtD,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAC7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,qCAAqC,CAAC;AAC3E,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAGjE,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAG3D,OAAO,EACL,WAAW,EACX,cAAc,EACd,eAAe,EACf,kBAAkB,EAClB,qBAAqB,GACtB,MAAM,aAAa,CAAC;AACrB,YAAY,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAGnD,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AACnF,YAAY,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAGxC,mBAAmB,kBAAkB,CAAC"}
|
package/dist/core/index.js
CHANGED
|
@@ -9,6 +9,7 @@ export { InventoryService } from './services/inventory.service.js';
|
|
|
9
9
|
export { SubscriptionsService } from './services/subscriptions.service.js';
|
|
10
10
|
export { InvoicesService } from './services/invoices.service.js';
|
|
11
11
|
export { LoyaltyService } from './services/loyalty.service.js';
|
|
12
|
+
export { CheckoutService } from './services/checkout.service.js';
|
|
12
13
|
// Builders
|
|
13
14
|
export { OrderBuilder } from './builders/order.builder.js';
|
|
14
15
|
// Errors
|
package/dist/core/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAG/D,WAAW;AACX,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAC7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,qCAAqC,CAAC;AAC3E,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAG/D,WAAW;AACX,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAC7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,qCAAqC,CAAC;AAC3E,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAEjE,WAAW;AACX,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAE3D,SAAS;AACT,OAAO,EACL,WAAW,EACX,cAAc,EACd,eAAe,EACf,kBAAkB,EAClB,qBAAqB,GACtB,MAAM,aAAa,CAAC;AAGrB,QAAQ;AACR,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -3,7 +3,32 @@ import type { CurrencyCode } from '../types/index.js';
|
|
|
3
3
|
/**
|
|
4
4
|
* Catalog item type
|
|
5
5
|
*/
|
|
6
|
-
export type CatalogObjectType = 'ITEM' | 'ITEM_VARIATION' | 'CATEGORY' | 'DISCOUNT' | 'TAX' | 'MODIFIER' | 'MODIFIER_LIST' | 'IMAGE';
|
|
6
|
+
export type CatalogObjectType = 'ITEM' | 'ITEM_VARIATION' | 'CATEGORY' | 'DISCOUNT' | 'TAX' | 'MODIFIER' | 'MODIFIER_LIST' | 'IMAGE' | 'CUSTOM_ATTRIBUTE_DEFINITION';
|
|
7
|
+
/**
|
|
8
|
+
* Custom attribute value for catalog items
|
|
9
|
+
*/
|
|
10
|
+
export interface CatalogCustomAttributeValue {
|
|
11
|
+
name?: string;
|
|
12
|
+
stringValue?: string;
|
|
13
|
+
customAttributeDefinitionId?: string;
|
|
14
|
+
type?: 'STRING' | 'BOOLEAN' | 'NUMBER' | 'SELECTION';
|
|
15
|
+
numberValue?: string;
|
|
16
|
+
booleanValue?: boolean;
|
|
17
|
+
selectionUidValues?: string[];
|
|
18
|
+
key?: string;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Custom attribute definition data
|
|
22
|
+
*/
|
|
23
|
+
export interface CustomAttributeDefinitionData {
|
|
24
|
+
type?: 'STRING' | 'BOOLEAN' | 'NUMBER' | 'SELECTION';
|
|
25
|
+
name?: string;
|
|
26
|
+
description?: string;
|
|
27
|
+
allowedObjectTypes?: CatalogObjectType[];
|
|
28
|
+
sellerVisibility?: 'SELLER_VISIBILITY_HIDDEN' | 'SELLER_VISIBILITY_READ_WRITE_VALUES';
|
|
29
|
+
appVisibility?: 'APP_VISIBILITY_HIDDEN' | 'APP_VISIBILITY_READ_ONLY' | 'APP_VISIBILITY_READ_WRITE_VALUES';
|
|
30
|
+
key?: string;
|
|
31
|
+
}
|
|
7
32
|
/**
|
|
8
33
|
* Catalog object from Square API
|
|
9
34
|
*/
|
|
@@ -15,6 +40,7 @@ export interface CatalogObject {
|
|
|
15
40
|
isDeleted?: boolean;
|
|
16
41
|
presentAtAllLocations?: boolean;
|
|
17
42
|
presentAtLocationIds?: string[];
|
|
43
|
+
customAttributeValues?: Record<string, CatalogCustomAttributeValue>;
|
|
18
44
|
itemData?: {
|
|
19
45
|
name?: string;
|
|
20
46
|
description?: string;
|
|
@@ -49,6 +75,7 @@ export interface CatalogObject {
|
|
|
49
75
|
percentage?: string;
|
|
50
76
|
inclusionType?: 'ADDITIVE' | 'INCLUSIVE';
|
|
51
77
|
};
|
|
78
|
+
customAttributeDefinitionData?: CustomAttributeDefinitionData;
|
|
52
79
|
}
|
|
53
80
|
/**
|
|
54
81
|
* Options for creating a catalog item
|
|
@@ -140,6 +167,39 @@ export declare class CatalogService {
|
|
|
140
167
|
* ```
|
|
141
168
|
*/
|
|
142
169
|
createCategory(options: CreateCategoryOptions): Promise<CatalogObject>;
|
|
170
|
+
/**
|
|
171
|
+
* Upsert (create or update) a catalog object
|
|
172
|
+
*
|
|
173
|
+
* @param catalogObject - The catalog object to upsert
|
|
174
|
+
* @param idempotencyKey - Optional idempotency key
|
|
175
|
+
* @returns The upserted catalog object
|
|
176
|
+
*
|
|
177
|
+
* @example
|
|
178
|
+
* ```typescript
|
|
179
|
+
* // Update an existing item's custom attributes
|
|
180
|
+
* const updatedItem = await square.catalog.upsert({
|
|
181
|
+
* type: 'ITEM',
|
|
182
|
+
* id: 'EXISTING_ITEM_ID',
|
|
183
|
+
* version: existingItem.version,
|
|
184
|
+
* customAttributeValues: {
|
|
185
|
+
* 'Square:some-key': { stringValue: 'new value' }
|
|
186
|
+
* },
|
|
187
|
+
* itemData: existingItem.itemData,
|
|
188
|
+
* });
|
|
189
|
+
*
|
|
190
|
+
* // Update a variation price
|
|
191
|
+
* const updatedVariation = await square.catalog.upsert({
|
|
192
|
+
* type: 'ITEM_VARIATION',
|
|
193
|
+
* id: 'EXISTING_VARIATION_ID',
|
|
194
|
+
* version: existingVariation.version,
|
|
195
|
+
* itemVariationData: {
|
|
196
|
+
* ...existingVariation.itemVariationData,
|
|
197
|
+
* priceMoney: { amount: BigInt(500), currency: 'USD' },
|
|
198
|
+
* },
|
|
199
|
+
* });
|
|
200
|
+
* ```
|
|
201
|
+
*/
|
|
202
|
+
upsert(catalogObject: CatalogObject, idempotencyKey?: string): Promise<CatalogObject>;
|
|
143
203
|
/**
|
|
144
204
|
* Get a catalog object by ID
|
|
145
205
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"catalog.service.d.ts","sourceRoot":"","sources":["../../../src/core/services/catalog.service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,
|
|
1
|
+
{"version":3,"file":"catalog.service.d.ts","sourceRoot":"","sources":["../../../src/core/services/catalog.service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAwC,MAAM,QAAQ,CAAC;AAGjF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEtD;;GAEG;AACH,MAAM,MAAM,iBAAiB,GACzB,MAAM,GACN,gBAAgB,GAChB,UAAU,GACV,UAAU,GACV,KAAK,GACL,UAAU,GACV,eAAe,GACf,OAAO,GACP,6BAA6B,CAAC;AAElC;;GAEG;AACH,MAAM,WAAW,2BAA2B;IAC1C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,2BAA2B,C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,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,GAC3B,OAAO,CAAC,aAAa,EAAE,CAAC;IAsB3B;;;;;;;;;;OAUG;IACG,QAAQ,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;CAgB9D"}
|
|
@@ -126,6 +126,53 @@ export class CatalogService {
|
|
|
126
126
|
throw parseSquareError(error);
|
|
127
127
|
}
|
|
128
128
|
}
|
|
129
|
+
/**
|
|
130
|
+
* Upsert (create or update) a catalog object
|
|
131
|
+
*
|
|
132
|
+
* @param catalogObject - The catalog object to upsert
|
|
133
|
+
* @param idempotencyKey - Optional idempotency key
|
|
134
|
+
* @returns The upserted catalog object
|
|
135
|
+
*
|
|
136
|
+
* @example
|
|
137
|
+
* ```typescript
|
|
138
|
+
* // Update an existing item's custom attributes
|
|
139
|
+
* const updatedItem = await square.catalog.upsert({
|
|
140
|
+
* type: 'ITEM',
|
|
141
|
+
* id: 'EXISTING_ITEM_ID',
|
|
142
|
+
* version: existingItem.version,
|
|
143
|
+
* customAttributeValues: {
|
|
144
|
+
* 'Square:some-key': { stringValue: 'new value' }
|
|
145
|
+
* },
|
|
146
|
+
* itemData: existingItem.itemData,
|
|
147
|
+
* });
|
|
148
|
+
*
|
|
149
|
+
* // Update a variation price
|
|
150
|
+
* const updatedVariation = await square.catalog.upsert({
|
|
151
|
+
* type: 'ITEM_VARIATION',
|
|
152
|
+
* id: 'EXISTING_VARIATION_ID',
|
|
153
|
+
* version: existingVariation.version,
|
|
154
|
+
* itemVariationData: {
|
|
155
|
+
* ...existingVariation.itemVariationData,
|
|
156
|
+
* priceMoney: { amount: BigInt(500), currency: 'USD' },
|
|
157
|
+
* },
|
|
158
|
+
* });
|
|
159
|
+
* ```
|
|
160
|
+
*/
|
|
161
|
+
async upsert(catalogObject, idempotencyKey) {
|
|
162
|
+
try {
|
|
163
|
+
const response = await this.client.catalog.object.upsert({
|
|
164
|
+
idempotencyKey: idempotencyKey ?? createIdempotencyKey(),
|
|
165
|
+
object: catalogObject,
|
|
166
|
+
});
|
|
167
|
+
if (!response.catalogObject) {
|
|
168
|
+
throw new Error('Catalog object was not upserted');
|
|
169
|
+
}
|
|
170
|
+
return response.catalogObject;
|
|
171
|
+
}
|
|
172
|
+
catch (error) {
|
|
173
|
+
throw parseSquareError(error);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
129
176
|
/**
|
|
130
177
|
* Get a catalog object by ID
|
|
131
178
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"catalog.service.js","sourceRoot":"","sources":["../../../src/core/services/catalog.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AACvE,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"catalog.service.js","sourceRoot":"","sources":["../../../src/core/services/catalog.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AACvE,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAgInD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,OAAO,cAAc;IACI;IAA7B,YAA6B,MAAoB;QAApB,WAAM,GAAN,MAAM,CAAc;IAAG,CAAC;IAErD;;;;;;;;;;;;;;;;;;OAkBG;IACH,KAAK,CAAC,UAAU,CAAC,OAAiC;QAChD,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;YAClB,MAAM,IAAI,qBAAqB,CAAC,uBAAuB,EAAE,MAAM,CAAC,CAAC;QACnE,CAAC;QACD,IAAI,OAAO,CAAC,UAAU,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACpC,MAAM,IAAI,qBAAqB,CAAC,oCAAoC,EAAE,YAAY,CAAC,CAAC;QACtF,CAAC;QAED,MAAM,MAAM,GAAG,SAAS,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C,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC;gBAClD,SAAS;gBACT,qBAAqB,EAAE,IAAI;aAC5B,CAAC,CAAC;YAEH,OAAO,CAAC,QAAQ,CAAC,OAAO,IAAI,EAAE,CAAoB,CAAC;QACrD,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,gBAAgB,CAAC,KAAK,CAAC,CAAC;QAChC,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
import type { SquareClient } from 'square';
|
|
2
|
+
/**
|
|
3
|
+
* Money representation for checkout
|
|
4
|
+
*/
|
|
5
|
+
export interface CheckoutMoney {
|
|
6
|
+
amount?: bigint;
|
|
7
|
+
currency?: string;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Address for checkout
|
|
11
|
+
*/
|
|
12
|
+
export interface CheckoutAddress {
|
|
13
|
+
addressLine1?: string;
|
|
14
|
+
addressLine2?: string;
|
|
15
|
+
addressLine3?: string;
|
|
16
|
+
locality?: string;
|
|
17
|
+
sublocality?: string;
|
|
18
|
+
administrativeDistrictLevel1?: string;
|
|
19
|
+
postalCode?: string;
|
|
20
|
+
country?: string;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Checkout options for payment links
|
|
24
|
+
*/
|
|
25
|
+
export interface CheckoutOptions {
|
|
26
|
+
allowTipping?: boolean;
|
|
27
|
+
customFields?: Array<{
|
|
28
|
+
title: string;
|
|
29
|
+
}>;
|
|
30
|
+
subscriptionPlanId?: string;
|
|
31
|
+
redirectUrl?: string;
|
|
32
|
+
merchantSupportEmail?: string;
|
|
33
|
+
askForShippingAddress?: boolean;
|
|
34
|
+
acceptedPaymentMethods?: {
|
|
35
|
+
applePay?: boolean;
|
|
36
|
+
googlePay?: boolean;
|
|
37
|
+
cashAppPay?: boolean;
|
|
38
|
+
afterpayClearpay?: boolean;
|
|
39
|
+
};
|
|
40
|
+
appFeeMoney?: CheckoutMoney;
|
|
41
|
+
shippingFee?: {
|
|
42
|
+
name?: string;
|
|
43
|
+
charge?: CheckoutMoney;
|
|
44
|
+
};
|
|
45
|
+
enableCoupon?: boolean;
|
|
46
|
+
enableLoyalty?: boolean;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Pre-populated data for checkout
|
|
50
|
+
*/
|
|
51
|
+
export interface PrePopulatedData {
|
|
52
|
+
buyerEmail?: string;
|
|
53
|
+
buyerPhoneNumber?: string;
|
|
54
|
+
buyerAddress?: CheckoutAddress;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Quick pay configuration for simple payment links
|
|
58
|
+
*/
|
|
59
|
+
export interface QuickPay {
|
|
60
|
+
name: string;
|
|
61
|
+
priceMoney: CheckoutMoney;
|
|
62
|
+
locationId: string;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Order line item for checkout
|
|
66
|
+
*/
|
|
67
|
+
export interface CheckoutLineItem {
|
|
68
|
+
name?: string;
|
|
69
|
+
quantity: string;
|
|
70
|
+
itemType?: string;
|
|
71
|
+
basePriceMoney?: CheckoutMoney;
|
|
72
|
+
catalogObjectId?: string;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Order configuration for checkout
|
|
76
|
+
*/
|
|
77
|
+
export interface CheckoutOrder {
|
|
78
|
+
locationId: string;
|
|
79
|
+
lineItems?: CheckoutLineItem[];
|
|
80
|
+
referenceId?: string;
|
|
81
|
+
customerId?: string;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Payment link object from Square API
|
|
85
|
+
*/
|
|
86
|
+
export interface PaymentLink {
|
|
87
|
+
id?: string;
|
|
88
|
+
version?: number;
|
|
89
|
+
description?: string;
|
|
90
|
+
orderId?: string;
|
|
91
|
+
checkoutOptions?: CheckoutOptions;
|
|
92
|
+
prePopulatedData?: PrePopulatedData;
|
|
93
|
+
url?: string;
|
|
94
|
+
longUrl?: string;
|
|
95
|
+
createdAt?: string;
|
|
96
|
+
updatedAt?: string;
|
|
97
|
+
paymentNote?: string;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Options for creating a payment link
|
|
101
|
+
*/
|
|
102
|
+
export interface CreatePaymentLinkOptions {
|
|
103
|
+
idempotencyKey?: string;
|
|
104
|
+
description?: string;
|
|
105
|
+
quickPay?: QuickPay;
|
|
106
|
+
order?: CheckoutOrder;
|
|
107
|
+
checkoutOptions?: CheckoutOptions;
|
|
108
|
+
prePopulatedData?: PrePopulatedData;
|
|
109
|
+
paymentNote?: string;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Options for updating a payment link
|
|
113
|
+
*/
|
|
114
|
+
export interface UpdatePaymentLinkOptions {
|
|
115
|
+
paymentLink: {
|
|
116
|
+
version: number;
|
|
117
|
+
description?: string;
|
|
118
|
+
checkoutOptions?: CheckoutOptions;
|
|
119
|
+
prePopulatedData?: PrePopulatedData;
|
|
120
|
+
paymentNote?: string;
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Options for listing payment links
|
|
125
|
+
*/
|
|
126
|
+
export interface ListPaymentLinksOptions {
|
|
127
|
+
cursor?: string;
|
|
128
|
+
limit?: number;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Payment links sub-service
|
|
132
|
+
*/
|
|
133
|
+
declare class PaymentLinksService {
|
|
134
|
+
private readonly client;
|
|
135
|
+
constructor(client: SquareClient);
|
|
136
|
+
/**
|
|
137
|
+
* Create a payment link
|
|
138
|
+
*
|
|
139
|
+
* @param options - Payment link creation options
|
|
140
|
+
* @returns Created payment link
|
|
141
|
+
*
|
|
142
|
+
* @throws {SquareValidationError} When input validation fails
|
|
143
|
+
*
|
|
144
|
+
* @example
|
|
145
|
+
* ```typescript
|
|
146
|
+
* // Create with quick pay
|
|
147
|
+
* const link = await square.checkout.paymentLinks.create({
|
|
148
|
+
* quickPay: {
|
|
149
|
+
* name: 'Auto Detailing',
|
|
150
|
+
* priceMoney: { amount: BigInt(1000), currency: 'USD' },
|
|
151
|
+
* locationId: 'LXXX',
|
|
152
|
+
* },
|
|
153
|
+
* checkoutOptions: {
|
|
154
|
+
* askForShippingAddress: true,
|
|
155
|
+
* },
|
|
156
|
+
* });
|
|
157
|
+
*
|
|
158
|
+
* // Create with order
|
|
159
|
+
* const link = await square.checkout.paymentLinks.create({
|
|
160
|
+
* order: {
|
|
161
|
+
* locationId: 'LXXX',
|
|
162
|
+
* lineItems: [
|
|
163
|
+
* { name: 'Product', quantity: '1', basePriceMoney: { amount: BigInt(1000), currency: 'USD' } },
|
|
164
|
+
* ],
|
|
165
|
+
* },
|
|
166
|
+
* });
|
|
167
|
+
* ```
|
|
168
|
+
*/
|
|
169
|
+
create(options: CreatePaymentLinkOptions): Promise<PaymentLink>;
|
|
170
|
+
/**
|
|
171
|
+
* Get a payment link by ID
|
|
172
|
+
*
|
|
173
|
+
* @param id - Payment link ID
|
|
174
|
+
* @returns Payment link details
|
|
175
|
+
*
|
|
176
|
+
* @example
|
|
177
|
+
* ```typescript
|
|
178
|
+
* const link = await square.checkout.paymentLinks.get('LINK_123');
|
|
179
|
+
* ```
|
|
180
|
+
*/
|
|
181
|
+
get(id: string): Promise<PaymentLink>;
|
|
182
|
+
/**
|
|
183
|
+
* Update a payment link
|
|
184
|
+
*
|
|
185
|
+
* @param id - Payment link ID to update
|
|
186
|
+
* @param options - Update options including required version
|
|
187
|
+
* @returns Updated payment link
|
|
188
|
+
*
|
|
189
|
+
* @example
|
|
190
|
+
* ```typescript
|
|
191
|
+
* const link = await square.checkout.paymentLinks.update('LINK_123', {
|
|
192
|
+
* paymentLink: {
|
|
193
|
+
* version: 1,
|
|
194
|
+
* description: 'Updated description',
|
|
195
|
+
* checkoutOptions: {
|
|
196
|
+
* askForShippingAddress: false,
|
|
197
|
+
* },
|
|
198
|
+
* },
|
|
199
|
+
* });
|
|
200
|
+
* ```
|
|
201
|
+
*/
|
|
202
|
+
update(id: string, options: UpdatePaymentLinkOptions): Promise<PaymentLink>;
|
|
203
|
+
/**
|
|
204
|
+
* Delete a payment link
|
|
205
|
+
*
|
|
206
|
+
* @param id - Payment link ID to delete
|
|
207
|
+
*
|
|
208
|
+
* @example
|
|
209
|
+
* ```typescript
|
|
210
|
+
* await square.checkout.paymentLinks.delete('LINK_123');
|
|
211
|
+
* ```
|
|
212
|
+
*/
|
|
213
|
+
delete(id: string): Promise<void>;
|
|
214
|
+
/**
|
|
215
|
+
* List payment links with optional pagination
|
|
216
|
+
*
|
|
217
|
+
* @param options - List options
|
|
218
|
+
* @returns Array of payment links with optional cursor for pagination
|
|
219
|
+
*
|
|
220
|
+
* @example
|
|
221
|
+
* ```typescript
|
|
222
|
+
* // List all (up to limit)
|
|
223
|
+
* const links = await square.checkout.paymentLinks.list({ limit: 50 });
|
|
224
|
+
*
|
|
225
|
+
* // Paginate through results
|
|
226
|
+
* const firstPage = await square.checkout.paymentLinks.list({ limit: 10 });
|
|
227
|
+
* if (firstPage.cursor) {
|
|
228
|
+
* const nextPage = await square.checkout.paymentLinks.list({
|
|
229
|
+
* limit: 10,
|
|
230
|
+
* cursor: firstPage.cursor,
|
|
231
|
+
* });
|
|
232
|
+
* }
|
|
233
|
+
* ```
|
|
234
|
+
*/
|
|
235
|
+
list(options?: ListPaymentLinksOptions): Promise<{
|
|
236
|
+
data: PaymentLink[];
|
|
237
|
+
cursor?: string;
|
|
238
|
+
}>;
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Checkout service for Square Checkout API
|
|
242
|
+
*
|
|
243
|
+
* @example
|
|
244
|
+
* ```typescript
|
|
245
|
+
* const square = createSquareClient({ ... });
|
|
246
|
+
*
|
|
247
|
+
* // Create a payment link
|
|
248
|
+
* const link = await square.checkout.paymentLinks.create({
|
|
249
|
+
* quickPay: {
|
|
250
|
+
* name: 'Auto Detailing',
|
|
251
|
+
* priceMoney: { amount: BigInt(5000), currency: 'USD' },
|
|
252
|
+
* locationId: 'LXXX',
|
|
253
|
+
* },
|
|
254
|
+
* checkoutOptions: {
|
|
255
|
+
* redirectUrl: 'https://example.com/confirmation',
|
|
256
|
+
* askForShippingAddress: true,
|
|
257
|
+
* },
|
|
258
|
+
* prePopulatedData: {
|
|
259
|
+
* buyerEmail: 'customer@example.com',
|
|
260
|
+
* },
|
|
261
|
+
* });
|
|
262
|
+
*
|
|
263
|
+
* console.log('Checkout URL:', link.url);
|
|
264
|
+
* ```
|
|
265
|
+
*/
|
|
266
|
+
export declare class CheckoutService {
|
|
267
|
+
readonly paymentLinks: PaymentLinksService;
|
|
268
|
+
constructor(client: SquareClient);
|
|
269
|
+
}
|
|
270
|
+
export {};
|
|
271
|
+
//# sourceMappingURL=checkout.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checkout.service.d.ts","sourceRoot":"","sources":["../../../src/core/services/checkout.service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EAMb,MAAM,QAAQ,CAAC;AAIhB;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,4BAA4B,CAAC,EAAE,MAAM,CAAC;IACtC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,YAAY,CAAC,EAAE,KAAK,CAAC;QACnB,KAAK,EAAE,MAAM,CAAC;KACf,CAAC,CAAC;IACH,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EjD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAgCG;IACG,MAAM,CAAC,OAAO,EAAE,wBAAwB,GAAG,OAAO,CAAC,WAAW,CAAC;IA6BrE;;;;;;;;;;OAUG;IACG,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;IAkB3C;;;;;;;;;;;;;;;;;;;OAmBG;IACG,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,wBAAwB,GAAG,OAAO,CAAC,WAAW,CAAC;IAqBjF;;;;;;;;;OASG;IACG,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAYvC;;;;;;;;;;;;;;;;;;;;OAoBG;IACG,IAAI,CAAC,OAAO,CAAC,EAAE,uBAAuB,GAAG,OAAO,CAAC;QACrD,IAAI,EAAE,WAAW,EAAE,CAAC;QACpB,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB,CAAC;CAyBH;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,qBAAa,eAAe;IAC1B,SAAgB,YAAY,EAAE,mBAAmB,CAAC;gBAEtC,MAAM,EAAE,YAAY;CAGjC"}
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
import { parseSquareError, SquareValidationError } from '../errors.js';
|
|
2
|
+
import { createIdempotencyKey } from '../utils.js';
|
|
3
|
+
/**
|
|
4
|
+
* Payment links sub-service
|
|
5
|
+
*/
|
|
6
|
+
class PaymentLinksService {
|
|
7
|
+
client;
|
|
8
|
+
constructor(client) {
|
|
9
|
+
this.client = client;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Create a payment link
|
|
13
|
+
*
|
|
14
|
+
* @param options - Payment link creation options
|
|
15
|
+
* @returns Created payment link
|
|
16
|
+
*
|
|
17
|
+
* @throws {SquareValidationError} When input validation fails
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```typescript
|
|
21
|
+
* // Create with quick pay
|
|
22
|
+
* const link = await square.checkout.paymentLinks.create({
|
|
23
|
+
* quickPay: {
|
|
24
|
+
* name: 'Auto Detailing',
|
|
25
|
+
* priceMoney: { amount: BigInt(1000), currency: 'USD' },
|
|
26
|
+
* locationId: 'LXXX',
|
|
27
|
+
* },
|
|
28
|
+
* checkoutOptions: {
|
|
29
|
+
* askForShippingAddress: true,
|
|
30
|
+
* },
|
|
31
|
+
* });
|
|
32
|
+
*
|
|
33
|
+
* // Create with order
|
|
34
|
+
* const link = await square.checkout.paymentLinks.create({
|
|
35
|
+
* order: {
|
|
36
|
+
* locationId: 'LXXX',
|
|
37
|
+
* lineItems: [
|
|
38
|
+
* { name: 'Product', quantity: '1', basePriceMoney: { amount: BigInt(1000), currency: 'USD' } },
|
|
39
|
+
* ],
|
|
40
|
+
* },
|
|
41
|
+
* });
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
async create(options) {
|
|
45
|
+
if (!options.quickPay && !options.order) {
|
|
46
|
+
throw new SquareValidationError('Either quickPay or order must be provided', 'quickPay');
|
|
47
|
+
}
|
|
48
|
+
try {
|
|
49
|
+
const response = await this.client.checkout.paymentLinks.create({
|
|
50
|
+
idempotencyKey: options.idempotencyKey ?? createIdempotencyKey(),
|
|
51
|
+
description: options.description,
|
|
52
|
+
quickPay: options.quickPay,
|
|
53
|
+
order: options.order,
|
|
54
|
+
checkoutOptions: options.checkoutOptions,
|
|
55
|
+
prePopulatedData: options.prePopulatedData,
|
|
56
|
+
paymentNote: options.paymentNote,
|
|
57
|
+
});
|
|
58
|
+
if (!response.paymentLink) {
|
|
59
|
+
throw new Error('Payment link was not created');
|
|
60
|
+
}
|
|
61
|
+
return response.paymentLink;
|
|
62
|
+
}
|
|
63
|
+
catch (error) {
|
|
64
|
+
throw parseSquareError(error);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Get a payment link by ID
|
|
69
|
+
*
|
|
70
|
+
* @param id - Payment link ID
|
|
71
|
+
* @returns Payment link details
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* ```typescript
|
|
75
|
+
* const link = await square.checkout.paymentLinks.get('LINK_123');
|
|
76
|
+
* ```
|
|
77
|
+
*/
|
|
78
|
+
async get(id) {
|
|
79
|
+
if (!id) {
|
|
80
|
+
throw new SquareValidationError('id is required', 'id');
|
|
81
|
+
}
|
|
82
|
+
try {
|
|
83
|
+
const response = await this.client.checkout.paymentLinks.get({ id });
|
|
84
|
+
if (!response.paymentLink) {
|
|
85
|
+
throw new Error('Payment link not found');
|
|
86
|
+
}
|
|
87
|
+
return response.paymentLink;
|
|
88
|
+
}
|
|
89
|
+
catch (error) {
|
|
90
|
+
throw parseSquareError(error);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Update a payment link
|
|
95
|
+
*
|
|
96
|
+
* @param id - Payment link ID to update
|
|
97
|
+
* @param options - Update options including required version
|
|
98
|
+
* @returns Updated payment link
|
|
99
|
+
*
|
|
100
|
+
* @example
|
|
101
|
+
* ```typescript
|
|
102
|
+
* const link = await square.checkout.paymentLinks.update('LINK_123', {
|
|
103
|
+
* paymentLink: {
|
|
104
|
+
* version: 1,
|
|
105
|
+
* description: 'Updated description',
|
|
106
|
+
* checkoutOptions: {
|
|
107
|
+
* askForShippingAddress: false,
|
|
108
|
+
* },
|
|
109
|
+
* },
|
|
110
|
+
* });
|
|
111
|
+
* ```
|
|
112
|
+
*/
|
|
113
|
+
async update(id, options) {
|
|
114
|
+
if (!id) {
|
|
115
|
+
throw new SquareValidationError('id is required', 'id');
|
|
116
|
+
}
|
|
117
|
+
try {
|
|
118
|
+
const response = await this.client.checkout.paymentLinks.update({
|
|
119
|
+
id,
|
|
120
|
+
paymentLink: options.paymentLink,
|
|
121
|
+
});
|
|
122
|
+
if (!response.paymentLink) {
|
|
123
|
+
throw new Error('Payment link update failed');
|
|
124
|
+
}
|
|
125
|
+
return response.paymentLink;
|
|
126
|
+
}
|
|
127
|
+
catch (error) {
|
|
128
|
+
throw parseSquareError(error);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Delete a payment link
|
|
133
|
+
*
|
|
134
|
+
* @param id - Payment link ID to delete
|
|
135
|
+
*
|
|
136
|
+
* @example
|
|
137
|
+
* ```typescript
|
|
138
|
+
* await square.checkout.paymentLinks.delete('LINK_123');
|
|
139
|
+
* ```
|
|
140
|
+
*/
|
|
141
|
+
async delete(id) {
|
|
142
|
+
if (!id) {
|
|
143
|
+
throw new SquareValidationError('id is required', 'id');
|
|
144
|
+
}
|
|
145
|
+
try {
|
|
146
|
+
await this.client.checkout.paymentLinks.delete({ id });
|
|
147
|
+
}
|
|
148
|
+
catch (error) {
|
|
149
|
+
throw parseSquareError(error);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* List payment links with optional pagination
|
|
154
|
+
*
|
|
155
|
+
* @param options - List options
|
|
156
|
+
* @returns Array of payment links with optional cursor for pagination
|
|
157
|
+
*
|
|
158
|
+
* @example
|
|
159
|
+
* ```typescript
|
|
160
|
+
* // List all (up to limit)
|
|
161
|
+
* const links = await square.checkout.paymentLinks.list({ limit: 50 });
|
|
162
|
+
*
|
|
163
|
+
* // Paginate through results
|
|
164
|
+
* const firstPage = await square.checkout.paymentLinks.list({ limit: 10 });
|
|
165
|
+
* if (firstPage.cursor) {
|
|
166
|
+
* const nextPage = await square.checkout.paymentLinks.list({
|
|
167
|
+
* limit: 10,
|
|
168
|
+
* cursor: firstPage.cursor,
|
|
169
|
+
* });
|
|
170
|
+
* }
|
|
171
|
+
* ```
|
|
172
|
+
*/
|
|
173
|
+
async list(options) {
|
|
174
|
+
try {
|
|
175
|
+
const links = [];
|
|
176
|
+
const limit = options?.limit ?? 100;
|
|
177
|
+
const page = await this.client.checkout.paymentLinks.list({
|
|
178
|
+
cursor: options?.cursor,
|
|
179
|
+
limit: options?.limit,
|
|
180
|
+
});
|
|
181
|
+
for await (const link of page) {
|
|
182
|
+
links.push(link);
|
|
183
|
+
if (links.length >= limit) {
|
|
184
|
+
break;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
return {
|
|
188
|
+
data: links,
|
|
189
|
+
cursor: undefined, // Pagination handled by iterator
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
catch (error) {
|
|
193
|
+
throw parseSquareError(error);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Checkout service for Square Checkout API
|
|
199
|
+
*
|
|
200
|
+
* @example
|
|
201
|
+
* ```typescript
|
|
202
|
+
* const square = createSquareClient({ ... });
|
|
203
|
+
*
|
|
204
|
+
* // Create a payment link
|
|
205
|
+
* const link = await square.checkout.paymentLinks.create({
|
|
206
|
+
* quickPay: {
|
|
207
|
+
* name: 'Auto Detailing',
|
|
208
|
+
* priceMoney: { amount: BigInt(5000), currency: 'USD' },
|
|
209
|
+
* locationId: 'LXXX',
|
|
210
|
+
* },
|
|
211
|
+
* checkoutOptions: {
|
|
212
|
+
* redirectUrl: 'https://example.com/confirmation',
|
|
213
|
+
* askForShippingAddress: true,
|
|
214
|
+
* },
|
|
215
|
+
* prePopulatedData: {
|
|
216
|
+
* buyerEmail: 'customer@example.com',
|
|
217
|
+
* },
|
|
218
|
+
* });
|
|
219
|
+
*
|
|
220
|
+
* console.log('Checkout URL:', link.url);
|
|
221
|
+
* ```
|
|
222
|
+
*/
|
|
223
|
+
export class CheckoutService {
|
|
224
|
+
paymentLinks;
|
|
225
|
+
constructor(client) {
|
|
226
|
+
this.paymentLinks = new PaymentLinksService(client);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
//# sourceMappingURL=checkout.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checkout.service.js","sourceRoot":"","sources":["../../../src/core/services/checkout.service.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,gBAAgB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