@bates-solutions/squareup 0.2.0 → 1.1.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/README.md +91 -88
- 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/package.json +7 -41
- package/dist/angular/__tests__/setup.d.ts +0 -1
- package/dist/angular/__tests__/setup.d.ts.map +0 -1
- package/dist/angular/__tests__/setup.js +0 -5
- package/dist/angular/__tests__/setup.js.map +0 -1
- package/dist/angular/components/index.d.ts +0 -2
- package/dist/angular/components/index.d.ts.map +0 -1
- package/dist/angular/components/index.js +0 -2
- package/dist/angular/components/index.js.map +0 -1
- package/dist/angular/components/payment-button.component.d.ts +0 -49
- package/dist/angular/components/payment-button.component.d.ts.map +0 -1
- package/dist/angular/components/payment-button.component.js +0 -176
- package/dist/angular/components/payment-button.component.js.map +0 -1
- package/dist/angular/directives/index.d.ts +0 -2
- package/dist/angular/directives/index.d.ts.map +0 -1
- package/dist/angular/directives/index.js +0 -2
- package/dist/angular/directives/index.js.map +0 -1
- package/dist/angular/directives/square-card.directive.d.ts +0 -52
- package/dist/angular/directives/square-card.directive.d.ts.map +0 -1
- package/dist/angular/directives/square-card.directive.js +0 -98
- package/dist/angular/directives/square-card.directive.js.map +0 -1
- package/dist/angular/index.d.ts +0 -42
- package/dist/angular/index.d.ts.map +0 -1
- package/dist/angular/index.js +0 -45
- package/dist/angular/index.js.map +0 -1
- package/dist/angular/services/index.d.ts +0 -6
- package/dist/angular/services/index.d.ts.map +0 -1
- package/dist/angular/services/index.js +0 -6
- package/dist/angular/services/index.js.map +0 -1
- package/dist/angular/services/square-catalog.service.d.ts +0 -60
- package/dist/angular/services/square-catalog.service.d.ts.map +0 -1
- package/dist/angular/services/square-catalog.service.js +0 -152
- package/dist/angular/services/square-catalog.service.js.map +0 -1
- package/dist/angular/services/square-customers.service.d.ts +0 -77
- package/dist/angular/services/square-customers.service.d.ts.map +0 -1
- package/dist/angular/services/square-customers.service.js +0 -187
- package/dist/angular/services/square-customers.service.js.map +0 -1
- package/dist/angular/services/square-orders.service.d.ts +0 -66
- package/dist/angular/services/square-orders.service.d.ts.map +0 -1
- package/dist/angular/services/square-orders.service.js +0 -170
- package/dist/angular/services/square-orders.service.js.map +0 -1
- package/dist/angular/services/square-payments.service.d.ts +0 -73
- package/dist/angular/services/square-payments.service.d.ts.map +0 -1
- package/dist/angular/services/square-payments.service.js +0 -167
- package/dist/angular/services/square-payments.service.js.map +0 -1
- package/dist/angular/services/square-sdk.service.d.ts +0 -45
- package/dist/angular/services/square-sdk.service.d.ts.map +0 -1
- package/dist/angular/services/square-sdk.service.js +0 -133
- package/dist/angular/services/square-sdk.service.js.map +0 -1
- package/dist/angular/square.module.d.ts +0 -36
- package/dist/angular/square.module.d.ts.map +0 -1
- package/dist/angular/square.module.js +0 -75
- package/dist/angular/square.module.js.map +0 -1
- package/dist/angular/types.d.ts +0 -189
- package/dist/angular/types.d.ts.map +0 -1
- package/dist/angular/types.js +0 -8
- package/dist/angular/types.js.map +0 -1
- package/dist/react/SquareProvider.d.ts +0 -50
- package/dist/react/SquareProvider.d.ts.map +0 -1
- package/dist/react/SquareProvider.js +0 -134
- package/dist/react/SquareProvider.js.map +0 -1
- package/dist/react/__tests__/CardInput.test.d.ts +0 -2
- package/dist/react/__tests__/CardInput.test.d.ts.map +0 -1
- package/dist/react/__tests__/CardInput.test.js +0 -218
- package/dist/react/__tests__/CardInput.test.js.map +0 -1
- package/dist/react/__tests__/PaymentButton.test.d.ts +0 -2
- package/dist/react/__tests__/PaymentButton.test.d.ts.map +0 -1
- package/dist/react/__tests__/PaymentButton.test.js +0 -400
- package/dist/react/__tests__/PaymentButton.test.js.map +0 -1
- package/dist/react/__tests__/SquareProvider.test.d.ts +0 -2
- package/dist/react/__tests__/SquareProvider.test.d.ts.map +0 -1
- package/dist/react/__tests__/SquareProvider.test.js +0 -126
- package/dist/react/__tests__/SquareProvider.test.js.map +0 -1
- package/dist/react/__tests__/setup.d.ts +0 -2
- package/dist/react/__tests__/setup.d.ts.map +0 -1
- package/dist/react/__tests__/setup.js +0 -3
- package/dist/react/__tests__/setup.js.map +0 -1
- package/dist/react/__tests__/useCatalog.test.d.ts +0 -2
- package/dist/react/__tests__/useCatalog.test.d.ts.map +0 -1
- package/dist/react/__tests__/useCatalog.test.js +0 -277
- package/dist/react/__tests__/useCatalog.test.js.map +0 -1
- package/dist/react/__tests__/useCustomers.test.d.ts +0 -2
- package/dist/react/__tests__/useCustomers.test.d.ts.map +0 -1
- package/dist/react/__tests__/useCustomers.test.js +0 -312
- package/dist/react/__tests__/useCustomers.test.js.map +0 -1
- package/dist/react/__tests__/useOrders.test.d.ts +0 -2
- package/dist/react/__tests__/useOrders.test.d.ts.map +0 -1
- package/dist/react/__tests__/useOrders.test.js +0 -216
- package/dist/react/__tests__/useOrders.test.js.map +0 -1
- package/dist/react/__tests__/usePayments.test.d.ts +0 -2
- package/dist/react/__tests__/usePayments.test.d.ts.map +0 -1
- package/dist/react/__tests__/usePayments.test.js +0 -235
- package/dist/react/__tests__/usePayments.test.js.map +0 -1
- package/dist/react/__tests__/useSquarePayment.test.d.ts +0 -2
- package/dist/react/__tests__/useSquarePayment.test.d.ts.map +0 -1
- package/dist/react/__tests__/useSquarePayment.test.js +0 -447
- package/dist/react/__tests__/useSquarePayment.test.js.map +0 -1
- package/dist/react/components/CardInput.d.ts +0 -69
- package/dist/react/components/CardInput.d.ts.map +0 -1
- package/dist/react/components/CardInput.js +0 -58
- package/dist/react/components/CardInput.js.map +0 -1
- package/dist/react/components/PaymentButton.d.ts +0 -71
- package/dist/react/components/PaymentButton.d.ts.map +0 -1
- package/dist/react/components/PaymentButton.js +0 -140
- package/dist/react/components/PaymentButton.js.map +0 -1
- package/dist/react/components/index.d.ts +0 -5
- package/dist/react/components/index.d.ts.map +0 -1
- package/dist/react/components/index.js +0 -3
- package/dist/react/components/index.js.map +0 -1
- package/dist/react/hooks/index.d.ts +0 -11
- package/dist/react/hooks/index.d.ts.map +0 -1
- package/dist/react/hooks/index.js +0 -6
- package/dist/react/hooks/index.js.map +0 -1
- package/dist/react/hooks/useCatalog.d.ts +0 -98
- package/dist/react/hooks/useCatalog.d.ts.map +0 -1
- package/dist/react/hooks/useCatalog.js +0 -134
- package/dist/react/hooks/useCatalog.js.map +0 -1
- package/dist/react/hooks/useCustomers.d.ts +0 -105
- package/dist/react/hooks/useCustomers.d.ts.map +0 -1
- package/dist/react/hooks/useCustomers.js +0 -174
- package/dist/react/hooks/useCustomers.js.map +0 -1
- package/dist/react/hooks/useOrders.d.ts +0 -112
- package/dist/react/hooks/useOrders.d.ts.map +0 -1
- package/dist/react/hooks/useOrders.js +0 -115
- package/dist/react/hooks/useOrders.js.map +0 -1
- package/dist/react/hooks/usePayments.d.ts +0 -98
- package/dist/react/hooks/usePayments.d.ts.map +0 -1
- package/dist/react/hooks/usePayments.js +0 -89
- package/dist/react/hooks/usePayments.js.map +0 -1
- package/dist/react/hooks/useSquarePayment.d.ts +0 -52
- package/dist/react/hooks/useSquarePayment.d.ts.map +0 -1
- package/dist/react/hooks/useSquarePayment.js +0 -146
- package/dist/react/hooks/useSquarePayment.js.map +0 -1
- package/dist/react/index.d.ts +0 -8
- package/dist/react/index.d.ts.map +0 -1
- package/dist/react/index.js +0 -7
- package/dist/react/index.js.map +0 -1
- package/dist/react/types.d.ts +0 -183
- package/dist/react/types.d.ts.map +0 -1
- package/dist/react/types.js +0 -2
- package/dist/react/types.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<p align="center">
|
|
2
|
-
<img src="https://img.shields.io/badge/
|
|
2
|
+
<img src="https://img.shields.io/badge/Node.js-18+-339933?logo=node.js&logoColor=white&style=for-the-badge" alt="Node.js" height="28">
|
|
3
3
|
|
|
4
|
-
<img src="https://img.shields.io/badge/
|
|
4
|
+
<img src="https://img.shields.io/badge/TypeScript-5.0+-3178C6?logo=typescript&logoColor=white&style=for-the-badge" alt="TypeScript" height="28">
|
|
5
5
|
|
|
6
6
|
<img src="https://img.shields.io/badge/Square-Payments-0066CC?logo=data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjQiIGhlaWdodD0iMjQiIHZpZXdCb3g9IjAgMCAyNCAyNCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHJlY3Qgd2lkdGg9IjI0IiBoZWlnaHQ9IjI0IiByeD0iNCIgZmlsbD0iIzAwNjZDQyIvPgo8cGF0aCBkPSJNOC41IDEySDE1LjVWMTMuNUgxMC41VjE1SDE1LjVWMTYuNUgxMC41VjE4SDE1LjVWMTlIMFYxMkg4LjVWMTJIMFYxMkg4LjVWMTJaIiBmaWxsPSJ3aGl0ZSIvPgo8L3N2Zz4K&style=for-the-badge" alt="Square" height="28">
|
|
7
7
|
</p>
|
|
@@ -10,64 +10,33 @@
|
|
|
10
10
|
|
|
11
11
|
<p align="center">
|
|
12
12
|
<strong>The modern TypeScript SDK for Square payments</strong><br>
|
|
13
|
-
Build payment
|
|
13
|
+
Build payment backends with type-safe APIs, fluent builders, and webhook support.
|
|
14
14
|
</p>
|
|
15
15
|
|
|
16
16
|
<p align="center">
|
|
17
|
-
<img src="https://img.shields.io/badge/version-0.1.0-blue.svg" alt="version 0.1.0">
|
|
18
17
|
<a href="LICENSE"><img src="https://img.shields.io/badge/License-MIT-yellow.svg" alt="License: MIT"></a>
|
|
19
18
|
<a href="https://typescriptlang.org"><img src="https://img.shields.io/badge/TypeScript-5.0+-blue.svg" alt="TypeScript"></a>
|
|
20
|
-
<br>
|
|
21
|
-
<img src="https://img.shields.io/badge/tests-329%20passed-brightgreen.svg" alt="Tests">
|
|
22
|
-
<img src="https://img.shields.io/badge/coverage-99.84%25-brightgreen.svg" alt="Coverage">
|
|
23
|
-
<img src="https://img.shields.io/badge/React-110%20tests-blue.svg" alt="React Tests">
|
|
24
|
-
<img src="https://img.shields.io/badge/Angular-133%20tests-red.svg" alt="Angular Tests">
|
|
25
19
|
</p>
|
|
26
20
|
|
|
27
21
|
---
|
|
28
22
|
|
|
29
|
-
Stop wrestling with Square's low-level APIs. **squareup** gives you
|
|
23
|
+
Stop wrestling with Square's low-level APIs. **squareup** gives you a simplified client API and fluent builders that make payment integration straightforward. Process payments, manage orders, handle webhooks—all with full TypeScript support and zero boilerplate.
|
|
30
24
|
|
|
31
25
|
## Features
|
|
32
26
|
|
|
33
27
|
- **Simplified APIs** - Less boilerplate, more productivity
|
|
34
|
-
- **React Integration** - Hooks and components for payments
|
|
35
|
-
- **Angular Integration** - Services with RxJS Observables
|
|
36
|
-
- **Server Utilities** - Webhook verification and middleware
|
|
37
28
|
- **Type-Safe** - Full TypeScript support with strict types
|
|
38
29
|
- **Fluent Builders** - Chainable order and payment construction
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
**329 comprehensive tests** with **99.84% code coverage** ensure reliability and maintainability:
|
|
43
|
-
|
|
44
|
-
- **React Tests (110)**: Complete coverage of hooks, components, and integrations
|
|
45
|
-
- **Angular Tests (133)**: Full service testing with RxJS observables
|
|
46
|
-
- **Core Tests (86)**: API clients, builders, and utilities
|
|
47
|
-
- **Coverage Breakdown**:
|
|
48
|
-
- Statements: **99.84%**
|
|
49
|
-
- Branches: **95.99%**
|
|
50
|
-
- Functions: **100%**
|
|
51
|
-
- Lines: **99.84%**
|
|
52
|
-
|
|
53
|
-
Run tests with:
|
|
54
|
-
|
|
55
|
-
```bash
|
|
56
|
-
npm test # All tests
|
|
57
|
-
npm run test:react # React tests only
|
|
58
|
-
npm run test:angular # Angular tests only
|
|
59
|
-
npm run test:coverage # With coverage report
|
|
60
|
-
```
|
|
30
|
+
- **Webhook Support** - Signature verification and middleware for Express/Next.js
|
|
31
|
+
- **Service Classes** - Payments, Orders, Customers, Catalog, Inventory, Subscriptions, Invoices, Loyalty
|
|
61
32
|
|
|
62
33
|
## Requirements
|
|
63
34
|
|
|
64
35
|
| Dependency | Version |
|
|
65
36
|
| ---------- | ------- |
|
|
66
37
|
| Square SDK | ^43.0.0 |
|
|
67
|
-
| Node.js |
|
|
38
|
+
| Node.js | 22+ |
|
|
68
39
|
| TypeScript | 5.0+ |
|
|
69
|
-
| React | 18+ (optional) |
|
|
70
|
-
| Angular | 17+ (optional) |
|
|
71
40
|
|
|
72
41
|
## Installation
|
|
73
42
|
|
|
@@ -75,26 +44,9 @@ npm run test:coverage # With coverage report
|
|
|
75
44
|
npm install @bates-solutions/squareup square
|
|
76
45
|
```
|
|
77
46
|
|
|
78
|
-
### Peer Dependencies
|
|
79
|
-
|
|
80
|
-
```bash
|
|
81
|
-
# For React integration
|
|
82
|
-
npm install react
|
|
83
|
-
|
|
84
|
-
# For Angular integration
|
|
85
|
-
npm install @angular/core @angular/common rxjs
|
|
86
|
-
```
|
|
87
|
-
|
|
88
|
-
## 📚 Documentation
|
|
89
|
-
|
|
90
|
-
- **[Getting Started](./docs/getting-started/)** - Installation and setup guides
|
|
91
|
-
- **[Guides](./docs/guides/)** - Framework-specific tutorials and examples
|
|
92
|
-
- **[API Reference](./docs/api-reference.md)** - Complete API documentation
|
|
93
|
-
- **[Configuration](./docs/getting-started/configuration.md)** - Environment setup
|
|
94
|
-
|
|
95
47
|
## Quick Start
|
|
96
48
|
|
|
97
|
-
###
|
|
49
|
+
### Basic Usage
|
|
98
50
|
|
|
99
51
|
```typescript
|
|
100
52
|
import { createSquareClient } from '@bates-solutions/squareup';
|
|
@@ -104,55 +56,106 @@ const client = createSquareClient({
|
|
|
104
56
|
environment: 'sandbox',
|
|
105
57
|
});
|
|
106
58
|
|
|
59
|
+
// Process a payment
|
|
107
60
|
const payment = await client.payments.create({
|
|
108
61
|
sourceId: 'cnon:card-nonce',
|
|
109
62
|
amount: 1000, // $10.00
|
|
110
63
|
currency: 'USD',
|
|
111
64
|
});
|
|
65
|
+
|
|
66
|
+
// Create an order with the fluent builder
|
|
67
|
+
const order = await client.orders.create(
|
|
68
|
+
client.orders
|
|
69
|
+
.builder()
|
|
70
|
+
.addItem({ name: 'Coffee', quantity: 2, amount: 450 })
|
|
71
|
+
.addItem({ name: 'Muffin', quantity: 1, amount: 350 })
|
|
72
|
+
.build()
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
// Manage customers
|
|
76
|
+
const customer = await client.customers.create({
|
|
77
|
+
givenName: 'John',
|
|
78
|
+
familyName: 'Doe',
|
|
79
|
+
emailAddress: 'john@example.com',
|
|
80
|
+
});
|
|
112
81
|
```
|
|
113
82
|
|
|
114
|
-
###
|
|
83
|
+
### Webhook Handling (Express)
|
|
115
84
|
|
|
116
|
-
```
|
|
117
|
-
import
|
|
85
|
+
```typescript
|
|
86
|
+
import express from 'express';
|
|
87
|
+
import { createWebhookHandler, rawBodyMiddleware } from '@bates-solutions/squareup/server';
|
|
118
88
|
|
|
119
|
-
|
|
120
|
-
return (
|
|
121
|
-
<SquareProvider applicationId="sq0idp-xxx" locationId="LXXX" environment="sandbox">
|
|
122
|
-
<PaymentForm />
|
|
123
|
-
</SquareProvider>
|
|
124
|
-
);
|
|
125
|
-
}
|
|
89
|
+
const app = express();
|
|
126
90
|
|
|
127
|
-
|
|
128
|
-
|
|
91
|
+
// Use raw body middleware before JSON parsing for webhook routes
|
|
92
|
+
app.use('/webhooks/square', rawBodyMiddleware);
|
|
93
|
+
app.use(express.json());
|
|
129
94
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
95
|
+
const webhookHandler = createWebhookHandler({
|
|
96
|
+
signatureKey: process.env.SQUARE_WEBHOOK_SIGNATURE_KEY!,
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
app.post('/webhooks/square', (req, res) => {
|
|
100
|
+
const event = webhookHandler.verifyAndParse(req);
|
|
101
|
+
|
|
102
|
+
switch (event.type) {
|
|
103
|
+
case 'payment.completed':
|
|
104
|
+
console.log('Payment completed:', event.data);
|
|
105
|
+
break;
|
|
106
|
+
case 'order.created':
|
|
107
|
+
console.log('Order created:', event.data);
|
|
108
|
+
break;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
res.sendStatus(200);
|
|
112
|
+
});
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
### Webhook Handling (Next.js)
|
|
116
|
+
|
|
117
|
+
```typescript
|
|
118
|
+
// app/api/webhooks/square/route.ts
|
|
119
|
+
import { createWebhookHandler } from '@bates-solutions/squareup/server';
|
|
137
120
|
|
|
138
|
-
|
|
121
|
+
const webhookHandler = createWebhookHandler({
|
|
122
|
+
signatureKey: process.env.SQUARE_WEBHOOK_SIGNATURE_KEY!,
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
export async function POST(request: Request) {
|
|
126
|
+
const body = await request.text();
|
|
127
|
+
const signature = request.headers.get('x-square-hmacsha256-signature')!;
|
|
128
|
+
|
|
129
|
+
const event = webhookHandler.verifyAndParse(body, signature);
|
|
130
|
+
|
|
131
|
+
// Handle the event
|
|
132
|
+
console.log('Received event:', event.type);
|
|
133
|
+
|
|
134
|
+
return new Response('OK', { status: 200 });
|
|
139
135
|
}
|
|
140
136
|
```
|
|
141
137
|
|
|
142
|
-
|
|
138
|
+
## Available Services
|
|
139
|
+
|
|
140
|
+
| Service | Description |
|
|
141
|
+
| --------------- | ------------------------------------ |
|
|
142
|
+
| `payments` | Process and manage payments |
|
|
143
|
+
| `orders` | Create and manage orders |
|
|
144
|
+
| `customers` | Customer management |
|
|
145
|
+
| `catalog` | Product catalog operations |
|
|
146
|
+
| `inventory` | Inventory tracking |
|
|
147
|
+
| `subscriptions` | Subscription management |
|
|
148
|
+
| `invoices` | Invoice operations |
|
|
149
|
+
| `loyalty` | Loyalty program management |
|
|
150
|
+
|
|
151
|
+
## Utilities
|
|
143
152
|
|
|
144
153
|
```typescript
|
|
145
|
-
import {
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
accessToken: 'YOUR_ACCESS_TOKEN',
|
|
151
|
-
environment: 'sandbox',
|
|
152
|
-
}),
|
|
153
|
-
],
|
|
154
|
-
})
|
|
155
|
-
export class AppModule {}
|
|
154
|
+
import { toCents, fromCents, formatMoney } from '@bates-solutions/squareup';
|
|
155
|
+
|
|
156
|
+
toCents(10.99); // 1099
|
|
157
|
+
fromCents(1099); // 10.99
|
|
158
|
+
formatMoney(1099, 'USD'); // "$10.99"
|
|
156
159
|
```
|
|
157
160
|
|
|
158
161
|
## Contributing
|
|
@@ -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,EAA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;;;;;;;;;OAWG;IACG,IAAI,CACR,UAAU,EAAE,iBAAiB,EAC7B,OAAO,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,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,CAAC;QAED,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,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"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bates-solutions/squareup",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "TypeScript wrapper for Square API with
|
|
3
|
+
"version": "1.1.0",
|
|
4
|
+
"description": "TypeScript wrapper for Square API with webhook support for Node.js backends",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/core/index.js",
|
|
7
7
|
"types": "./dist/core/index.d.ts",
|
|
@@ -10,14 +10,6 @@
|
|
|
10
10
|
"types": "./dist/core/index.d.ts",
|
|
11
11
|
"import": "./dist/core/index.js"
|
|
12
12
|
},
|
|
13
|
-
"./react": {
|
|
14
|
-
"types": "./dist/react/index.d.ts",
|
|
15
|
-
"import": "./dist/react/index.js"
|
|
16
|
-
},
|
|
17
|
-
"./angular": {
|
|
18
|
-
"types": "./dist/angular/index.d.ts",
|
|
19
|
-
"import": "./dist/angular/index.js"
|
|
20
|
-
},
|
|
21
13
|
"./server": {
|
|
22
14
|
"types": "./dist/server/index.d.ts",
|
|
23
15
|
"import": "./dist/server/index.js"
|
|
@@ -37,8 +29,6 @@
|
|
|
37
29
|
"test": "vitest run",
|
|
38
30
|
"test:watch": "vitest",
|
|
39
31
|
"test:coverage": "vitest run --coverage",
|
|
40
|
-
"test:react": "vitest run --config vitest.react.config.ts",
|
|
41
|
-
"test:angular": "vitest run --config vitest.angular.config.ts",
|
|
42
32
|
"docs": "typedoc",
|
|
43
33
|
"prepublishOnly": "npm run build"
|
|
44
34
|
},
|
|
@@ -47,11 +37,10 @@
|
|
|
47
37
|
"square-api",
|
|
48
38
|
"payments",
|
|
49
39
|
"payment-processing",
|
|
50
|
-
"react",
|
|
51
|
-
"react-hooks",
|
|
52
|
-
"angular",
|
|
53
40
|
"typescript",
|
|
54
|
-
"
|
|
41
|
+
"nodejs",
|
|
42
|
+
"backend",
|
|
43
|
+
"webhooks",
|
|
55
44
|
"ecommerce",
|
|
56
45
|
"point-of-sale",
|
|
57
46
|
"pos",
|
|
@@ -69,53 +58,30 @@
|
|
|
69
58
|
},
|
|
70
59
|
"homepage": "https://github.com/mbates/squareup#readme",
|
|
71
60
|
"engines": {
|
|
72
|
-
"node": ">=
|
|
61
|
+
"node": ">=22"
|
|
73
62
|
},
|
|
74
63
|
"peerDependencies": {
|
|
75
|
-
"@angular/core": "^17.0.0 || ^18.0.0 || ^19.0.0",
|
|
76
|
-
"react": "^18.0.0 || ^19.0.0",
|
|
77
64
|
"square": "^43.2.1"
|
|
78
65
|
},
|
|
79
|
-
"peerDependenciesMeta": {
|
|
80
|
-
"react": {
|
|
81
|
-
"optional": true
|
|
82
|
-
},
|
|
83
|
-
"@angular/core": {
|
|
84
|
-
"optional": true
|
|
85
|
-
}
|
|
86
|
-
},
|
|
87
66
|
"devDependencies": {
|
|
88
|
-
"@angular/common": "^21.0.6",
|
|
89
|
-
"@angular/core": "^21.0.6",
|
|
90
|
-
"@angular/platform-browser": "^21.0.6",
|
|
91
|
-
"@angular/platform-browser-dynamic": "^21.0.6",
|
|
92
67
|
"@eslint/js": "^9.39.2",
|
|
93
68
|
"@semantic-release/changelog": "^6.0.3",
|
|
94
69
|
"@semantic-release/git": "^10.0.1",
|
|
95
|
-
"@testing-library/dom": "^10.4.1",
|
|
96
|
-
"@testing-library/jest-dom": "^6.9.1",
|
|
97
|
-
"@testing-library/react": "^16.3.1",
|
|
98
70
|
"@types/express": "^5.0.6",
|
|
99
71
|
"@types/node": "^25.0.3",
|
|
100
|
-
"@types/react": "^19.2.7",
|
|
101
72
|
"@typescript-eslint/eslint-plugin": "^8.51.0",
|
|
102
73
|
"@typescript-eslint/parser": "^8.51.0",
|
|
103
74
|
"@vitest/coverage-v8": "^4.0.0",
|
|
104
75
|
"eslint": "^9.39.2",
|
|
105
76
|
"eslint-config-prettier": "^10.1.8",
|
|
106
77
|
"eslint-plugin-prettier": "^5.1.0",
|
|
107
|
-
"jsdom": "^27.4.0",
|
|
108
78
|
"prettier": "^3.2.0",
|
|
109
|
-
"react": "^19.2.3",
|
|
110
|
-
"react-dom": "^19.2.3",
|
|
111
|
-
"rxjs": "^7.8.2",
|
|
112
79
|
"semantic-release": "^25.0.2",
|
|
113
80
|
"square": "^43.2.1",
|
|
114
81
|
"typedoc": "^0.28.15",
|
|
115
82
|
"typedoc-plugin-markdown": "^4.9.0",
|
|
116
83
|
"typescript": "^5.3.0",
|
|
117
84
|
"typescript-eslint": "^8.51.0",
|
|
118
|
-
"vitest": "^4.0.16"
|
|
119
|
-
"zone.js": "^0.16.0"
|
|
85
|
+
"vitest": "^4.0.16"
|
|
120
86
|
}
|
|
121
87
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
//# sourceMappingURL=setup.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../../../src/angular/__tests__/setup.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"setup.js","sourceRoot":"","sources":["../../../src/angular/__tests__/setup.ts"],"names":[],"mappings":";AAAA,4DAA4D;AAC5D,iDAAiD;AACjD,sDAAsD"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/angular/components/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/angular/components/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC"}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { EventEmitter, OnInit, OnDestroy, ChangeDetectorRef } from '@angular/core';
|
|
2
|
-
import { SquareSdkService } from '../services/square-sdk.service.js';
|
|
3
|
-
import type { DigitalWalletOptions } from '../types.js';
|
|
4
|
-
/**
|
|
5
|
-
* Payment button component for Google Pay / Apple Pay
|
|
6
|
-
*
|
|
7
|
-
* @example
|
|
8
|
-
* ```html
|
|
9
|
-
* <square-payment-button
|
|
10
|
-
* type="googlePay"
|
|
11
|
-
* (payment)="onPayment($event)"
|
|
12
|
-
* (error)="onError($event)"
|
|
13
|
-
* ></square-payment-button>
|
|
14
|
-
*
|
|
15
|
-
* <square-payment-button
|
|
16
|
-
* type="applePay"
|
|
17
|
-
* [buttonOptions]="{ buttonColor: 'black' }"
|
|
18
|
-
* (payment)="onPayment($event)"
|
|
19
|
-
* ></square-payment-button>
|
|
20
|
-
* ```
|
|
21
|
-
*/
|
|
22
|
-
export declare class PaymentButtonComponent implements OnInit, OnDestroy {
|
|
23
|
-
private sdk;
|
|
24
|
-
private cdr;
|
|
25
|
-
/** Payment method type */
|
|
26
|
-
type: 'googlePay' | 'applePay';
|
|
27
|
-
/** Button styling options */
|
|
28
|
-
buttonOptions?: DigitalWalletOptions;
|
|
29
|
-
/** Emits when button is ready */
|
|
30
|
-
buttonReady: EventEmitter<void>;
|
|
31
|
-
/** Emits payment token on success */
|
|
32
|
-
payment: EventEmitter<string>;
|
|
33
|
-
/** Emits when an error occurs */
|
|
34
|
-
error: EventEmitter<Error>;
|
|
35
|
-
/** Emits when payment is cancelled */
|
|
36
|
-
cancel: EventEmitter<void>;
|
|
37
|
-
private containerRef;
|
|
38
|
-
private paymentMethod;
|
|
39
|
-
private subscription?;
|
|
40
|
-
ready: boolean;
|
|
41
|
-
loading: boolean;
|
|
42
|
-
constructor(sdk: SquareSdkService, cdr: ChangeDetectorRef);
|
|
43
|
-
ngOnInit(): void;
|
|
44
|
-
ngOnDestroy(): void;
|
|
45
|
-
handleClick(): void;
|
|
46
|
-
private initializePaymentMethod;
|
|
47
|
-
private tokenize;
|
|
48
|
-
}
|
|
49
|
-
//# sourceMappingURL=payment-button.component.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"payment-button.component.d.ts","sourceRoot":"","sources":["../../../src/angular/components/payment-button.component.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,YAAY,EAEZ,MAAM,EACN,SAAS,EAGT,iBAAiB,EAClB,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AACrE,OAAO,KAAK,EAAuB,oBAAoB,EAAe,MAAM,aAAa,CAAC;AAE1F;;;;;;;;;;;;;;;;;GAiBG;AACH,qBAkBa,sBAAuB,YAAW,MAAM,EAAE,SAAS;IA6B5D,OAAO,CAAC,GAAG;IACX,OAAO,CAAC,GAAG;IA7Bb,0BAA0B;IACjB,IAAI,EAAE,WAAW,GAAG,UAAU,CAAe;IAEtD,6BAA6B;IACpB,aAAa,CAAC,EAAE,oBAAoB,CAAC;IAE9C,iCAAiC;IACvB,WAAW,qBAA4B;IAEjD,qCAAqC;IAC3B,OAAO,uBAA8B;IAE/C,iCAAiC;IACvB,KAAK,sBAA6B;IAE5C,sCAAsC;IAC5B,MAAM,qBAA4B;IAG5C,OAAO,CAAC,YAAY,CAA2B;IAE/C,OAAO,CAAC,aAAa,CAAqC;IAC1D,OAAO,CAAC,YAAY,CAAC,CAAe;IAEpC,KAAK,UAAS;IACd,OAAO,UAAS;gBAGN,GAAG,EAAE,gBAAgB,EACrB,GAAG,EAAE,iBAAiB;IAGhC,QAAQ,IAAI,IAAI;IAWhB,WAAW,IAAI,IAAI;IAQnB,WAAW,IAAI,IAAI;YAQL,uBAAuB;YAyBvB,QAAQ;CA4BvB"}
|