@spritz-finance/api-client 0.0.5 → 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.
Files changed (2) hide show
  1. package/README.md +37 -2
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -23,7 +23,42 @@ A Typescript library for interacting with the Spritz Finance API
23
23
  ```typescript
24
24
  import { SpritzApiClient, Environment } from '@spritz-finance/api-client'
25
25
 
26
- const client = SpritzApiClient.initialize(Environment.Staging, 'YOUR_API_KEY_HERE')
26
+ const client = SpritzApiClient.initialize({
27
+ environment: Environment.Staging,
28
+ apiKey: 'YOUR_USER_API_KEY_HERE',
29
+ integrationKey: 'YOUR_INTEGRATION_KEY_HERE',
30
+ })
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);
27
62
  ```
28
63
 
29
64
  ## Bank Accounts
@@ -231,7 +266,7 @@ const payments = await client.payment.listForAccount(account.id)
231
266
 
232
267
  // Example response
233
268
 
234
- ;[
269
+ [
235
270
  {
236
271
  id: '6368e3a3ec516e9572bbd23b',
237
272
  userId: '63d12d3B577fab6c6382136e',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spritz-finance/api-client",
3
- "version": "0.0.5",
3
+ "version": "0.0.7",
4
4
  "description": "Typescript library for interacting with the Spritz Finance API",
5
5
  "main": "dist/spritz-api-client.js",
6
6
  "module": "dist/spritz-api-client.mjs",