@bates-solutions/squareup 0.1.0 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (144) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +167 -154
  3. package/package.json +87 -118
  4. package/README.md.backup +0 -292
  5. package/dist/angular/__tests__/setup.d.ts +0 -1
  6. package/dist/angular/__tests__/setup.d.ts.map +0 -1
  7. package/dist/angular/__tests__/setup.js +0 -5
  8. package/dist/angular/__tests__/setup.js.map +0 -1
  9. package/dist/angular/components/index.d.ts +0 -2
  10. package/dist/angular/components/index.d.ts.map +0 -1
  11. package/dist/angular/components/index.js +0 -2
  12. package/dist/angular/components/index.js.map +0 -1
  13. package/dist/angular/components/payment-button.component.d.ts +0 -49
  14. package/dist/angular/components/payment-button.component.d.ts.map +0 -1
  15. package/dist/angular/components/payment-button.component.js +0 -176
  16. package/dist/angular/components/payment-button.component.js.map +0 -1
  17. package/dist/angular/directives/index.d.ts +0 -2
  18. package/dist/angular/directives/index.d.ts.map +0 -1
  19. package/dist/angular/directives/index.js +0 -2
  20. package/dist/angular/directives/index.js.map +0 -1
  21. package/dist/angular/directives/square-card.directive.d.ts +0 -52
  22. package/dist/angular/directives/square-card.directive.d.ts.map +0 -1
  23. package/dist/angular/directives/square-card.directive.js +0 -98
  24. package/dist/angular/directives/square-card.directive.js.map +0 -1
  25. package/dist/angular/index.d.ts +0 -42
  26. package/dist/angular/index.d.ts.map +0 -1
  27. package/dist/angular/index.js +0 -45
  28. package/dist/angular/index.js.map +0 -1
  29. package/dist/angular/services/index.d.ts +0 -6
  30. package/dist/angular/services/index.d.ts.map +0 -1
  31. package/dist/angular/services/index.js +0 -6
  32. package/dist/angular/services/index.js.map +0 -1
  33. package/dist/angular/services/square-catalog.service.d.ts +0 -60
  34. package/dist/angular/services/square-catalog.service.d.ts.map +0 -1
  35. package/dist/angular/services/square-catalog.service.js +0 -152
  36. package/dist/angular/services/square-catalog.service.js.map +0 -1
  37. package/dist/angular/services/square-customers.service.d.ts +0 -77
  38. package/dist/angular/services/square-customers.service.d.ts.map +0 -1
  39. package/dist/angular/services/square-customers.service.js +0 -187
  40. package/dist/angular/services/square-customers.service.js.map +0 -1
  41. package/dist/angular/services/square-orders.service.d.ts +0 -66
  42. package/dist/angular/services/square-orders.service.d.ts.map +0 -1
  43. package/dist/angular/services/square-orders.service.js +0 -170
  44. package/dist/angular/services/square-orders.service.js.map +0 -1
  45. package/dist/angular/services/square-payments.service.d.ts +0 -73
  46. package/dist/angular/services/square-payments.service.d.ts.map +0 -1
  47. package/dist/angular/services/square-payments.service.js +0 -167
  48. package/dist/angular/services/square-payments.service.js.map +0 -1
  49. package/dist/angular/services/square-sdk.service.d.ts +0 -45
  50. package/dist/angular/services/square-sdk.service.d.ts.map +0 -1
  51. package/dist/angular/services/square-sdk.service.js +0 -133
  52. package/dist/angular/services/square-sdk.service.js.map +0 -1
  53. package/dist/angular/square.module.d.ts +0 -36
  54. package/dist/angular/square.module.d.ts.map +0 -1
  55. package/dist/angular/square.module.js +0 -75
  56. package/dist/angular/square.module.js.map +0 -1
  57. package/dist/angular/types.d.ts +0 -189
  58. package/dist/angular/types.d.ts.map +0 -1
  59. package/dist/angular/types.js +0 -8
  60. package/dist/angular/types.js.map +0 -1
  61. package/dist/react/SquareProvider.d.ts +0 -50
  62. package/dist/react/SquareProvider.d.ts.map +0 -1
  63. package/dist/react/SquareProvider.js +0 -134
  64. package/dist/react/SquareProvider.js.map +0 -1
  65. package/dist/react/__tests__/CardInput.test.d.ts +0 -2
  66. package/dist/react/__tests__/CardInput.test.d.ts.map +0 -1
  67. package/dist/react/__tests__/CardInput.test.js +0 -218
  68. package/dist/react/__tests__/CardInput.test.js.map +0 -1
  69. package/dist/react/__tests__/PaymentButton.test.d.ts +0 -2
  70. package/dist/react/__tests__/PaymentButton.test.d.ts.map +0 -1
  71. package/dist/react/__tests__/PaymentButton.test.js +0 -400
  72. package/dist/react/__tests__/PaymentButton.test.js.map +0 -1
  73. package/dist/react/__tests__/SquareProvider.test.d.ts +0 -2
  74. package/dist/react/__tests__/SquareProvider.test.d.ts.map +0 -1
  75. package/dist/react/__tests__/SquareProvider.test.js +0 -126
  76. package/dist/react/__tests__/SquareProvider.test.js.map +0 -1
  77. package/dist/react/__tests__/setup.d.ts +0 -2
  78. package/dist/react/__tests__/setup.d.ts.map +0 -1
  79. package/dist/react/__tests__/setup.js +0 -3
  80. package/dist/react/__tests__/setup.js.map +0 -1
  81. package/dist/react/__tests__/useCatalog.test.d.ts +0 -2
  82. package/dist/react/__tests__/useCatalog.test.d.ts.map +0 -1
  83. package/dist/react/__tests__/useCatalog.test.js +0 -277
  84. package/dist/react/__tests__/useCatalog.test.js.map +0 -1
  85. package/dist/react/__tests__/useCustomers.test.d.ts +0 -2
  86. package/dist/react/__tests__/useCustomers.test.d.ts.map +0 -1
  87. package/dist/react/__tests__/useCustomers.test.js +0 -312
  88. package/dist/react/__tests__/useCustomers.test.js.map +0 -1
  89. package/dist/react/__tests__/useOrders.test.d.ts +0 -2
  90. package/dist/react/__tests__/useOrders.test.d.ts.map +0 -1
  91. package/dist/react/__tests__/useOrders.test.js +0 -216
  92. package/dist/react/__tests__/useOrders.test.js.map +0 -1
  93. package/dist/react/__tests__/usePayments.test.d.ts +0 -2
  94. package/dist/react/__tests__/usePayments.test.d.ts.map +0 -1
  95. package/dist/react/__tests__/usePayments.test.js +0 -235
  96. package/dist/react/__tests__/usePayments.test.js.map +0 -1
  97. package/dist/react/__tests__/useSquarePayment.test.d.ts +0 -2
  98. package/dist/react/__tests__/useSquarePayment.test.d.ts.map +0 -1
  99. package/dist/react/__tests__/useSquarePayment.test.js +0 -447
  100. package/dist/react/__tests__/useSquarePayment.test.js.map +0 -1
  101. package/dist/react/components/CardInput.d.ts +0 -69
  102. package/dist/react/components/CardInput.d.ts.map +0 -1
  103. package/dist/react/components/CardInput.js +0 -58
  104. package/dist/react/components/CardInput.js.map +0 -1
  105. package/dist/react/components/PaymentButton.d.ts +0 -71
  106. package/dist/react/components/PaymentButton.d.ts.map +0 -1
  107. package/dist/react/components/PaymentButton.js +0 -140
  108. package/dist/react/components/PaymentButton.js.map +0 -1
  109. package/dist/react/components/index.d.ts +0 -5
  110. package/dist/react/components/index.d.ts.map +0 -1
  111. package/dist/react/components/index.js +0 -3
  112. package/dist/react/components/index.js.map +0 -1
  113. package/dist/react/hooks/index.d.ts +0 -11
  114. package/dist/react/hooks/index.d.ts.map +0 -1
  115. package/dist/react/hooks/index.js +0 -6
  116. package/dist/react/hooks/index.js.map +0 -1
  117. package/dist/react/hooks/useCatalog.d.ts +0 -98
  118. package/dist/react/hooks/useCatalog.d.ts.map +0 -1
  119. package/dist/react/hooks/useCatalog.js +0 -134
  120. package/dist/react/hooks/useCatalog.js.map +0 -1
  121. package/dist/react/hooks/useCustomers.d.ts +0 -105
  122. package/dist/react/hooks/useCustomers.d.ts.map +0 -1
  123. package/dist/react/hooks/useCustomers.js +0 -174
  124. package/dist/react/hooks/useCustomers.js.map +0 -1
  125. package/dist/react/hooks/useOrders.d.ts +0 -112
  126. package/dist/react/hooks/useOrders.d.ts.map +0 -1
  127. package/dist/react/hooks/useOrders.js +0 -115
  128. package/dist/react/hooks/useOrders.js.map +0 -1
  129. package/dist/react/hooks/usePayments.d.ts +0 -98
  130. package/dist/react/hooks/usePayments.d.ts.map +0 -1
  131. package/dist/react/hooks/usePayments.js +0 -89
  132. package/dist/react/hooks/usePayments.js.map +0 -1
  133. package/dist/react/hooks/useSquarePayment.d.ts +0 -52
  134. package/dist/react/hooks/useSquarePayment.d.ts.map +0 -1
  135. package/dist/react/hooks/useSquarePayment.js +0 -146
  136. package/dist/react/hooks/useSquarePayment.js.map +0 -1
  137. package/dist/react/index.d.ts +0 -8
  138. package/dist/react/index.d.ts.map +0 -1
  139. package/dist/react/index.js +0 -7
  140. package/dist/react/index.js.map +0 -1
  141. package/dist/react/types.d.ts +0 -183
  142. package/dist/react/types.d.ts.map +0 -1
  143. package/dist/react/types.js +0 -2
  144. package/dist/react/types.js.map +0 -1
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2025 Bates Solutions
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Bates Solutions
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,154 +1,167 @@
1
- <p align="center">
2
- <img src="https://img.shields.io/badge/React-18+-61DAFB?logo=react&logoColor=white&style=for-the-badge" alt="React" height="28">
3
- &nbsp;&nbsp;&nbsp;&nbsp;
4
- <img src="https://img.shields.io/badge/Angular-17+-DD0031?logo=angular&logoColor=white&style=for-the-badge" alt="Angular" height="28">
5
- &nbsp;&nbsp;&nbsp;&nbsp;
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
- </p>
8
-
9
- <h1 align="center">@bates-solutions/squareup</h1>
10
-
11
- <p align="center">
12
- <strong>The modern TypeScript SDK for Square payments</strong><br>
13
- Build payment experiences in React and Angular with type-safe APIs, fluent builders, and framework-native integrations.
14
- </p>
15
-
16
- <p align="center">
17
- <img src="https://img.shields.io/badge/version-0.1.0-blue.svg" alt="version 0.1.0">
18
- <a href="LICENSE"><img src="https://img.shields.io/badge/License-MIT-yellow.svg" alt="License: MIT"></a>
19
- <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
- </p>
26
-
27
- ---
28
-
29
- Stop wrestling with Square's low-level APIs. **squareup** gives you React hooks, Angular services, and a fluent builder API that makes payment integration feel native to your framework. Tokenize cards, process payments, manage orders, and handle webhooks—all with full TypeScript support and zero boilerplate.
30
-
31
- ## Features
32
-
33
- - **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
- - **Type-Safe** - Full TypeScript support with strict types
38
- - **Fluent Builders** - Chainable order and payment construction
39
-
40
- ## 🧪 Testing & Quality
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
- ```
61
-
62
- ## Installation
63
-
64
- ```bash
65
- npm install @bates-solutions/squareup square
66
- ```
67
-
68
- ### Peer Dependencies
69
-
70
- ```bash
71
- # For React integration
72
- npm install react
73
-
74
- # For Angular integration
75
- npm install @angular/core @angular/common rxjs
76
- ```
77
-
78
- ## 📚 Documentation
79
-
80
- - **[Getting Started](./docs/getting-started/)** - Installation and setup guides
81
- - **[Guides](./docs/guides/)** - Framework-specific tutorials and examples
82
- - **[API Reference](./docs/api-reference.md)** - Complete API documentation
83
- - **[Configuration](./docs/getting-started/configuration.md)** - Environment setup
84
-
85
- ## Quick Start
86
-
87
- ### Backend
88
-
89
- ```typescript
90
- import { createSquareClient } from '@bates-solutions/squareup';
91
-
92
- const client = createSquareClient({
93
- accessToken: process.env.SQUARE_ACCESS_TOKEN!,
94
- environment: 'sandbox',
95
- });
96
-
97
- const payment = await client.payments.create({
98
- sourceId: 'cnon:card-nonce',
99
- amount: 1000, // $10.00
100
- currency: 'USD',
101
- });
102
- ```
103
-
104
- ### React
105
-
106
- ```tsx
107
- import { SquareProvider, usePayments } from '@bates-solutions/squareup/react';
108
-
109
- function App() {
110
- return (
111
- <SquareProvider applicationId="sq0idp-xxx" locationId="LXXX" environment="sandbox">
112
- <PaymentForm />
113
- </SquareProvider>
114
- );
115
- }
116
-
117
- function PaymentForm() {
118
- const { processPayment } = usePayments();
119
-
120
- const handlePayment = async () => {
121
- const result = await processPayment({
122
- sourceId: 'cnon:card-nonce',
123
- amount: 1000, // $10.00
124
- currency: 'USD',
125
- });
126
- };
127
-
128
- return <button onClick={handlePayment}>Pay $10.00</button>;
129
- }
130
- ```
131
-
132
- ### Angular
133
-
134
- ```typescript
135
- import { SquareModule } from '@bates-solutions/squareup/angular';
136
-
137
- @NgModule({
138
- imports: [
139
- SquareModule.forRoot({
140
- accessToken: 'YOUR_ACCESS_TOKEN',
141
- environment: 'sandbox',
142
- }),
143
- ],
144
- })
145
- export class AppModule {}
146
- ```
147
-
148
- ## Contributing
149
-
150
- We welcome contributions! Please see our [Contributing Guide](./CONTRIBUTING.md) for details.
151
-
152
- ## License
153
-
154
- MIT - see [LICENSE](./LICENSE) for details.
1
+ <p align="center">
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
+ &nbsp;&nbsp;&nbsp;&nbsp;
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
+ &nbsp;&nbsp;&nbsp;&nbsp;
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
+ </p>
8
+
9
+ <h1 align="center">@bates-solutions/squareup</h1>
10
+
11
+ <p align="center">
12
+ <strong>The modern TypeScript SDK for Square payments</strong><br>
13
+ Build payment backends with type-safe APIs, fluent builders, and webhook support.
14
+ </p>
15
+
16
+ <p align="center">
17
+ <a href="LICENSE"><img src="https://img.shields.io/badge/License-MIT-yellow.svg" alt="License: MIT"></a>
18
+ <a href="https://typescriptlang.org"><img src="https://img.shields.io/badge/TypeScript-5.0+-blue.svg" alt="TypeScript"></a>
19
+ </p>
20
+
21
+ ---
22
+
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.
24
+
25
+ ## Features
26
+
27
+ - **Simplified APIs** - Less boilerplate, more productivity
28
+ - **Type-Safe** - Full TypeScript support with strict types
29
+ - **Fluent Builders** - Chainable order and payment construction
30
+ - **Webhook Support** - Signature verification and middleware for Express/Next.js
31
+ - **Service Classes** - Payments, Orders, Customers, Catalog, Inventory, Subscriptions, Invoices, Loyalty
32
+
33
+ ## Requirements
34
+
35
+ | Dependency | Version |
36
+ | ---------- | ------- |
37
+ | Square SDK | ^43.0.0 |
38
+ | Node.js | 22+ |
39
+ | TypeScript | 5.0+ |
40
+
41
+ ## Installation
42
+
43
+ ```bash
44
+ npm install @bates-solutions/squareup square
45
+ ```
46
+
47
+ ## Quick Start
48
+
49
+ ### Basic Usage
50
+
51
+ ```typescript
52
+ import { createSquareClient } from '@bates-solutions/squareup';
53
+
54
+ const client = createSquareClient({
55
+ accessToken: process.env.SQUARE_ACCESS_TOKEN!,
56
+ environment: 'sandbox',
57
+ });
58
+
59
+ // Process a payment
60
+ const payment = await client.payments.create({
61
+ sourceId: 'cnon:card-nonce',
62
+ amount: 1000, // $10.00
63
+ currency: 'USD',
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
+ });
81
+ ```
82
+
83
+ ### Webhook Handling (Express)
84
+
85
+ ```typescript
86
+ import express from 'express';
87
+ import { createWebhookHandler, rawBodyMiddleware } from '@bates-solutions/squareup/server';
88
+
89
+ const app = express();
90
+
91
+ // Use raw body middleware before JSON parsing for webhook routes
92
+ app.use('/webhooks/square', rawBodyMiddleware);
93
+ app.use(express.json());
94
+
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';
120
+
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 });
135
+ }
136
+ ```
137
+
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
152
+
153
+ ```typescript
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"
159
+ ```
160
+
161
+ ## Contributing
162
+
163
+ We welcome contributions! Please see our [Contributing Guide](./CONTRIBUTING.md) for details.
164
+
165
+ ## License
166
+
167
+ MIT - see [LICENSE](./LICENSE) for details.
package/package.json CHANGED
@@ -1,118 +1,87 @@
1
- {
2
- "name": "@bates-solutions/squareup",
3
- "version": "0.1.0",
4
- "description": "TypeScript wrapper for Square API with React & Angular integrations",
5
- "type": "module",
6
- "main": "./dist/core/index.js",
7
- "types": "./dist/core/index.d.ts",
8
- "exports": {
9
- ".": {
10
- "types": "./dist/core/index.d.ts",
11
- "import": "./dist/core/index.js"
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
- "./server": {
22
- "types": "./dist/server/index.d.ts",
23
- "import": "./dist/server/index.js"
24
- }
25
- },
26
- "files": [
27
- "dist",
28
- "README.md",
29
- "LICENSE"
30
- ],
31
- "scripts": {
32
- "build": "tsc",
33
- "dev": "tsc --watch",
34
- "lint": "eslint src",
35
- "lint:fix": "eslint src --fix",
36
- "typecheck": "tsc --noEmit",
37
- "test": "vitest run",
38
- "test:watch": "vitest",
39
- "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
- "docs": "typedoc",
43
- "prepublishOnly": "npm run build"
44
- },
45
- "keywords": [
46
- "square",
47
- "square-api",
48
- "payments",
49
- "payment-processing",
50
- "react",
51
- "react-hooks",
52
- "angular",
53
- "typescript",
54
- "checkout",
55
- "ecommerce",
56
- "point-of-sale",
57
- "pos",
58
- "sdk",
59
- "api"
60
- ],
61
- "author": "Bates Solutions",
62
- "license": "MIT",
63
- "repository": {
64
- "type": "git",
65
- "url": "git+https://github.com/mbates/squareup.git"
66
- },
67
- "bugs": {
68
- "url": "https://github.com/mbates/squareup/issues"
69
- },
70
- "homepage": "https://github.com/mbates/squareup#readme",
71
- "engines": {
72
- "node": ">=18"
73
- },
74
- "peerDependencies": {
75
- "@angular/core": "^17.0.0 || ^18.0.0 || ^19.0.0",
76
- "react": "^18.0.0 || ^19.0.0",
77
- "square": "^43.2.1"
78
- },
79
- "peerDependenciesMeta": {
80
- "react": {
81
- "optional": true
82
- },
83
- "@angular/core": {
84
- "optional": true
85
- }
86
- },
87
- "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
- "@eslint/js": "^9.39.2",
93
- "@testing-library/dom": "^10.4.1",
94
- "@testing-library/jest-dom": "^6.9.1",
95
- "@testing-library/react": "^16.3.1",
96
- "@types/express": "^5.0.6",
97
- "@types/node": "^25.0.3",
98
- "@types/react": "^19.2.7",
99
- "@typescript-eslint/eslint-plugin": "^8.51.0",
100
- "@typescript-eslint/parser": "^8.51.0",
101
- "@vitest/coverage-v8": "^4.0.0",
102
- "eslint": "^9.39.2",
103
- "eslint-config-prettier": "^10.1.8",
104
- "eslint-plugin-prettier": "^5.1.0",
105
- "jsdom": "^27.4.0",
106
- "prettier": "^3.2.0",
107
- "react": "^19.2.3",
108
- "react-dom": "^19.2.3",
109
- "rxjs": "^7.8.2",
110
- "square": "^43.2.1",
111
- "typedoc": "^0.28.15",
112
- "typedoc-plugin-markdown": "^4.9.0",
113
- "typescript": "^5.3.0",
114
- "typescript-eslint": "^8.51.0",
115
- "vitest": "^4.0.16",
116
- "zone.js": "^0.16.0"
117
- }
118
- }
1
+ {
2
+ "name": "@bates-solutions/squareup",
3
+ "version": "1.0.0",
4
+ "description": "TypeScript wrapper for Square API with webhook support for Node.js backends",
5
+ "type": "module",
6
+ "main": "./dist/core/index.js",
7
+ "types": "./dist/core/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/core/index.d.ts",
11
+ "import": "./dist/core/index.js"
12
+ },
13
+ "./server": {
14
+ "types": "./dist/server/index.d.ts",
15
+ "import": "./dist/server/index.js"
16
+ }
17
+ },
18
+ "files": [
19
+ "dist",
20
+ "README.md",
21
+ "LICENSE"
22
+ ],
23
+ "scripts": {
24
+ "build": "tsc",
25
+ "dev": "tsc --watch",
26
+ "lint": "eslint src",
27
+ "lint:fix": "eslint src --fix",
28
+ "typecheck": "tsc --noEmit",
29
+ "test": "vitest run",
30
+ "test:watch": "vitest",
31
+ "test:coverage": "vitest run --coverage",
32
+ "docs": "typedoc",
33
+ "prepublishOnly": "npm run build"
34
+ },
35
+ "keywords": [
36
+ "square",
37
+ "square-api",
38
+ "payments",
39
+ "payment-processing",
40
+ "typescript",
41
+ "nodejs",
42
+ "backend",
43
+ "webhooks",
44
+ "ecommerce",
45
+ "point-of-sale",
46
+ "pos",
47
+ "sdk",
48
+ "api"
49
+ ],
50
+ "author": "Bates Solutions",
51
+ "license": "MIT",
52
+ "repository": {
53
+ "type": "git",
54
+ "url": "git+https://github.com/mbates/squareup.git"
55
+ },
56
+ "bugs": {
57
+ "url": "https://github.com/mbates/squareup/issues"
58
+ },
59
+ "homepage": "https://github.com/mbates/squareup#readme",
60
+ "engines": {
61
+ "node": ">=22"
62
+ },
63
+ "peerDependencies": {
64
+ "square": "^43.2.1"
65
+ },
66
+ "devDependencies": {
67
+ "@eslint/js": "^9.39.2",
68
+ "@semantic-release/changelog": "^6.0.3",
69
+ "@semantic-release/git": "^10.0.1",
70
+ "@types/express": "^5.0.6",
71
+ "@types/node": "^25.0.3",
72
+ "@typescript-eslint/eslint-plugin": "^8.51.0",
73
+ "@typescript-eslint/parser": "^8.51.0",
74
+ "@vitest/coverage-v8": "^4.0.0",
75
+ "eslint": "^9.39.2",
76
+ "eslint-config-prettier": "^10.1.8",
77
+ "eslint-plugin-prettier": "^5.1.0",
78
+ "prettier": "^3.2.0",
79
+ "semantic-release": "^25.0.2",
80
+ "square": "^43.2.1",
81
+ "typedoc": "^0.28.15",
82
+ "typedoc-plugin-markdown": "^4.9.0",
83
+ "typescript": "^5.3.0",
84
+ "typescript-eslint": "^8.51.0",
85
+ "vitest": "^4.0.16"
86
+ }
87
+ }