@spritz-finance/api-client 0.4.5 → 0.4.7
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 +113 -3
- package/dist/spritz-api-client.cjs +125 -67
- package/dist/spritz-api-client.d.ts +125 -4
- package/dist/spritz-api-client.mjs +125 -67
- package/package.json +1 -1
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)
|
|
@@ -105,6 +107,7 @@ const transactionData = await client.paymentRequest.getWeb3PaymentParams({
|
|
|
105
107
|
- [Payment Requests](#payment-requests)
|
|
106
108
|
- [Create a payment request](#create-a-payment-request)
|
|
107
109
|
- [Fulfil a payment request (EVM transactions)](#fulfil-a-payment-request--evm-transactions-)
|
|
110
|
+
- [Fulfil a payment request (Solana transactions)](#fulfil-a-payment-request--solana-transactions-)
|
|
108
111
|
- [Transaction fees](#transaction-fees)
|
|
109
112
|
- [Payments](#payments)
|
|
110
113
|
- [Retrieve the payment for a payment request](#retrieve-the-payment-for-a-payment-request)
|
|
@@ -304,11 +307,12 @@ Spritz emphasizes its capabilities in account handling and payment processing.
|
|
|
304
307
|
|
|
305
308
|
### Account Types
|
|
306
309
|
|
|
307
|
-
Spritz supports
|
|
310
|
+
Spritz supports four distinct types of accounts:
|
|
308
311
|
|
|
309
312
|
1. **Bank Account**
|
|
310
|
-
2. **
|
|
311
|
-
3. **
|
|
313
|
+
2. **Debit Card**
|
|
314
|
+
3. **Bill**
|
|
315
|
+
4. **Virtual Card**
|
|
312
316
|
|
|
313
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.
|
|
314
318
|
|
|
@@ -426,6 +430,67 @@ const bankAccounts = await client.bankAccount.create(BankAccountType.CABankAccou
|
|
|
426
430
|
})
|
|
427
431
|
```
|
|
428
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
|
+
|
|
429
494
|
### Bills
|
|
430
495
|
|
|
431
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.
|
|
@@ -588,6 +653,14 @@ You can conveniently change the display name of a bank account using the followi
|
|
|
588
653
|
const updateAccount = await client.bankAccount.rename('62d17d3b377dab6c1342136e', 'My new account')
|
|
589
654
|
```
|
|
590
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
|
+
|
|
591
664
|
#### Rename a bill
|
|
592
665
|
|
|
593
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.
|
|
@@ -606,6 +679,14 @@ To remove a bank account from a user's account, you can use the following endpoi
|
|
|
606
679
|
await client.bankAccount.delete('62d17d3b377dab6c1342136e')
|
|
607
680
|
```
|
|
608
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
|
+
|
|
609
690
|
#### Delete a bill
|
|
610
691
|
|
|
611
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.
|
|
@@ -708,6 +789,35 @@ const transactionData = await client.paymentRequest.getWeb3PaymentParams({
|
|
|
708
789
|
|
|
709
790
|
The contract address (to), calldata (data), and value are the primary components used to execute the blockchain transaction. You can use the `requiredTokenInput` to verify that the user's wallet has sufficient funds to complete the payment before initiating the transaction.
|
|
710
791
|
|
|
792
|
+
### Fulfil a payment request (Solana transactions)
|
|
793
|
+
|
|
794
|
+
For Solana payments, you need to obtain a versioned transaction that can be signed and submitted to the Solana network.
|
|
795
|
+
|
|
796
|
+
```typescript
|
|
797
|
+
import {PaymentNetwork} from '@spritz-finance/api-client';
|
|
798
|
+
|
|
799
|
+
const paymentRequest = await client.paymentRequest.create({
|
|
800
|
+
amount: 100,
|
|
801
|
+
accountId: account.id,
|
|
802
|
+
network: PaymentNetwork.Solana,
|
|
803
|
+
});
|
|
804
|
+
|
|
805
|
+
const transactionData = await client.paymentRequest.getSolanaPaymentParams({
|
|
806
|
+
paymentRequest,
|
|
807
|
+
paymentTokenAddress: 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v', // USDC on Solana
|
|
808
|
+
signer: 'YourSolanaWalletAddress...',
|
|
809
|
+
})
|
|
810
|
+
|
|
811
|
+
// Example response
|
|
812
|
+
|
|
813
|
+
{
|
|
814
|
+
versionedTransaction: VersionedTransaction, // Deserialized transaction ready to sign
|
|
815
|
+
transactionSerialized: 'base64EncodedTransaction...' // Base64 encoded transaction
|
|
816
|
+
}
|
|
817
|
+
```
|
|
818
|
+
|
|
819
|
+
The `versionedTransaction` is a deserialized Solana transaction that can be signed with your wallet and submitted to the network. The `transactionSerialized` contains the same transaction in base64 encoded format if needed for your implementation.
|
|
820
|
+
|
|
711
821
|
### Transaction fees
|
|
712
822
|
|
|
713
823
|
Transaction fees are applied once the monthly transaction volume exceeds $100. To determine the fee amount for a specific payment value, you can use the following endpoint.
|