the my points API is intended solely for frontend use on a customer's session. This allows you to process the following data:
GET: /wp-json/loyalty-program/v1/mypoints
Fetch all sections of LPFW settings.
Requirements:
role is allowed to earn points
Get current logged in user's points balance
GET: http://example.com/wp-json/loyalty-program/v1/mypoints
Status: 200 OK
Get current logged in user's points balance
{
"points": 361,
"worth": "$36.10",
"expiry": "April 7, 2022 11:59 am"
}
Status: 403 Forbidden
{
"code": "rest_forbidden_context",
"message": "Sorry, you are not allowed access to this endpoint.",
"data": {
"status": 401
}
}
GET: /wp-json/loyalty-program/v1/mypoints/coupons
Fetch all sections of LPFW settings.
Requirements:
role is allowed to earn points
Get customer's most recent redeemed coupons (10 entries)
GET: http://example.com/wp-json/loyalty-program/v1/mypoints/coupons
Get next page of redeemed coupon entries
GET: http://example.com/wp-json/loyalty-program/v1/mypoints/coupons?page=2
Status: 200 OK
Get customer's most recent redeemed coupons (10 entries) / Get next page of redeemed coupon entries
Headers:
{
...
X-TOTAL: 15
}
JSON Body:
[
...
{
"id": 314,
"code": "1mpwzrp",
"amount": "$10.00",
"date_created": "April 7, 2021 11:59 am",
"date_expire": "April 2, 2022 12:00 am",
"points": 100
}
...
]
Status: 403 Forbidden
{
"code": "rest_forbidden_context",
"message": "Sorry, you are not allowed access to this endpoint.",
"data": {
"status": 401
}
}
GET: /wp-json/loyalty-program/v1/mypoints/history
Get customer's points history data.
Requirements:
role is allowed to earn points
Get logged in user's most recent points history (10 entries)
GET: http://example.com/wp-json/loyalty-program/v1/mypoints/history
Get next page of history entries
GET: http://example.com/wp-json/loyalty-program/v1/mypoints/history?page=2
Status: 200 OK
Headers:
{
...
X-TOTAL: 25
}
JSON Body:
[
...
{
"id": 116,
"action": "coupon",
"date": "04/07/2021 11:59:22",
"activity": "Redeem Coupon",
"points": 100,
"rel_link": "http://acfw.test/coupon/1mpwzrp/",
"rel_label": "Coupon: 1mpwzrp"
}
...
]
Status: 403 Forbidden
{
"code": "rest_forbidden_context",
"message": "Sorry, you are not allowed access to this endpoint.",
"data": {
"status": 401
}
}
POST: /wp-json/loyalty-program/v1/mypoints/redeem
Redeem points and create a coupon.
Requirements:
role is allowed to earn points
Redeem 50 points
POST: http://example.com/wp-json/loyalty-program/v1/mypoints/redeem
JSON Body:
{
"points": 50
}
Status: 200 OK
Redeem 50 points
{
"user_coupon": {
"id": 315,
"code": "1l6ywrm",
"amount": "$5.00",
"date_created": "April 7, 2021 1:57 pm",
"date_expire": "April 7, 2022 1:57 pm",
"link": "http://acfw.test/coupon/1l6ywrm/",
"points": 50
},
"balance": {
"points": 311,
"worth": "$31.10",
"expiry": "April 7, 2022 1:57 pm"
},
"message": "Points redeemed successfully!"
}
Status: 403 Forbidden
{
"code": "rest_forbidden_context",
"message": "Sorry, you are not allowed access to this endpoint.",
"data": {
"status": 401
}
}