The Toast platform sends requests to your gift card API implementation when it processes gift card transactions at restaurants that use your gift card provider service. Your implementation of the gift card API must return information about the results of your attempt to process the transaction.
The following sections provide more information about the gift card transaction workflow in a Toast platform gift card integration.
The Toast gift card API specification includes a single endpoint. The Toast platform sends information about all gift card transaction types to that endpoint. The information in the HTTP request indicates the type of transaction and provides details about it.
You can name the single endpoint of your gift card integration API
anything that you want. For example, the REST path in the URL for your
API might be https://my-host-name/v1/myTransactions
. You
define every part of that URL. During the integration process, the Toast
integrations team will configure the REST path to your endpoint in the
Toast platform.
The Toast platform indicates the type of each transaction request
by including a transaction type identifier in the
Toast-Transaction-Type
HTTP header parameter. For
information about gift card transaction type identifiers see Gift card transaction types.
The Toast platform includes a set of values that provide
information about the gift card transaction in the JSON
GiftCardTransaction
object in the message body parameter
for each request.
Your single endpoint must return a JSON
GiftCardTransactionResponse
object in the message body of
the HTTP response to each request. The
GiftCardTransactionResponse
object indicates the success or
failure of transaction processing and provides information about the
state of the gift card after the transaction is processed. The
transactionStatus
value of the
GiftCardTransactionResponse
object includes a status
identifier. For information about transactionStatus
values,
see Response status types.
Important |
Your gift card API implementation must use HTTPS for all REST requests and responses. |
Your gift card API implementation must use HTTPS for all REST requests and responses. HTTPS uses Transport Layer Security (TLS) to encrypt and secure communications between the API client and server.
The following table describes the transaction types that the Toast
platform sends to your gift card provider service. The Toast platform
includes the transaction type identifier in the
Toast-Transaction-Type
header parameter for each gift card
transaction API request.
Transaction type |
Description |
||
---|---|---|---|
|
Activates a new gift card. For
example, the Toast platform sends a
Optional
Your gift card implementation can either handle
requests with this transaction type or may return a
|
||
|
Increases the amount of money available on a gift card. For example, the Toast platform sends a GIFTCARD_ADD_VALUE request when it handles a gift card sale (initial balance) or when a restaurant guest purchases additional value to add to a gift card balance. Optional
Your gift card implementation can either handle
requests with this transaction type or may return a
|
||
|
Requests the amount of money that is available for purchases on a gift card. For example, the Toast
platform sends a
Required
Your gift card implementation must handle requests with this transaction type. |
||
|
Decreases the amount of money available on a gift card. For example, the Toast platform sends a
If the redeem request is for a cash-out
transaction, the Optional
Your gift card implementation can either handle
requests with this transaction type or may return a
|
||
|
Undoes a previous gift card transaction. For example, the Toast platform sends a
Required
Your gift card implementation must handle requests with this transaction type. |
All transaction types can support verification codes (also known as PINs). You may choose to support verification codes (PINs) for your Toast gift card API implementation. If you’d like to add this to your existing Toast gift card API implementation, reach out to developer-support@toasttab.com to inquire about adding Verification Code (PIN) support to your Toast API implementation scope.
If a user enters a verification code, the Toast platform sends it as part of any of the transactions listed below. The Toast platform also indicates if the card number is entered via swipe, manual entry (keyed), or scan (1D or 2D barcode). The provider must validate the verification code and use the corresponding response type. If a verification code is not entered but is required, the provider can choose to respond with “ERROR_VERIFICATION_REQUIRED” to indicate the user must resubmit using a verification code (PIN).
The following table describes the response status types that your
gift card provider service can send to the Toast platform. Your gift
card integration API implementation returns a transaction status
identifier in the transactionStatus
value of the
GiftCardTransactionResponse object.
Transaction status |
Description |
||
---|---|---|---|
|
The transaction was handled successfully. |
||
|
Your implementation does not handle the optional transaction type that was supplied in the request. Return this response status type when the request transaction type is one of the types defined by the gift card integration API specification but you have decided not to support it. |
||
|
The transaction type identifier supplied in the
Return this response status type when the request transaction type is not one of the types defined by the gift card integration API specification. |
||
|
The transaction attempted to activate a gift card that is already active. |
||
|
The gift card is not active.
|
||
|
The gift card identifier is not in the set of identifiers that correspond to the current restaurant. For example, if a gift card identifier is entered incorrectly or if the gift card identifier corresponds to a different restaurant location, your implementation returns this status. |
||
|
The values that the Toast platform supplied in the
|
||
|
The transaction specified by a
|
||
|
The authentication token supplied in the
|
||
|
The transaction specified by a
|
||
|
The restaurant identifier included in the
You receive the identifiers for Toast platform restaurants from the Toast integrations team when you implement your gift card integration. |
||
|
The verification code (PIN) data specified by the JSON body is invalid. |
||
|
Verification code (PIN) data is necessary to complete the transaction but the data is missing or `null` in the JSON body. |
||
|
Verification code (PIN) data is provided by the JSON body but the provider doesn't support verification code. |
The Toast platform may send multiple requests to your gift card integration API implementation when it processes a gift card transaction.
For example, when a restaurant employee sells a new gift card to a guest:
-
First, the Toast platform sends a balance inquiry request to verify that the new gift card is not already active and that it does not have an existing balance
-
Then the Toast platform sends an activate request to add value and make the card usable for transactions.
The following procedures describe the sequence of integration API requests that the Toast platform sends to a gift card integration API implementation to handle common gift card transaction types.
Note |
The sequence of requests is described here to show the way that the Toast platform combines request types for a transaction. The specific sequence of requests is determined by the internal implementation of the Toast platform software. Make sure that your integration API implementation does not rely on any specific sequence of requests. The specific sequence of requests will change without notice. |
Selling a new gift card, successful result
-
Toast platform sends a
GIFTCARD_GET_BALANCE
request for the new gift card. -
Gift card provider sends a
ERROR_CARD_NOT_ACTIVATED
transaction status in theGiftCardTransactionResponse
. -
Toast platform sends a
GIFTCARD_ACTIVATE
request for the new gift card. -
Gift card provider sends an
ACCEPT
transaction status in theGiftCardTransactionResponse
.
Selling a new gift card, failure
-
Toast platform sends a
GIFTCARD_GET_BALANCE
request for the new gift card. -
Gift card provider sends an
ACCEPT
transaction status and information about the card balance in theGiftCardTransactionResponse
. -
Toast platform reports that the gift card is already active to restaurant employee and takes no further action.
Adding value to a gift card, successful result
-
Toast platform sends a
GIFTCARD_GET_BALANCE
request for the new gift card. -
Gift card provider sends an
ACCEPT
transaction status and information about the card balance in theGiftCardTransactionResponse
. -
Toast platform sends a
GIFTCARD_ADD_VALUE
request for the new gift card. -
Gift card provider sends an
ACCEPT
transaction status in theGiftCardTransactionResponse
.
Adding value to a gift card, failure
-
Toast platform sends a
GIFTCARD_GET_BALANCE
request for the new gift card. -
Gift card provider sends an
ERROR_CARD_NOT_ACTIVATED
transaction status in theGiftCardTransactionResponse
. -
Toast platform reports that the gift card is not active to restaurant employee and takes no further action.
Restaurant locations that use the Toast gift card provider integration can give guests cash as a gift card redeem transaction when applicable regulations require cash-out transactions. For example, some gift-card regulations require that guests can withdraw all remaining funds available on a gift card when the balance is below a specific threshold. A cash-out redeem transaction deducts funds from the gift card account and the guest receives the funds directly in cash. A guest must cash out the entire available balance of a gift card account. A cash out transaction leaves the gift card account with a 0.00 currency balance and you should update the card's balance to zero in your system. See this article for more information about cash out transactions.
If a gift card redemption is a cash out, the
isCashOut
value on the transaction will be
true
. Otherwise, isCashOut
will be
false
.
Some restaurant locations are subject to regulations that require that guests be allowed to redeem gift card balances in cash.
Restaurant locations can enable or disable cash-out transactions for the gift card integration. Restaurant locations can set a maximum currency amount for cash-out transactions. If a gift card balance is greater than the cash-out transaction threshold, the Toast platform does not allow the cash-out redeem transaction.