> ## Documentation Index
> Fetch the complete documentation index at: https://pro-docs.bglobale.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Loyalty Points

## Overview

Global‑e cartridges support using Loyalty Points cards on the Checkout page.

The cartridges contain the required functionality and implementation, using SFCC custom objects.

## Using Loyalty Points Cards

* For registered User who have Loyalty Point Cards in the ‘SendCart’ request is sent info about Loyalty Points can be used and earned on the Global-e checkout.

  Merchant’s development team should override ‘loyaltyPoints.js' by path: `./cartridge/models/globale/sendCart/decorators/loyaltyPoints.js`

  The following information should be sent by `SendCart`:

  * **LoyaltyCreditPointsEarned** - Loyalty points to be earned from the purchase.
  * **LoyaltyPointOriginalValueForSpend** - Loyalty points in conversion to money. Amount denoted in the currency code of `LoyaltyPointOriginalCurrencyForSpend` attribute.
  * **LoyaltyPointOriginalCurrencyForSpend** - Currency code.
  * **LoyaltyCreditCode** - ID of Loyalty Card.

  <Frame>
    <img src="https://mintcdn.com/globale-pro/b-PlqzQu3R4_02Jo/images/uuid-42aea76e-59a4-2352-244c-083a4db374d8.png?fit=max&auto=format&n=b-PlqzQu3R4_02Jo&q=85&s=bac20b349a8505fc23f1d712f6bb98d4" width="1322" height="602" data-path="images/uuid-42aea76e-59a4-2352-244c-083a4db374d8.png" />
  </Frame>
* Loyalty Points can be used, by entering the amount on the Global-e Checkout page, and pressing the ‘redeem’ button.

  <Frame>
    <img src="https://mintcdn.com/globale-pro/ujP0qFJXfw3cnuWM/images/uuid-858f1a08-e58b-404d-2015-9c18778490de.png?fit=max&auto=format&n=ujP0qFJXfw3cnuWM&q=85&s=1d3dfda3d6cccbee670fd2bfcd3f6968" width="585" height="327" data-path="images/uuid-858f1a08-e58b-404d-2015-9c18778490de.png" />
  </Frame>
* Validate: Loyalty points are validated on the Global-e side, according to data sent in the `SendCart` request.
* If the amount of loyalty points entered is not valid, an error message is displayed.

  <Frame>
    <img src="https://mintcdn.com/globale-pro/XlQTHMO1JRS1wjIN/images/uuid-ba6c4f23-8201-8039-10b1-0921a1881a85.png?fit=max&auto=format&n=XlQTHMO1JRS1wjIN&q=85&s=14c6f7f880fd65809befa13fc751e650" width="583" height="337" data-path="images/uuid-ba6c4f23-8201-8039-10b1-0921a1881a85.png" />
  </Frame>
* If the amount of loyalty points is valid – the loyalty points are converted to the Checkout currency and the User is notified of the successful operation. The Totals section displays the amount compensated from the Loyalty Points Card.

  <Frame>
    <img src="https://mintcdn.com/globale-pro/y93-IIIj3CQONbcg/images/uuid-f3b53c85-c823-9ad8-cdea-5dcfaf7356bf.png?fit=max&auto=format&n=y93-IIIj3CQONbcg&q=85&s=268ecbd4ea4ceb297a9964b25ea817b7" width="878" height="759" data-path="images/uuid-f3b53c85-c823-9ad8-cdea-5dcfaf7356bf.png" />
  </Frame>
* If the amount of the entered points covers the entire order's amount – the User can create an order without any additional payments.
* If the amount of the entered points covers only part of the order's total amount - the User should select a payment method to pay the rest.

**Redeem API call**

* After a User clicks on ‘PAY AND PLACE ORDER' and successful validation on the Global-e side - from the Global-e to SFCC is sent 'Redeem’ request.
* When an order is created on the Global-e side (and before creation on the SFCC side) - Global-e sends a “Redeem” request to the SFCC.

  Note: At that point, the order is created only on the Global-e side.
* The request’s payload is parsed and on the SFCC or external system(Givex, etc.) side is handle 'redeem' operation for the card.
* A response is sent from SFCC to Global-e.
* If the 'Redeem' operation for the card was not successful, and error message displayed and the order is not created on the SFCC side.
* If the 'Redeem' operation for the card was successful, a confirmation opens and the order is created on the SFCC side.

**Refund API call**

A Refund request is sent from Global-e to SFCC if a ‘refund' case is created on the Global-e side. For example: if the order is set to ‘Cancelled' on the Global-e side.

**Used ’Loyalty Cards’ details**

Information on used cards is added to the APIs of ‘Send Order To Merchant' and 'Payment Notification’ API requests.

## Required customization

Demo implementation in Global-e cartridges was done based on SFCC custom objects with type 'DEMO\_GLOBALE\_LOYALTY\_CARDS'.

The project’s development team should override demo implementation and add a ‘Loyalty Card' provider depending on the project’s needs.

Should be overridden:

* **Loyalty Card Provider** by path: `./scripts/globale/alternativePayments/providers/LoyaltyCardProvider.js`
* **Loyalty Points decorator** file by path:`./models/globale/sendCart/decorators/loyaltyPoints.js`

### Summary

The demo implementation (that is based on using SFCC custom objects.) was made with a simple structure as a test example which allows understanding of main things which can be used in the scope of the 'Loyalty Points Cards’ feature.
