How to test gift card scenarios in sandbox

From reading the forum on here, Square is a bit limited in what it can do with test gift cards in the sandbox.

I can create test gift cards via the API and charge against them in the sandbox just fine.

However, it looks like when using the sandbox WebPaymentsSDK, I can only use the test gift card number “7783 3200 0000 0000”.

I need to be able to test the scenarios as to where there are insufficient funds and only a partial payment. Is the following the only workaround possible?

  1. Enter “7783 3200 0000 0000” into the Gift Card Input box on the webpage
  2. Have Javascript send the token to the backend
  3. Have the backend ignore the token, but swap in a (previously created) hardcoded gift card ID that was created in the sandbox and load it
  4. Continue on based on the status of the gift card

With gift cards and partial payments you’ll use the Payments API autocomplete and set that to false. Also you’ll set accept_partial_authorization to true. This will allow you to accept whatever remaining balance is on the card and allow you to create another payment for the remaining amount. Here’s the link to the walkthrough of Partial Payments with Gift Cards. :slightly_smiling_face:

Thanks. I have it working, but I want to be able to have my client be able to just enter in test gift cards that have insufficent/full/no balance so they can see how the UI behaves based upon the status of the gift card (eg, if a customer pays with a gift card, I need to first check the balance and then display the Square Credit Card input box also, or not show it at all if the balance is sufficient).

As a workaround, I have a dropdown on the page that has a list of test gift cards in it plus their balance, on the backend instead of using the GiftCardToken, I’m just swapping in the gift card ID that my test dropdown is sending. It’s a hack but at least the client can test things.

It would just be more helpful if you could use actual test gift card GANs in the WebPaymentsSDK box for giftcards.

You can avoid checking the balance all together since you have accept_partial_authorization set to true. The amount authorized for the gift card payment will either cover the entire sale or it will tell you how much if any was authorized. The difference is the amount still owed to cover the order. :slightly_smiling_face:

Yeah, that is what I was more or less saying in a badly worded way, heh. Just hit the gift card first and if it doesn’t cover it at all, show the remaining balance and ask for a credit card.

Oh, from my understanding, I only should put a 1 - 2 minute authorization on the Gift Card and then have it cancel the authorization? Eg, like if the customer makes a mistake and has to redo the order again (or one of the 852 other APIs I have to deal without outside of Square fails), I want them to be able to reuse the gift card again.

If they abandon the payment page altogether I’d say at that point it’s a good sign to call CancelPayment for the gift card. Unless they went back to shopping on the site. :slightly_smiling_face: