@bates-solutions/squareup 0.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.
Files changed (220) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +154 -0
  3. package/README.md.backup +292 -0
  4. package/dist/angular/__tests__/setup.d.ts +1 -0
  5. package/dist/angular/__tests__/setup.d.ts.map +1 -0
  6. package/dist/angular/__tests__/setup.js +5 -0
  7. package/dist/angular/__tests__/setup.js.map +1 -0
  8. package/dist/angular/components/index.d.ts +2 -0
  9. package/dist/angular/components/index.d.ts.map +1 -0
  10. package/dist/angular/components/index.js +2 -0
  11. package/dist/angular/components/index.js.map +1 -0
  12. package/dist/angular/components/payment-button.component.d.ts +49 -0
  13. package/dist/angular/components/payment-button.component.d.ts.map +1 -0
  14. package/dist/angular/components/payment-button.component.js +176 -0
  15. package/dist/angular/components/payment-button.component.js.map +1 -0
  16. package/dist/angular/directives/index.d.ts +2 -0
  17. package/dist/angular/directives/index.d.ts.map +1 -0
  18. package/dist/angular/directives/index.js +2 -0
  19. package/dist/angular/directives/index.js.map +1 -0
  20. package/dist/angular/directives/square-card.directive.d.ts +52 -0
  21. package/dist/angular/directives/square-card.directive.d.ts.map +1 -0
  22. package/dist/angular/directives/square-card.directive.js +98 -0
  23. package/dist/angular/directives/square-card.directive.js.map +1 -0
  24. package/dist/angular/index.d.ts +42 -0
  25. package/dist/angular/index.d.ts.map +1 -0
  26. package/dist/angular/index.js +45 -0
  27. package/dist/angular/index.js.map +1 -0
  28. package/dist/angular/services/index.d.ts +6 -0
  29. package/dist/angular/services/index.d.ts.map +1 -0
  30. package/dist/angular/services/index.js +6 -0
  31. package/dist/angular/services/index.js.map +1 -0
  32. package/dist/angular/services/square-catalog.service.d.ts +60 -0
  33. package/dist/angular/services/square-catalog.service.d.ts.map +1 -0
  34. package/dist/angular/services/square-catalog.service.js +152 -0
  35. package/dist/angular/services/square-catalog.service.js.map +1 -0
  36. package/dist/angular/services/square-customers.service.d.ts +77 -0
  37. package/dist/angular/services/square-customers.service.d.ts.map +1 -0
  38. package/dist/angular/services/square-customers.service.js +187 -0
  39. package/dist/angular/services/square-customers.service.js.map +1 -0
  40. package/dist/angular/services/square-orders.service.d.ts +66 -0
  41. package/dist/angular/services/square-orders.service.d.ts.map +1 -0
  42. package/dist/angular/services/square-orders.service.js +170 -0
  43. package/dist/angular/services/square-orders.service.js.map +1 -0
  44. package/dist/angular/services/square-payments.service.d.ts +73 -0
  45. package/dist/angular/services/square-payments.service.d.ts.map +1 -0
  46. package/dist/angular/services/square-payments.service.js +167 -0
  47. package/dist/angular/services/square-payments.service.js.map +1 -0
  48. package/dist/angular/services/square-sdk.service.d.ts +45 -0
  49. package/dist/angular/services/square-sdk.service.d.ts.map +1 -0
  50. package/dist/angular/services/square-sdk.service.js +133 -0
  51. package/dist/angular/services/square-sdk.service.js.map +1 -0
  52. package/dist/angular/square.module.d.ts +36 -0
  53. package/dist/angular/square.module.d.ts.map +1 -0
  54. package/dist/angular/square.module.js +75 -0
  55. package/dist/angular/square.module.js.map +1 -0
  56. package/dist/angular/types.d.ts +189 -0
  57. package/dist/angular/types.d.ts.map +1 -0
  58. package/dist/angular/types.js +8 -0
  59. package/dist/angular/types.js.map +1 -0
  60. package/dist/core/builders/order.builder.d.ts +140 -0
  61. package/dist/core/builders/order.builder.d.ts.map +1 -0
  62. package/dist/core/builders/order.builder.js +185 -0
  63. package/dist/core/builders/order.builder.js.map +1 -0
  64. package/dist/core/client.d.ts +93 -0
  65. package/dist/core/client.d.ts.map +1 -0
  66. package/dist/core/client.js +99 -0
  67. package/dist/core/client.js.map +1 -0
  68. package/dist/core/errors.d.ts +55 -0
  69. package/dist/core/errors.d.ts.map +1 -0
  70. package/dist/core/errors.js +118 -0
  71. package/dist/core/errors.js.map +1 -0
  72. package/dist/core/index.d.ts +17 -0
  73. package/dist/core/index.d.ts.map +1 -0
  74. package/dist/core/index.js +18 -0
  75. package/dist/core/index.js.map +1 -0
  76. package/dist/core/services/catalog.service.d.ts +218 -0
  77. package/dist/core/services/catalog.service.d.ts.map +1 -0
  78. package/dist/core/services/catalog.service.js +274 -0
  79. package/dist/core/services/catalog.service.js.map +1 -0
  80. package/dist/core/services/customers.service.d.ts +197 -0
  81. package/dist/core/services/customers.service.d.ts.map +1 -0
  82. package/dist/core/services/customers.service.js +246 -0
  83. package/dist/core/services/customers.service.js.map +1 -0
  84. package/dist/core/services/inventory.service.d.ts +196 -0
  85. package/dist/core/services/inventory.service.d.ts.map +1 -0
  86. package/dist/core/services/inventory.service.js +266 -0
  87. package/dist/core/services/inventory.service.js.map +1 -0
  88. package/dist/core/services/invoices.service.d.ts +211 -0
  89. package/dist/core/services/invoices.service.d.ts.map +1 -0
  90. package/dist/core/services/invoices.service.js +297 -0
  91. package/dist/core/services/invoices.service.js.map +1 -0
  92. package/dist/core/services/loyalty.service.d.ts +282 -0
  93. package/dist/core/services/loyalty.service.d.ts.map +1 -0
  94. package/dist/core/services/loyalty.service.js +340 -0
  95. package/dist/core/services/loyalty.service.js.map +1 -0
  96. package/dist/core/services/orders.service.d.ts +121 -0
  97. package/dist/core/services/orders.service.d.ts.map +1 -0
  98. package/dist/core/services/orders.service.js +208 -0
  99. package/dist/core/services/orders.service.js.map +1 -0
  100. package/dist/core/services/payments.service.d.ts +121 -0
  101. package/dist/core/services/payments.service.d.ts.map +1 -0
  102. package/dist/core/services/payments.service.js +189 -0
  103. package/dist/core/services/payments.service.js.map +1 -0
  104. package/dist/core/services/subscriptions.service.d.ts +205 -0
  105. package/dist/core/services/subscriptions.service.d.ts.map +1 -0
  106. package/dist/core/services/subscriptions.service.js +265 -0
  107. package/dist/core/services/subscriptions.service.js.map +1 -0
  108. package/dist/core/types/index.d.ts +68 -0
  109. package/dist/core/types/index.d.ts.map +1 -0
  110. package/dist/core/types/index.js +2 -0
  111. package/dist/core/types/index.js.map +1 -0
  112. package/dist/core/utils.d.ts +74 -0
  113. package/dist/core/utils.d.ts.map +1 -0
  114. package/dist/core/utils.js +96 -0
  115. package/dist/core/utils.js.map +1 -0
  116. package/dist/react/SquareProvider.d.ts +50 -0
  117. package/dist/react/SquareProvider.d.ts.map +1 -0
  118. package/dist/react/SquareProvider.js +134 -0
  119. package/dist/react/SquareProvider.js.map +1 -0
  120. package/dist/react/__tests__/CardInput.test.d.ts +2 -0
  121. package/dist/react/__tests__/CardInput.test.d.ts.map +1 -0
  122. package/dist/react/__tests__/CardInput.test.js +218 -0
  123. package/dist/react/__tests__/CardInput.test.js.map +1 -0
  124. package/dist/react/__tests__/PaymentButton.test.d.ts +2 -0
  125. package/dist/react/__tests__/PaymentButton.test.d.ts.map +1 -0
  126. package/dist/react/__tests__/PaymentButton.test.js +400 -0
  127. package/dist/react/__tests__/PaymentButton.test.js.map +1 -0
  128. package/dist/react/__tests__/SquareProvider.test.d.ts +2 -0
  129. package/dist/react/__tests__/SquareProvider.test.d.ts.map +1 -0
  130. package/dist/react/__tests__/SquareProvider.test.js +126 -0
  131. package/dist/react/__tests__/SquareProvider.test.js.map +1 -0
  132. package/dist/react/__tests__/setup.d.ts +2 -0
  133. package/dist/react/__tests__/setup.d.ts.map +1 -0
  134. package/dist/react/__tests__/setup.js +3 -0
  135. package/dist/react/__tests__/setup.js.map +1 -0
  136. package/dist/react/__tests__/useCatalog.test.d.ts +2 -0
  137. package/dist/react/__tests__/useCatalog.test.d.ts.map +1 -0
  138. package/dist/react/__tests__/useCatalog.test.js +277 -0
  139. package/dist/react/__tests__/useCatalog.test.js.map +1 -0
  140. package/dist/react/__tests__/useCustomers.test.d.ts +2 -0
  141. package/dist/react/__tests__/useCustomers.test.d.ts.map +1 -0
  142. package/dist/react/__tests__/useCustomers.test.js +312 -0
  143. package/dist/react/__tests__/useCustomers.test.js.map +1 -0
  144. package/dist/react/__tests__/useOrders.test.d.ts +2 -0
  145. package/dist/react/__tests__/useOrders.test.d.ts.map +1 -0
  146. package/dist/react/__tests__/useOrders.test.js +216 -0
  147. package/dist/react/__tests__/useOrders.test.js.map +1 -0
  148. package/dist/react/__tests__/usePayments.test.d.ts +2 -0
  149. package/dist/react/__tests__/usePayments.test.d.ts.map +1 -0
  150. package/dist/react/__tests__/usePayments.test.js +235 -0
  151. package/dist/react/__tests__/usePayments.test.js.map +1 -0
  152. package/dist/react/__tests__/useSquarePayment.test.d.ts +2 -0
  153. package/dist/react/__tests__/useSquarePayment.test.d.ts.map +1 -0
  154. package/dist/react/__tests__/useSquarePayment.test.js +447 -0
  155. package/dist/react/__tests__/useSquarePayment.test.js.map +1 -0
  156. package/dist/react/components/CardInput.d.ts +69 -0
  157. package/dist/react/components/CardInput.d.ts.map +1 -0
  158. package/dist/react/components/CardInput.js +58 -0
  159. package/dist/react/components/CardInput.js.map +1 -0
  160. package/dist/react/components/PaymentButton.d.ts +71 -0
  161. package/dist/react/components/PaymentButton.d.ts.map +1 -0
  162. package/dist/react/components/PaymentButton.js +140 -0
  163. package/dist/react/components/PaymentButton.js.map +1 -0
  164. package/dist/react/components/index.d.ts +5 -0
  165. package/dist/react/components/index.d.ts.map +1 -0
  166. package/dist/react/components/index.js +3 -0
  167. package/dist/react/components/index.js.map +1 -0
  168. package/dist/react/hooks/index.d.ts +11 -0
  169. package/dist/react/hooks/index.d.ts.map +1 -0
  170. package/dist/react/hooks/index.js +6 -0
  171. package/dist/react/hooks/index.js.map +1 -0
  172. package/dist/react/hooks/useCatalog.d.ts +98 -0
  173. package/dist/react/hooks/useCatalog.d.ts.map +1 -0
  174. package/dist/react/hooks/useCatalog.js +134 -0
  175. package/dist/react/hooks/useCatalog.js.map +1 -0
  176. package/dist/react/hooks/useCustomers.d.ts +105 -0
  177. package/dist/react/hooks/useCustomers.d.ts.map +1 -0
  178. package/dist/react/hooks/useCustomers.js +174 -0
  179. package/dist/react/hooks/useCustomers.js.map +1 -0
  180. package/dist/react/hooks/useOrders.d.ts +112 -0
  181. package/dist/react/hooks/useOrders.d.ts.map +1 -0
  182. package/dist/react/hooks/useOrders.js +115 -0
  183. package/dist/react/hooks/useOrders.js.map +1 -0
  184. package/dist/react/hooks/usePayments.d.ts +98 -0
  185. package/dist/react/hooks/usePayments.d.ts.map +1 -0
  186. package/dist/react/hooks/usePayments.js +89 -0
  187. package/dist/react/hooks/usePayments.js.map +1 -0
  188. package/dist/react/hooks/useSquarePayment.d.ts +52 -0
  189. package/dist/react/hooks/useSquarePayment.d.ts.map +1 -0
  190. package/dist/react/hooks/useSquarePayment.js +146 -0
  191. package/dist/react/hooks/useSquarePayment.js.map +1 -0
  192. package/dist/react/index.d.ts +8 -0
  193. package/dist/react/index.d.ts.map +1 -0
  194. package/dist/react/index.js +7 -0
  195. package/dist/react/index.js.map +1 -0
  196. package/dist/react/types.d.ts +183 -0
  197. package/dist/react/types.d.ts.map +1 -0
  198. package/dist/react/types.js +2 -0
  199. package/dist/react/types.js.map +1 -0
  200. package/dist/server/index.d.ts +43 -0
  201. package/dist/server/index.d.ts.map +1 -0
  202. package/dist/server/index.js +45 -0
  203. package/dist/server/index.js.map +1 -0
  204. package/dist/server/middleware/express.d.ts +77 -0
  205. package/dist/server/middleware/express.d.ts.map +1 -0
  206. package/dist/server/middleware/express.js +123 -0
  207. package/dist/server/middleware/express.js.map +1 -0
  208. package/dist/server/middleware/nextjs.d.ts +118 -0
  209. package/dist/server/middleware/nextjs.d.ts.map +1 -0
  210. package/dist/server/middleware/nextjs.js +172 -0
  211. package/dist/server/middleware/nextjs.js.map +1 -0
  212. package/dist/server/types.d.ts +89 -0
  213. package/dist/server/types.d.ts.map +1 -0
  214. package/dist/server/types.js +7 -0
  215. package/dist/server/types.js.map +1 -0
  216. package/dist/server/webhook.d.ts +114 -0
  217. package/dist/server/webhook.d.ts.map +1 -0
  218. package/dist/server/webhook.js +190 -0
  219. package/dist/server/webhook.js.map +1 -0
  220. package/package.json +118 -0
