Glue API: Manage gift cards of registered users
Edit on GitHubGift 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.
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:
- Add a Gift Card to a guest shopping cart. See Adding Items to Carts of Registered Users for more details.
- Submit the checkout data.
- Complete the checkout.
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. |
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"
}
}
]
}
General cart information
RESOURCE | ATTRIBUTE | TYPE | DESCRIPTION |
---|---|---|---|
carts | currency | String | Currency that was selected when the cart was created. |
carts | isDefault | Boolean | Specifies whether the cart is the default one for the customer. The field is available in multi-cart environments only. |
carts | name | String | Specifies a cart name. The field is available in multi-cart environments only. |
carts | priceMode | String | Price mode that was active when the cart was created. |
carts | store | String | Store for which the cart was created. |
Discount information
RESOURCE | ATTRIBUTE | TYPE | DESCRIPTION |
---|---|---|---|
carts | displayName | String | Discount name. |
carts | amount | Integer | Discount amount applied to the cart. |
carts | code | String | Discount code applied to the cart. |
Totals
RESOURCE | ATTRIBUTE | TYPE | DESCRIPTION |
---|---|---|---|
carts | expenseTotal | String | Total amount of expenses (including, e.g., shipping costs). |
carts | discountTotal | Integer | Total amount of discounts applied to the cart. |
carts | taxTotal | Integer | Total amount of taxes to be paid. |
carts | subTotal | Integer | Subtotal of the cart. |
carts | grandTotal | Integer | Grand total of the cart. |
carts | priceToPay | Integer | Total price of the cart to pay after discounts. |
carts | selectedProductOptions | array | List of attributes describing the product options that were added to cart with the product. |
Thresholds
RESOURCE | ATTRIBUTE | TYPE | DESCRIPTION |
---|---|---|---|
carts | threshold | Array | Thresholds applied. |
carts | type | String | Threshold type. |
carts | threshold | Integer | Threshold monetary amount. |
carts | fee | Integer | Fee to be paid if the threshold is not reached. |
carts | deltaWithSubtotal | Integer | Displays the remaining amount that needs to be added to pass the threshold. |
carts | message | String | Message shown to the customer if the threshold is not fulfilled. |
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. |
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.
Thank you!
For submitting the form