import SnagSolutions from '@snagsolutions/sdk';
const client = new SnagSolutions({
apiKey: process.env['X_API_KEY'], // This is the default and can be omitted
});
const response = await client.loyalty.transactions.createTransaction({
description: 'Purchase of item X',
entries: [{ amount: 5 }],
});
console.log(response.id);{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"description": "<string>",
"entries": [
{
"walletAddress": "<string>",
"amount": 123,
"direction": "credit",
"idempotencyKey": "<string>"
}
],
"createdAt": "<string>",
"updatedAt": "<string>"
}Create a loyalty transaction to update account balances.
import SnagSolutions from '@snagsolutions/sdk';
const client = new SnagSolutions({
apiKey: process.env['X_API_KEY'], // This is the default and can be omitted
});
const response = await client.loyalty.transactions.createTransaction({
description: 'Purchase of item X',
entries: [{ amount: 5 }],
});
console.log(response.id);{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"description": "<string>",
"entries": [
{
"walletAddress": "<string>",
"amount": 123,
"direction": "credit",
"idempotencyKey": "<string>"
}
],
"createdAt": "<string>",
"updatedAt": "<string>"
}Body
Schema for creating a loyalty transaction
Description of the loyalty transaction
"Purchase of item X"
Array of transaction entries
Show child attributes
Transaction entry amount.
5
The wallet address of the user
"0x1234567890abcdef1234567890abcdef12345678"
Direction of the transaction entry for this wallet address
credit, debit "credit"
Idempotency key for the transaction entry. Creation will fail if already exists for this wallet address.
32"example-idempotency-key"
Unique identifier for the loyalty currency for the wallet. Can only use entry-level currency or transaction-level currency.
"123e4567-e89b-12d3-a456-426614174090"
Unique identifier for the loyalty currency
"123e4567-e89b-12d3-a456-426614174090"
200
Was this page helpful?