Usage
MageSDK.getCustomerDetails().then(function(resp) {
if (resp.success) {
console.log(resp.data.customer);
console.log(resp.data.loyaltyMode); // 'points' | 'store_credit'
}
});
Response
boolean
Whether the request was successful.
string
The shop’s loyalty mode,
"points" or "store_credit". In store-credit mode every loyalty number below is in the currency’s minor units. See Loyalty modes.string
The shop’s ISO currency code, e.g.
"USD".object
The customer object.
Show Customer properties
Show Customer properties
string
Internal Mage customer ID.
string
The Shopify customer ID.
string
Customer email address.
string
Customer first name.
string
Customer last name.
number
Current available balance. Points in points mode, minor currency units in store-credit mode.
number
Total earned over the customer’s lifetime, in the same unit as
points.number
Total redeemed, in the same unit as
points.boolean
Whether the customer is excluded from the loyalty program.
string | null
Customer date of birth in ISO 8601 format.
string | null
The customer’s unique referral code.
string | null
The customer’s full referral URL that can be shared.
object | null
The customer’s current VIP tier, or
null if no tier is assigned. See getShopVipTiers for the tier shape.number
The customer’s progress value toward the next tier, measured by the shop’s primary entry method.
number | null
Progress toward the secondary tier-entry threshold, when the shop combines two entry methods.
null otherwise.array
List of the customer’s point earning events, newest first.
Show Earning entry properties
Show Earning entry properties
string
The earning record ID.
string
ID of the earning rule that produced this entry.
string
Status of the entry, e.g.
"APPROVED". Expired rows are surfaced as "EXPIRED".number
Amount earned, in the shop’s loyalty unit.
number
Amount later reversed (for example after an order refund).
string | null
The earning rule action, e.g.
"purchase", "birthday", "points_drop".string
A display name for the row.
string | null
Expiry timestamp. Set only for future-dated points drops,
null otherwise.object | null
The related earning rule,
{ id, name }, or null.array
Backwards-compatible alias of
customerEarningRule. New code should read customerEarningRule.array
List of earnings from referrals.
object | null
In store-credit mode, a ready-to-display view of the balance (
balanceMinor, balance, balanceFormatted, currency). null in points mode. See Loyalty modes.string
ISO 8601 timestamp of when the customer was enrolled.
string
ISO 8601 timestamp of the last update.
Sample response
{
"success": true,
"data": {
"loyaltyMode": "points",
"currency": "GBP",
"customer": {
"id": "abc123",
"shopifyCustomerId": "6789012345",
"email": "jane@example.com",
"firstName": "Jane",
"lastName": "Doe",
"points": 450,
"lifetimePoints": 1200,
"redeemedPoints": 750,
"isExcluded": false,
"dateOfBirth": "1990-05-15T00:00:00.000Z",
"referralCode": "ABC123",
"referralUrl": "https://mystore.com?referral_code=ABC123",
"tier": {
"id": "tier_abc",
"name": "Gold",
"description": "Our most valued customers",
"threshold": 500,
"thresholdPoints": 500,
"thresholdSpend": null,
"thresholdOrders": null,
"pointsMultiplier": 1.5,
"badgeImageUrl": null,
"badgeColor": "#FFD700"
},
"tierProgressValue": 1200,
"tierProgressValueExtra": null,
"customerEarningRule": [
{
"id": "cer_abc",
"earningRuleId": "rule_abc",
"status": "APPROVED",
"points": 150,
"refundedPoints": 0,
"action": "purchase",
"name": "Points for purchase",
"pointsExpiryAt": null,
"earningRule": {
"id": "rule_abc",
"name": "Points for purchase"
}
}
],
"referralEarnings": [],
"storeCredit": null,
"createdAt": "2024-01-15T10:00:00.000Z",
"updatedAt": "2024-06-20T14:30:00.000Z"
}
}
}