Simple Workflow
1
Create Credit Type
2
Create Wallet
3
Deposit Credits
4
Debit Credits
5
Check Wallet Status
Now we will create a the required elements and performe simple API calls.
Create a Credit Type
First, define the type of credits you'll be managing
bash
1curl -X POST http://localhost:8000/api/v1/credit-types \2-H "Authorization: Bearer YOUR_TOKEN" \3-H "Content-Type: application/json" \4-d '{5"name": "regular",6"description": "Standard currency credits"7}'
Let's create a credit type
Create a Wallet
Now, create a wallet for the user
bash
1curl -X POST http://localhost:8000/api/v1/wallets \2-H "Authorization: Bearer YOUR_TOKEN" \3-H "Content-Type: application/json" \4-d '{5"name": "User Main Wallet",6"context": {7"user_id": "user_123",8"organization": "acme_corp"9}10}'
Let's create a wallet
Deposit Credits
Now, deposit credits into the wallet
bash
1curl -X POST http://localhost:8000/api/v1/wallets/wallet_123/deposit \2-H "Authorization: Bearer YOUR_TOKEN" \3-H "Content-Type: application/json" \4-d '{5"type": "deposit",6"credit_type_id": "credit_type_123",7"description": "Initial deposit",8"issuer": "system",9"payload": {10"type": "deposit",11"amount": 100.0012},13"context": {14"source": "bank_transfer",15"reference": "tx_789"16}17}'
Let's deposit credits for a wallet
Debit Credits
Now, debit credits from the wallet
bash
1curl -X POST http://localhost:8000/api/v1/wallets/wallet_123/debit \2-H "Authorization: Bearer YOUR_TOKEN" \3-H "Content-Type: application/json" \4-d '{5"type": "debit",6"credit_type_id": "credit_type_123",7"description": "Service purchase",8"issuer": "system",9"payload": {10"type": "debit",11"amount": 50.0012},13"context": {14"purpose": "service_payment",15"service_id": "srv_456"16}17}'
Let's debit credits for a wallet
Check Wallet Status
Now, check the status of the wallet
bash
1curl -X GET http://localhost:8000/api/v1/wallets/wallet_123 \2-H "Authorization: Bearer YOUR_TOKEN"'
Let's deposit credits for a wallet