Search.../

listTransactions( )

Developer Preview

Retrieves a list of transactions for a specified loyalty account.

Description

The listTransactions() function returns a Promise that resolves to a list of loyalty transactions for the loyalty account specified by the account ID.

Loyalty transactions include activities that change a loyalty account point balance, such as adjusting, earning, or redeeming loyalty points. If you want to get a specific transaction use that transaction's ID and the getTransaction() function.

Admin Method

This function requires elevated permissions to run. This function is not universal and runs only on the backend.

Syntax

function listTransactions(accountId: string, options: ListTransactionsOptions): Promise<ListTransactionsResponse>

listTransactions Parameters

NAME
TYPE
DESCRIPTION
accountId
string

Loyalty account ID.

options
Optional
ListTransactionsOptions

Options to use when retrieving a list of loyalty transactions.

Returns

Return Type:

Promise<
ListTransactionsResponse
>
NAME
TYPE
DESCRIPTION
pagingMetadata
PagingMetadataV2

Details on the paged set of results returned.

transactions
Array<
Transaction
>

Retrieved transactions.

Was this helpful?

Get a list of transactions for a loyalty account

Copy Code
1import { accounts } from 'wix-loyalty.v2';
2
3// Sample accountId value: 'b04a7524-f0cc-435a-981a-b765f758438b'
4
5export async function myListTransactionsFunction() {
6 try {
7 const transactionsList = await accounts.listTransactions(accountId);
8
9 const firstId = transactionsList.transactions[0]._id;
10 const firstStatus = transactionsList.transactions[0].type;
11
12 console.log('The most recent transaction ID is: ', firstId);
13 return transactionsList;
14 } catch (error) {
15 console.error(error);
16 }
17}
18
19/* Promise resolves to:
20 * {
21 * "transactions": [{
22 * "id": "03992fc4-8e8c-4406-8d3c-0292ed3be5d8",
23 * "accountId": "b04a7524-f0cc-435a-981a-b765f758438b",
24 * "contactId": "8b4ff9ff-2f9a-41de-901d-9f6ecdb91664",
25 * "amount": 150,
26 * "type": "ADJUST",
27 * "description": "Signed up as site member.",
28 * "createdDate": "2022-05-23T22:50:49.366Z",
29 * "appId": "553c79f3-5625-4f38-b14b-ef7c0d1e87df"
30 * },
31 * {
32 * "id": "70f0711b-e16f-44d7-ad03-4301c78d8623",
33 * "accountId": "b04a7524-f0cc-435a-981a-b765f758438b",
34 * "contactId": "8b4ff9ff-2f9a-41de-901d-9f6ecdb91664",
35 * "amount": 50,
36 * "type": "EARN",
37 * "description": "Shared post on social",
38 * "createdDate": "2022-05-24T09:11:51.274Z",
39 * "appId": "553c79f3-5625-4f38-b14b-ef7c0d1e87df",
40 * "idempotencyKey": "0eb76578-8928-418e-8428-4a330d24186c"
41 * },
42 * {
43 * "id": "78a5c76e-fe47-4103-bfda-15e05c2ab003",
44 * "accountId": "b04a7524-f0cc-435a-981a-b765f758438b",
45 * "contactId": "8b4ff9ff-2f9a-41de-901d-9f6ecdb91664",
46 * "amount": 50,
47 * "type": "EARN",
48 * "description": "Shared post on social",
49 * "createdDate": "2022-06-19T22:09:23.434Z",
50 * "appId": "553c79f3-5625-4f38-b14b-ef7c0d1e87df",
51 * "idempotencyKey": "5a036e48-4188-4200-a42e-de37c273c3c1"
52 * }
53 * ],
54 * "pagingMetadata": {
55 * "count": 3,
56 * "cursors": {},
57 * "hasNext": false
58 * }
59 * }
60 */
61