@spritz-finance/api-client 0.0.6 → 0.0.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 +34 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -24,11 +24,43 @@ A Typescript library for interacting with the Spritz Finance API
|
|
|
24
24
|
import { SpritzApiClient, Environment } from '@spritz-finance/api-client'
|
|
25
25
|
|
|
26
26
|
const client = SpritzApiClient.initialize({
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
environment: Environment.Staging,
|
|
28
|
+
apiKey: 'YOUR_USER_API_KEY_HERE',
|
|
29
|
+
integrationKey: 'YOUR_INTEGRATION_KEY_HERE',
|
|
29
30
|
})
|
|
30
31
|
```
|
|
31
32
|
|
|
33
|
+
## Basic payment flow
|
|
34
|
+
|
|
35
|
+
```typescript
|
|
36
|
+
// Fetch all bank accounts for the user
|
|
37
|
+
const bankAccounts = await client.bankAccounts.list()
|
|
38
|
+
|
|
39
|
+
// Choose a bank account to use for the payment request
|
|
40
|
+
const account = bankAccounts[0]
|
|
41
|
+
|
|
42
|
+
// Create a payment request for the selected bank account
|
|
43
|
+
const paymentRequest = await client.paymentRequest.create({
|
|
44
|
+
amount: 100,
|
|
45
|
+
accountId: account.id,
|
|
46
|
+
network: PaymentNetwork.Ethereum,
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
// Retrieve the transaction data required to issue a blockchain transaction
|
|
50
|
+
const transactionData = await client.paymentRequest.getWeb3PaymentParams({
|
|
51
|
+
paymentRequest,
|
|
52
|
+
paymentTokenAddress: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48', // USDC on mainnet
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Issue blockchain transaction with the transaction data
|
|
57
|
+
* and wait for confirmation
|
|
58
|
+
**/
|
|
59
|
+
|
|
60
|
+
// Retrieve the payment issued for the payment request to check the payment status and confirmation
|
|
61
|
+
const payment = await client.payment.getForPaymentRequest(paymentRequest.id);
|
|
62
|
+
```
|
|
63
|
+
|
|
32
64
|
## Bank Accounts
|
|
33
65
|
|
|
34
66
|
Spritz provides robust support for bank accounts, allowing you to easily manage and interact with a user's bank account. To leverage these capabilities, you can utilize our specific methods and functionalities designed for bank accounts.
|
package/package.json
CHANGED