@spritz-finance/api-client 0.4.6 → 0.4.8

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 CHANGED
@@ -29,6 +29,7 @@ import {
29
29
  PaymentNetwork,
30
30
  BankAccountType,
31
31
  BankAccountSubType,
32
+ DebitCardNetwork,
32
33
  } from '@spritz-finance/api-client'
33
34
 
34
35
  // Initialize the client with your integration key
@@ -93,6 +94,7 @@ const transactionData = await client.paymentRequest.getWeb3PaymentParams({
93
94
  - [Account Types](#account-types)
94
95
  - [Commonalities & Differences](#commonalities---differences)
95
96
  - [Bank Accounts](#bank-accounts)
97
+ - [Debit Cards](#debit-cards)
96
98
  - [Bills](#bills)
97
99
  - [Virtual Card](#virtual-card)
98
100
  - [Address Book](#address-book)
@@ -305,11 +307,12 @@ Spritz emphasizes its capabilities in account handling and payment processing.
305
307
 
306
308
  ### Account Types
307
309
 
308
- Spritz supports three distinct types of accounts:
310
+ Spritz supports four distinct types of accounts:
309
311
 
310
312
  1. **Bank Account**
311
- 2. **Bill**
312
- 3. **Virtual Card**
313
+ 2. **Debit Card**
314
+ 3. **Bill**
315
+ 4. **Virtual Card**
313
316
 
314
317
  Though each account type possesses its unique creation process and specific properties, it's important to understand that all of them are uniformly termed as an "account" within the Spritz platform.
315
318
 
@@ -427,6 +430,67 @@ const bankAccounts = await client.bankAccount.create(BankAccountType.CABankAccou
427
430
  })
428
431
  ```
429
432
 
433
+ ### Debit Cards
434
+
435
+ Spritz provides support for adding debit cards as payment accounts, allowing users to make payments directly to their debit cards.
436
+
437
+ #### List user debit cards
438
+
439
+ To retrieve all debit cards linked to a user:
440
+
441
+ ```typescript
442
+ const debitCards = await client.debitCard.list()
443
+ ```
444
+
445
+ The `debitCard.list()` method returns an array of user-linked debit cards:
446
+
447
+ ```typescript
448
+ const debitCards = [{
449
+ id: "62d17d3b377dab6c1342136e",
450
+ type: "DebitCard",
451
+ name: "My Visa Debit",
452
+ userId: "62d17d3b377dab6c1342136e",
453
+ country: "US",
454
+ currency: "USD",
455
+ payable: true,
456
+ debitCardNetwork: "Visa",
457
+ expirationDate: "12/25",
458
+ cardNumber: "4111111111111111",
459
+ mask: "1111",
460
+ createdAt: "2023-01-01T00:00:00Z",
461
+ paymentCount: 5,
462
+ externalId: "ext-123"
463
+ }]
464
+ ```
465
+
466
+ #### Add a debit card
467
+
468
+ To add a new debit card for a user:
469
+
470
+ ```typescript
471
+ import { DebitCardNetwork } from '@spritz-finance/api-client'
472
+
473
+ const debitCard = await client.debitCard.create({
474
+ name: 'My Visa Debit',
475
+ cardNumber: '4111111111111111',
476
+ expirationDate: '12/25',
477
+ })
478
+ ```
479
+
480
+ The input structure for adding a debit card is:
481
+
482
+ ```typescript
483
+ export interface DebitCardInput {
484
+ name?: string | null // Optional name for the card
485
+ cardNumber: string // Full card number (13-19 digits)
486
+ expirationDate: string // Expiration date in MM/YY format
487
+ }
488
+ ```
489
+
490
+ Supported debit card networks:
491
+ - `Visa`
492
+ - `Mastercard`
493
+
430
494
  ### Bills
431
495
 
432
496
  Spritz provides robust support for bills, allowing seamless management and interaction with user billing accounts. Below is a guide to the methods and functionalities specifically designed for handling bills within Spritz.
@@ -589,6 +653,14 @@ You can conveniently change the display name of a bank account using the followi
589
653
  const updateAccount = await client.bankAccount.rename('62d17d3b377dab6c1342136e', 'My new account')
590
654
  ```
591
655
 
656
+ #### Rename a debit card
657
+
658
+ You can change the display name of a debit card:
659
+
660
+ ```typescript
661
+ const updatedCard = await client.debitCard.rename('62d17d3b377dab6c1342136e', 'My primary debit card')
662
+ ```
663
+
592
664
  #### Rename a bill
593
665
 
594
666
  You can conveniently change the display name of a bill using the following endpoint. The first argument specifies the ID of the bill, while the second argument represents the desired new name for the account.
@@ -607,6 +679,14 @@ To remove a bank account from a user's account, you can use the following endpoi
607
679
  await client.bankAccount.delete('62d17d3b377dab6c1342136e')
608
680
  ```
609
681
 
682
+ #### Delete a debit card
683
+
684
+ To remove a debit card from a user's account:
685
+
686
+ ```typescript
687
+ await client.debitCard.delete('62d17d3b377dab6c1342136e')
688
+ ```
689
+
610
690
  #### Delete a bill
611
691
 
612
692
  To remove a bill from a user's account, you can use the following endpoint. You only need to specify the ID of the bill that you want to delete as an argument.
@@ -894,6 +974,10 @@ Spritz currently supports the following webhook events:
894
974
  - `payment.completed`: Triggered when a payment is successfully completed.
895
975
  - `payment.refunded`: Triggered when a payment is refunded.
896
976
 
977
+ #### Verification Events
978
+
979
+ - `verification.status.updated`: Triggered when a user's verification status changes.
980
+
897
981
  These events allow you to respond to changes in the account and payments for a user.
898
982
 
899
983
  ### Setting up webhooks
@@ -919,3 +1003,23 @@ Upon receiving a webhook, your server will get a payload with the following stru
919
1003
  "eventName": "name-of-the-event-here"
920
1004
  }
921
1005
  ```
1006
+
1007
+ ### Webhook security and signing
1008
+
1009
+ Each webhook request is signed using an HMAC SHA256 signature, based on the exact JSON payload sent in the body. This signature is included in the Signature HTTP header of the request.
1010
+
1011
+ The secret key used to compute the signature is the webhook secret you set when configuring your webhook integration. If you have not set a webhook secret, there will be no Signature header in the webhook request.
1012
+
1013
+ You can verify webhook authenticity by computing the HMAC signature and comparing it to the Signature header included in the webhook request.
1014
+
1015
+ #### Example: Verifying a webhook signature (Node.js)
1016
+
1017
+ ```typescript
1018
+ import { createHmac } from "crypto";
1019
+
1020
+ const signature = createHmac("sha256", <YOUR_WEBHOOK_SECRET>)
1021
+ .update(<REQUEST_BODY_AS_JSON_STRING>) // JSON.stringify(payload)
1022
+ .digest("hex");
1023
+ ```
1024
+
1025
+ Ensure that the computed signature matches the Signature header received in the webhook request before processing the payload.