Glue API: Manage gift cards of registered users

Edit on GitHub

Gift Card is an alternative payment method. It is purchased as a default product in the Spryker Commerce OS and is redeemed as a voucher code during the checkout. When you have a gift card code, this code can be applied to a shopping cart, and the money value of the applied gift card is deducted from the total sum of the cart items.

In your development, Gift Cards API provides resources for purchasing and redeeming gift cards in Spryker Commerce OS via Glue API.

This article includes a list of endpoints to manage Gift Cards for registered users.

Info

To manage the gift cards of the unregistered users, see Managing Gift Cards of Guest Users.

Installation

For detailed information on the modules that provide the API functionality and related installation instructions, see Gift Cards API Integration.

Purchasing a gift card

Gift Card is available in the Spryker shop as an abstract product with its variants (concrete products). To purchase the gift card:

  1. Add a Gift Card to a guest shopping cart. See Adding Items to Carts of Registered Users for more details.
  2. Submit the checkout data.
  3. Complete the checkout.
Note

To prevent fraud, the payment method invoice is not accepted if a cart contains a gift card.

After placing the order, you will receive the gift card code to the email address specified in the checkout. You can redeem this code to pay for the products.

Redeem the gift card code

To redeem the gift card code, send the request:


POST /carts/{{cart_uuid}}/cart-codes?include=vouchers,gift-cards


PATH PARAMETER DESCRIPTION
cart_uuid Unique identifier of a cart to remove products from. You can get this in the response when creating carts or retrieving all carts.
Authentication

To use this endpoint, customers need to authenticate. For details, see Authentication and Authorization.

Request

Request sample: redeem the gift card code

POST https://glue.mysprykershop.com/carts/8ef901fe-fe47-5569-9668-2db890dbee6d/cart-codes?include=vouchers,gift-cards

{
    "data": {
        "type": "cart-codes",
        "attributes": {
            "code": "GC-I6UB6O56-20"
        }
    }
}
ATTRIBUTE TYPE REQUIRED DESCRIPTION
code String

Response

Response sample: redeem the gift card code

{
    "data": {
        "type": "carts",
        "id": "8ef901fe-fe47-5569-9668-2db890dbee6d",
        "attributes": {
            "priceMode": "GROSS_MODE",
            "currency": "EUR",
            "store": "DE",
            "name": "Shopping cart",
            "isDefault": false,
            "totals": {
                "expenseTotal": 0,
                "discountTotal": 4200,
                "taxTotal": 6035,
                "subtotal": 42000,
                "grandTotal": 37800,
                "priceToPay": 17800
            },
            "discounts": [
                {
                    "displayName": "10% Discount for all orders above",
                    "amount": 4200,
                    "code": null
                }
            ],
            "thresholds": []
        },
        "links": {
            "self": "https://glue.mysprykershop.com/carts/8ef901fe-fe47-5569-9668-2db890dbee6d"
        },
        "relationships": {
            "gift-cards": {
                "data": [
                    {
                        "type": "gift-cards",
                        "id": "GC-I6UB6O56-20"
                    }
                ]
            }
        }
    },
    "included": [
        {
            "type": "gift-cards",
            "id": "GC-I6UB6O56-20",
            "attributes": {
                "code": "GC-I6UB6O56-20",
                "name": "Gift Card 200",
                "value": 20000,
                "currencyIsoCode": "EUR",
                "actualValue": 20000,
                "isActive": true
            },
            "links": {
                "self": "https://glue.mysprykershop.com/carts/8ef901fe-fe47-5569-9668-2db890dbee6d/cart-codes/GC-I6UB6O56-20"
            }
        }
    ]
}

For the attributes of the registered user’s carts, see Creating carts of registered users.

INCLUDED RESOURCE ATTRIBUTE TYPE DESCRIPTION
gift-cards code String Code of the gift card sent to the specified email address after the gift card was purchased.
gift-cards name String Name of the gift card.
gift-cards value Integer Amount applied to the card when the gift card code is redeemed.
gift-cards currencyIsoCode String Currency to which the code is applied.
gift-cards actualValue Integer Actual value of the gift card code.
gift-cards isActive Boolean Specifies whether the gift card code is redeemed or not.

Remove a gift card

To remove the gift card code from the cart, send the request:


DELETE /carts/{{cart_uuid}}/cart-codes/{{gift_card_code}}


PATH PARAMETER DESCRIPTION
cart_uuid Unique identifier of a cart to remove products from. You can get this in the response when creating carts or retrieving all carts.
gift_card_code Code that you have received after purchasing the gift card.
Authentication

To use this endpoint, customers need to authenticate. For details, see Authentication and Authorization.

Request

Request sample: remove a gift card

DELETE https://glue.mysprykershop.com/carts/8ef901fe-fe47-5569-9668-2db890dbee6d/cart-codes/GC-I6UB6O56-20

Response

If the item is deleted successfully, the endpoint will respond with a 204 No Content status code.

Possible errors

CODE REASON
001 Access token is incorrect.
002 Access token is missing.
003 Failed to log in the user.
003 Cart code is not found in cart.
3301 Cart or voucher with the specified ID is not found.
3302 Incorrect voucher code or the voucher cannot be applied.
3303 Cart code can’t be removed.

To view generic errors that originate from the Glue Application, see Reference information: GlueApplication errors.