Skip to content

Commit 5224571

Browse files
committed
Update README.md
1 parent 1b50873 commit 5224571

File tree

1 file changed

+27
-128
lines changed

1 file changed

+27
-128
lines changed

README.md

Lines changed: 27 additions & 128 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,6 @@
55

66
The Square TypeScript library provides convenient access to the Square API from TypeScript.
77

8-
## Requirements
9-
10-
Use of the Square Node.js SDK requires:
11-
12-
- Node.js 14 or higher
13-
14-
This SDK supports Node.js versions that are either current, or that are in long-term support status (LTS). The SDK does not support Node.js versions that have reached their end-of-life (EOL). For more information on Node.js versioning, see <https://nodejs.org/en/about/releases/>.
15-
16-
This SDK is for use with Node.js only. It does not support other usages, such as for web browsers or frontend applications.
17-
188
## Installation
199

2010
```sh
@@ -25,9 +15,16 @@ npm i -s square
2515

2616
A full reference for this library is available [here](./reference.md).
2717

28-
## Quickstart
18+
## Versioning
19+
20+
By default, the SDK is pinned to the latest version. If you would like
21+
to override this version you can simply pass in a request option.
2922

30-
For more information, see [Square Node.js SDK Quickstart](https://developer.squareup.com/docs/sdks/nodejs/quick-start).
23+
```ts
24+
await client.payments.create(..., {
25+
version: "2024-05-04" // override the version used
26+
})
27+
```
3128

3229
## Usage
3330

@@ -41,11 +38,11 @@ await client.payments.create({
4138
sourceId: "ccof:GaJGNaZa8x4OgDJn4GB",
4239
idempotencyKey: "7b0f3ec5-086a-4871-8f13-3c81b3875218",
4340
amountMoney: {
44-
amount: 1000,
41+
amount: BigInt(1000),
4542
currency: "USD",
4643
},
4744
appFeeMoney: {
48-
amount: 10,
45+
amount: BigInt(10),
4946
currency: "USD",
5047
},
5148
autocomplete: true,
@@ -69,120 +66,6 @@ const request: Square.CreateMobileAuthorizationCodeRequest = {
6966
};
7067
```
7168

72-
## Tests
73-
74-
First, clone the repo locally and `cd` into the directory.
75-
76-
```sh
77-
git clone https://github.com/square/square-nodejs-sdk.git
78-
cd square-nodejs-sdk
79-
```
80-
81-
Next, install dependencies and build.
82-
83-
```sh
84-
npm install
85-
npm run build
86-
```
87-
88-
Before running the tests, get a sandbox access token from your [Developer Dashboard] and use it to set a `SQUARE_SANDBOX_TOKEN` environment variable.
89-
90-
```sh
91-
export SQUARE_SANDBOX_TOKEN="YOUR SANDBOX ACCESS TOKEN HERE"
92-
```
93-
94-
And run the tests.
95-
96-
```sh
97-
npm test
98-
```
99-
100-
## SDK Reference
101-
102-
### Payments
103-
104-
- [Payments]
105-
- [Refunds]
106-
- [Disputes]
107-
- [Checkout]
108-
- [Apple Pay]
109-
- [Cards]
110-
- [Payouts]
111-
112-
### Terminal
113-
114-
- [Terminal]
115-
116-
### Orders
117-
118-
- [Orders]
119-
- [Order Custom Attributes]
120-
121-
### Subscriptions
122-
123-
- [Subscriptions]
124-
125-
### Invoices
126-
127-
- [Invoices]
128-
129-
### Items
130-
131-
- [Catalog]
132-
- [Inventory]
133-
134-
### Customers
135-
136-
- [Customers]
137-
- [Customer Groups]
138-
- [Customer Segments]
139-
140-
### Loyalty
141-
142-
- [Loyalty]
143-
144-
### Gift Cards
145-
146-
- [Gift Cards]
147-
- [Gift Card Activities]
148-
149-
### Bookings
150-
151-
- [Bookings]
152-
- [Booking Custom Attributes]
153-
154-
### Business
155-
156-
- [Merchants]
157-
- [Merchant Custom Attributes]
158-
- [Locations]
159-
- [Location Custom Attributes]
160-
- [Devices]
161-
- [Cash Drawers]
162-
163-
### Team
164-
165-
- [Team]
166-
- [Labor]
167-
168-
### Financials
169-
170-
- [Bank Accounts]
171-
172-
### Online
173-
174-
- [Sites]
175-
- [Snippets]
176-
177-
### Authorization
178-
179-
- [Mobile Authorization]
180-
- [OAuth]
181-
182-
### Webhook Subscriptions
183-
184-
- [Webhook Subscriptions]
185-
18669
## Exception Handling
18770

18871
When the API returns a non-success status code (4xx or 5xx response), a subclass of the following error
@@ -222,6 +105,22 @@ while (page.hasNextPage()) {
222105
}
223106
```
224107

108+
## Webhook Signature Verification
109+
110+
The SDK provides utility methods that allow you to verify webhook signatures and ensure that all
111+
webhook events originate from Square. The `Webhooks.verifySignature` method will verify the signature.
112+
113+
```ts
114+
import { WebhooksHelper } from "square";
115+
116+
const isValid = WebhooksHelper.verifySignature({
117+
requestBody,
118+
signatureHeader: request.headers['x-square-hmacsha256-signature'],
119+
signatureKey: "YOUR_SIGNATURE_KEY",
120+
notificationUrl: "https://example.com/webhook", // The URL where event notifications are sent.
121+
});
122+
```
123+
225124
## Advanced
226125

227126
### Additional Headers

0 commit comments

Comments
 (0)