Managing Gift Cards of Guest Users
  • 04 Sep 2020
  • 3 Minutes To Read
  • Print
  • Share
  • Dark
    Light

Managing Gift Cards of Guest Users

  • Print
  • Share
  • Dark
    Light

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 non-authenticated users.

Info

To manage the gift cards of the registered users, see Gift Cards of the Registered 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 Guest Carts 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.

Redeeming the Gift Card Code in the Guest Cart

To redeem the gift card code, send the request:


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


Path Paremeter DESCRIPTION
guest_cart_uuid Unique identifier of the guest cart in the system. You can get it when retrieving the guest carts.

Request

HEADER KEY HEADER VALUE EXAMPLE REQUIRED DESCRIPTION
X-Anonymous-Customer-Unique-Id 164b-5708-8530 A hyphenated alphanumeric value that is the user's unique identifier.
Request sample

https://glue.mysprykershop.com/guest-carts/f8782b6c-848d-595e-b3f7-57374f1ff6d7/cart-codes?include=vouchers,gift-cards

{
    "data": {
        "type": "cart-codes",
        "attributes": {
            "code": "GC-Z9FYJRK3-20"
        }
    }
}
Attribute Type Required Description
code String Code of the gift card sent to the specified email address after the gift card was purchased.

Response

Response sample:

{
    "data": {
        "type": "guest-carts",
        "id": "f8782b6c-848d-595e-b3f7-57374f1ff6d7",
        "attributes": {
            "priceMode": "GROSS_MODE",
            "currency": "EUR",
            "store": "DE",
            "name": "Shopping cart",
            "isDefault": true,
            "totals": {
                "expenseTotal": 0,
                "discountTotal": 10689,
                "taxTotal": 15360,
                "subtotal": 106892,
                "grandTotal": 96203,
                "priceToPay": 93203
            },
            "discounts": [
                {
                    "displayName": "10% Discount for all orders above",
                    "amount": 10689,
                    "code": null
                }
            ]
        },
        "links": {
            "self": "https://glue.mysprykershop.com/guest-carts/f8782b6c-848d-595e-b3f7-57374f1ff6d7"
        },
        "relationships": {
            "gift-cards": {
                "data": [
                    {
                        "type": "gift-cards",
                        "id": "GC-Z9FYJRK3-20"
                    }
                ]
            }
        }
    },
    "included": [
        {
            "type": "gift-cards",
            "id": "GC-Z9FYJRK3-20",
            "attributes": {
                "code": "GC-Z9FYJRK3-20",
                "name": "Gift Card 30",
                "value": 3000,
                "currencyIsoCode": "EUR",
                "actualValue": 3000,
                "isActive": true
            },
            "links": {
                "self": "https://glue.mysprykershop.com/guest-carts/f8782b6c-848d-595e-b3f7-57374f1ff6d7/cart-codes/GC-Z9FYJRK3-20"
            }
        }
    ]
}

For the guest cart attributes, see Creating Guest Carts.

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.

Removing Gift Card Code

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


DELETE /guest-carts/{{guest_cart_uuid}}/cart-codes/{{gift_card_code}}


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

Request

HEADER KEY HEADER VALUE EXAMPLE REQUIRED DESCRIPTION
X-Anonymous-Customer-Unique-Id 164b-5708-8530 A hyphenated alphanumeric value that is the user's unique identifier.

Request sample: https://glue.mysprykershop.com/guest-carts/f8782b6c-848d-595e-b3f7-57374f1ff6d7/cart-codes/GC-Z9FYJRK3-20

Response

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

Was This Article Helpful?