listTransactions( )
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.
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
Loyalty account ID.
Options to use when retrieving a list of loyalty transactions.
Returns
Return Type:
NAME
TYPE
DESCRIPTION
Details on the paged set of results returned.
Retrieved transactions.
Was this helpful?
1import { accounts } from 'wix-loyalty.v2';23// Sample accountId value: 'b04a7524-f0cc-435a-981a-b765f758438b'45export async function myListTransactionsFunction() {6 try {7 const transactionsList = await accounts.listTransactions(accountId);89 const firstId = transactionsList.transactions[0]._id;10 const firstStatus = transactionsList.transactions[0].type;1112 console.log('The most recent transaction ID is: ', firstId);13 return transactionsList;14 } catch (error) {15 console.error(error);16 }17}1819/* 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": false58 * }59 * }60 */61
1import { Permissions, webMethod } from 'wix-web-module';2import { accounts } from 'wix-loyalty.v2';34// Sample accountId value: 'b04a7524-f0cc-435a-981a-b765f758438b'56export const myListTransactionsFunction = webMethod(Permissions.Anyone, async () => {7 try {8 const transactionsList = await accounts.listTransactions(accountId);910 const firstId = transactionsList.transactions[0]._id;11 const firstStatus = transactionsList.transactions[0].type;1213 console.log('The most recent transaction ID is: ', firstId);14 return transactionsList;15 } catch (error) {16 console.error(error);17 }18});1920/* Promise resolves to:21 * {22 * "transactions": [{23 * "id": "03992fc4-8e8c-4406-8d3c-0292ed3be5d8",24 * "accountId": "b04a7524-f0cc-435a-981a-b765f758438b",25 * "contactId": "8b4ff9ff-2f9a-41de-901d-9f6ecdb91664",26 * "amount": 150,27 * "type": "ADJUST",28 * "description": "Signed up as site member.",29 * "createdDate": "2022-05-23T22:50:49.366Z",30 * "appId": "553c79f3-5625-4f38-b14b-ef7c0d1e87df"31 * },32 * {33 * "id": "70f0711b-e16f-44d7-ad03-4301c78d8623",34 * "accountId": "b04a7524-f0cc-435a-981a-b765f758438b",35 * "contactId": "8b4ff9ff-2f9a-41de-901d-9f6ecdb91664",36 * "amount": 50,37 * "type": "EARN",38 * "description": "Shared post on social",39 * "createdDate": "2022-05-24T09:11:51.274Z",40 * "appId": "553c79f3-5625-4f38-b14b-ef7c0d1e87df",41 * "idempotencyKey": "0eb76578-8928-418e-8428-4a330d24186c"42 * },43 * {44 * "id": "78a5c76e-fe47-4103-bfda-15e05c2ab003",45 * "accountId": "b04a7524-f0cc-435a-981a-b765f758438b",46 * "contactId": "8b4ff9ff-2f9a-41de-901d-9f6ecdb91664",47 * "amount": 50,48 * "type": "EARN",49 * "description": "Shared post on social",50 * "createdDate": "2022-06-19T22:09:23.434Z",51 * "appId": "553c79f3-5625-4f38-b14b-ef7c0d1e87df",52 * "idempotencyKey": "5a036e48-4188-4200-a42e-de37c273c3c1"53 * }54 * ],55 * "pagingMetadata": {56 * "count": 3,57 * "cursors": {},58 * "hasNext": false59 * }60 * }61 */62