package/LICENSE ADDED
@@ -0,0 +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.
package/README.md ADDED
@@ -0,0 +1,154 @@
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.
@@ -0,0 +1,292 @@
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
+ ## Quick Start
79
+
80
+ ### Core (Node.js/Backend)
81
+
82
+ ```typescript
83
+ import { createSquareClient } from '@bates-solutions/squareup';
84
+
85
+ const square = createSquareClient({
86
+ accessToken: process.env.SQUARE_ACCESS_TOKEN!,
87
+ environment: 'sandbox',
88
+ });
89
+
90
+ // Create a payment
91
+ const payment = await square.payments.create({
92
+ sourceId: 'cnon:card-nonce-ok',
93
+ amount: 1000, // $10.00 in cents
94
+ currency: 'USD',
95
+ });
96
+
97
+ // Build an order with fluent API
98
+ const order = await square.orders
99
+ .builder()
100
+ .addItem({ name: 'Latte', amount: 450 })
101
+ .addItem({ catalogId: 'ITEM_123', quantity: 2 })
102
+ .withTip(100)
103
+ .build();
104
+ ```
105
+
106
+ ### React
107
+
108
+ ```tsx
109
+ import { SquareProvider, useSquarePayment, useOrders } from '@bates-solutions/squareup/react';
110
+
111
+ function App() {
112
+ return (
113
+ <SquareProvider applicationId="sq0idp-xxx" locationId="LXXX" environment="sandbox">
114
+ <Checkout />
115
+ </SquareProvider>
116
+ );
117
+ }
118
+
119
+ function Checkout() {
120
+ const { cardRef, tokenize, ready, error } = useSquarePayment();
121
+ const { create: createOrder } = useOrders();
122
+
123
+ const handlePay = async () => {
124
+ const token = await tokenize();
125
+ await createOrder({
126
+ lineItems: [{ name: 'Coffee', amount: 500 }],
127
+ paymentToken: token,
128
+ });
129
+ };
130
+
131
+ return (
132
+ <div>
133
+ <div ref={cardRef} />
134
+ <button onClick={handlePay} disabled={!ready}>
135
+ Pay $5.00
136
+ </button>
137
+ {error && <p>{error.message}</p>}
138
+ </div>
139
+ );
140
+ }
141
+ ```
142
+
143
+ ### Angular
144
+
145
+ ```typescript
146
+ import { SquareModule } from '@bates-solutions/squareup/angular';
147
+
148
+ @NgModule({
149
+ imports: [
150
+ SquareModule.forRoot({
151
+ applicationId: 'sq0idp-xxx',
152
+ locationId: 'LXXX',
153
+ environment: 'sandbox',
154
+ })
155
+ ]
156
+ })
157
+ export class AppModule {}
158
+
159
+ @Component({...})
160
+ export class CheckoutComponent {
161
+ constructor(private square: SquarePaymentsService) {}
162
+
163
+ pay$ = () => this.square.tokenize().pipe(
164
+ switchMap(token => this.square.createPayment({
165
+ sourceId: token,
166
+ amount: 1000
167
+ }))
168
+ );
169
+ }
170
+ ```
171
+
172
+ ### Server (Webhooks)
173
+
174
+ ```typescript
175
+ import { createNextWebhookHandler } from '@bates-solutions/squareup/server';
176
+
177
+ // Next.js App Router
178
+ export const POST = createNextWebhookHandler({
179
+ signatureKey: process.env.SQUARE_WEBHOOK_KEY!,
180
+ handlers: {
181
+ 'payment.completed': async (event) => {
182
+ console.log('Payment received:', event.data.id);
183
+ },
184
+ 'order.fulfillment.updated': async (event) => {
185
+ await notifyCustomer(event.data.object);
186
+ },
187
+ },
188
+ });
189
+ ```
190
+
191
+ ## API Reference
192
+
193
+ ### Core Module
194
+
195
+ | Export | Description |
196
+ | ---------------------- | -------------------------------------- |
197
+ | `createSquareClient` | Factory for creating Square API client |
198
+ | `PaymentsService` | Payment processing operations |
199
+ | `OrdersService` | Order management with fluent builder |
200
+ | `CustomersService` | Customer CRUD and search |
201
+ | `CatalogService` | Product catalog operations |
202
+ | `InventoryService` | Stock tracking and adjustments |
203
+ | `SubscriptionsService` | Recurring billing management |
204
+ | `InvoicesService` | Invoice generation and sending |
205
+ | `LoyaltyService` | Loyalty program management |
206
+
207
+ ### React Module (`@bates-solutions/squareup/react`)
208
+
209
+ | Export | Description |
210
+ | ------------------ | --------------------------------------- |
211
+ | `SquareProvider` | Context provider for SDK initialization |
212
+ | `useSquare` | Access Square context |
213
+ | `useSquarePayment` | Card tokenization hook |
214
+ | `usePayments` | Payments API hook |
215
+ | `useOrders` | Orders API hook |
216
+ | `useCustomers` | Customers API hook |
217
+ | `useCatalog` | Catalog API hook |
218
+ | `CardInput` | Pre-built card input component |
219
+ | `PaymentButton` | Google Pay / Apple Pay button |
220
+
221
+ ### Angular Module (`@bates-solutions/squareup/angular`)
222
+
223
+ | Export | Description |
224
+ | ------------------------ | --------------------------------------- |
225
+ | `SquareModule` | NgModule with `forRoot()` configuration |
226
+ | `SquareSdkService` | SDK loading service |
227
+ | `SquarePaymentsService` | Payment operations |
228
+ | `SquareOrdersService` | Order operations |
229
+ | `SquareCustomersService` | Customer operations |
230
+ | `SquareCatalogService` | Catalog operations |
231
+ | `SquareCardDirective` | Card input directive |
232
+ | `PaymentButtonComponent` | Digital wallet component |
233
+
234
+ ### Server Module (`@bates-solutions/squareup/server`)
235
+
236
+ | Export | Description |
237
+ | ------------------------------- | ---------------------------------- |
238
+ | `verifySignature` | HMAC-SHA256 signature verification |
239
+ | `createExpressWebhookHandler` | Express middleware |
240
+ | `createNextWebhookHandler` | Next.js App Router handler |
241
+ | `createNextPagesWebhookHandler` | Next.js Pages Router handler |
242
+ | `parseNextWebhook` | Manual webhook parsing |
243
+
244
+ ## Money Utilities
245
+
246
+ ```typescript
247
+ import { toCents, fromCents, formatMoney } from '@bates-solutions/squareup';
248
+
249
+ toCents(10.99); // 1099
250
+ fromCents(1099); // 10.99
251
+ formatMoney(1099, 'USD'); // '$10.99'
252
+ ```
253
+
254
+ ## Error Handling
255
+
256
+ ```typescript
257
+ import {
258
+ SquareApiError,
259
+ SquareValidationError,
260
+ SquareNetworkError,
261
+ SquareAuthenticationError
262
+ } from '@bates-solutions/squareup';
263
+
264
+ try {
265
+ await square.payments.create({ ... });
266
+ } catch (error) {
267
+ if (error instanceof SquareValidationError) {
268
+ console.log('Invalid input:', error.errors);
269
+ } else if (error instanceof SquareAuthenticationError) {
270
+ console.log('Check your access token');
271
+ } else if (error instanceof SquareNetworkError) {
272
+ console.log('Network issue, retry later');
273
+ }
274
+ }
275
+ ```
276
+
277
+ ## Configuration
278
+
279
+ | Option | Type | Required | Description |
280
+ | --------------- | --------------------------- | ------------- | -------------------------------------- |
281
+ | `accessToken` | `string` | Yes | Square API access token |
282
+ | `environment` | `'sandbox' \| 'production'` | No | API environment (default: `'sandbox'`) |
283
+ | `applicationId` | `string` | React/Angular | Web Payments SDK application ID |
284
+ | `locationId` | `string` | React/Angular | Square location ID |
285
+
286
+ ## Contributing
287
+
288
+ Contributions are welcome! Please read our contributing guidelines before submitting a PR.
289
+
290
+ ## License
291
+
292
+ MIT
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=setup.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../../../src/angular/__tests__/setup.ts"],"names":[],"mappings":""}
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ // Angular tests use direct instantiation and mocked NgZone,
3
+ // so Zone.js is not required for our test setup.
4
+ // Keeping Zone.js out avoids hanging processes in CI.
5
+ //# sourceMappingURL=setup.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"setup.js","sourceRoot":"","sources":["../../../src/angular/__tests__/setup.ts"],"names":[],"mappings":";AAAA,4DAA4D;AAC5D,iDAAiD;AACjD,sDAAsD"}
@@ -0,0 +1,2 @@
1
+ export { PaymentButtonComponent } from './payment-button.component.js';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,2 @@
1
+ export { PaymentButtonComponent } from './payment-button.component.js';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/angular/components/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC"}
@@ -0,0 +1,49 @@
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
@@ -0,0 +1 @@
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"}