This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.
Retrieves a transaction.
This function requires elevated permissions and runs only on the backend and on dashboard pages.
function getLoyaltyTransaction(
loyaltyTransactionId: string,
): Promise<LoyaltyTransaction>;
ID of the loyalty transaction to be retrieved.
import { transactions } from "wix-loyalty.v2";
import { webMethod, Permissions } from "wix-web-module";
import { elevate } from "wix-auth";
/* Sample loyaltyTransactionId value:
*
* {
* "loyaltyTransactionId": "32ec5722-8727-475b-b499-3fe78af3ee99"
* }
*/
const elevatedGetLoyaltyTransaction = elevate(
transactions.getLoyaltyTransaction,
);
export const getLoyaltyTransaction = webMethod(
Permissions.Anyone,
async (loyaltyTransactionId) => {
try {
const result = await elevatedGetLoyaltyTransaction(loyaltyTransactionId);
return result;
} catch (error) {
console.error(error);
// Handle the error
}
},
);
/* Promise resolves to:
*
* {
* "_createdDate": "2024-06-06T13:18:13.233Z",
* "_id": "32ec5722-8727-475b-b499-3fe78af3ee99",
* "accountId": "d0dc5ba3-4a10-4cfc-b304-c976d8ac7303",
* "amount": 20,
* "description": "Refund",
* "idempotencyKey": "32ec5722-8727-475b-b499-3fe78af3ee99",
* "transactionType": "REFUND",
* "refundInfo": {
* "appId": "553c79f3-5625-4f38-b14b-ef7c0d1e87df"
* }
* }
*/
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.