Walkthrough 1: Sell a Gift Card
This walkthrough provides step-by-step instructions for you to create and activate a digital gift card.
To prepare for the walkthrough, do the following:
Review Sandbox testing considerations. You need to understand how to test the walkthrough in the Square Sandbox.
Gather account information. You need your Sandbox access token and location ID. You use the access token to authenticate requests and your location ID to create an order using the Orders API and create a gift card using the Gift Cards API.
The Sandbox provides test values that make testing in the Sandbox environment easy. For this exercise, you use a test payment token (
cnon:card-nonce-ok) to pay for an order. For more information, see Sandbox test values.
This walkthrough creates a digital gift card in the Sandbox. Although testing physical gift cards is not supported in Sandbox, you can register and activate physical gift cards in the production environment using the process described in this walkthrough.
Follow these steps to gather account information for your Sandbox environment:
Sign in to the Developer Dashboard.
Open an application, which provides you with the credentials you use. If you do not have an application, you need to create one.
Get Sandbox credentials:
You can toggle between the Sandbox and Production accounts. Choose Sandbox.
On the Credentials page, copy the token from Sandbox Access Token.
Get a location ID:
Choose Locations in the left navigation pane.
On the Locations page, choose an ID from Location ID.
You are now ready to sell a gift card. When a buyer wants to purchase a gift card, an application first takes an order and processes the payment (the amount to load on the gift card). The application then creates and activates a card.
Applications have the following options to process a gift card order:
Use the Square Orders API. For the example walkthrough, see Load a Gift Card Using the Orders API.
Use a custom client-side API. Instead of using the Orders API, you might choose to use your own custom client-side API to take a gift card order and process the payment. For the example walkthrough, see Load a Gift Card Without the Orders API.