> ## Documentation Index
> Fetch the complete documentation index at: https://enterprise-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-enterprise/-95KX8vS1vYAnafZ/images/uuid-42aea76e-59a4-2352-244c-083a4db374d8.png?fit=max&auto=format&n=-95KX8vS1vYAnafZ&q=85&s=b6b4fc097298a7397814329aa93f1469" 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-enterprise/hjqDl82-X0YUzXdP/images/uuid-858f1a08-e58b-404d-2015-9c18778490de.png?fit=max&auto=format&n=hjqDl82-X0YUzXdP&q=85&s=46fd65424498c76547e0a779b7f53716" 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-enterprise/83nCB7AJobthQFqb/images/uuid-ba6c4f23-8201-8039-10b1-0921a1881a85.png?fit=max&auto=format&n=83nCB7AJobthQFqb&q=85&s=6e28a38bcc9303daa8f11bd2bff248ec" 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-enterprise/j_QcUA5HG17m29tL/images/uuid-f3b53c85-c823-9ad8-cdea-5dcfaf7356bf.png?fit=max&auto=format&n=j_QcUA5HG17m29tL&q=85&s=84844c2869886f2581b9fad3748a747f" 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.
