# GIft Card Id as source\_id for Payment fails in Sandbox

**URL:** <https://developer.squareup.com/forums/t/gift-card-id-as-source-id-for-payment-fails-in-sandbox/3169>\
**Category:** Questions\
**Tags:** payments-api, sandbox, gift-cards-api\
**Created:** [August 6, 2021, 6:27pm UTC](https://developer.squareup.com/forums/t/gift-card-id-as-source-id-for-payment-fails-in-sandbox/3169 "2021-08-06T18:27:43Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![JM0ney](https://sea1.discourse-cdn.com/square/forums/user_avatar/developer.squareup.com/jm0ney/32/666_2.png) [@JM0ney](https://developer.squareup.com/forums/u/JM0ney)\
**Post date:** [August 6, 2021, 6:27pm UTC](https://developer.squareup.com/forums/t/gift-card-id-as-source-id-for-payment-fails-in-sandbox/3169/1 "2021-08-06T18:27:44Z")

</div>

I’m having difficulty paying for an order using the gift card’s Id as the source\_id for a Payment in the Sandbox environment. I am attempting to use the PaymentsApi to create the Payments in question.

I have tried 2 different approaches.

**Approach 1**  
Creating and activating my own gift card. I am able to retrieve the gift card using the RetrieveGiftCardFromGAN end point in the GiftCardsApi. I have verified that it is Active and has a balance. However, when using that gift card’s Id as a payment source for a different Order, I get the following error from Square:

_Category: PAYMENT\_METHOD\_ERROR_  
_Code: INVALID\_CARD_  
_Detail: Invalid card number._

**Order Details for Creating and Activating Gift Card**

> OrderId: wJG45GoV5AxSgkomWiqgIYgrnZ4F  
> LineItem UId: rY24lmjoawYs1r3j11wPPD  
> GAN: 7783320005727177  
> Gift Card Id: gftc:0647a1bb3aa74182b7cf3230ae57a273

**Order Details for Separate Order - Paying using above Gift Card**

> OrderId: w9ilBx9nfbNB2thNAHY1Rd72Ca4F  
> Gift Card Id: gftc:0647a1bb3aa74182b7cf3230ae57a273

**Does anyone have an idea why would I not be able to use that as a payment source?**

**Approach 2**  
When I attempt to retrieve the test gift card [found here](https://developer.squareup.com/docs/testing/test-values#web-and-mobile-client-testing) using the RetrieveGiftCardFromGAN end point, so I could attempt to pay using that gift card’s Id, I get a different error:

_Category: INVALID\_REQUEST\_ERROR_  
_Code: NOT\_FOUND_  
_Detail: No gift card found with that GAN._

We’re trying to allow our customers to use gift cards to pay for current and future orders, but I cannot seem to get anything but a single use nonce to work with gift cards.

Where am I going wrong?

---

<div class="post-metadata">

**Author:** ![Max-Square](https://avatars.discourse-cdn.com/v4/letter/m/c89c15/32.png) [@Max-Square](https://developer.squareup.com/forums/u/Max-Square)\
**Post date:** [August 6, 2021, 9:31pm UTC](https://developer.squareup.com/forums/t/gift-card-id-as-source-id-for-payment-fails-in-sandbox/3169/2 "2021-08-06T21:31:28Z")

</div>

Hi Jason, thanks for reaching out!

I was able to reproduce this issue, and believe it is a limitation of the current sandbox environment (for which Gift Cards API is in Beta). When using the Payments API in Sandbox, it accepts a very limited number of payment nonces for `source_id` that each have hard-coded responses. For your Approach #2, there is not an actual gift card in the Sandbox with that GAN, it is just a series of numbers that will produce a valid ‘gift card’ payment nonce when entered on a payment form.

For your Approach #1, the process you have described will work if done in the Production environment. Gift Card functionality is actually one of the easier things to test in Production with no consequences, as you can easily activate a Gift Card specifying the `amount_money` and with a `buyer_payment_instrument_ids: 'cash'` to load balances without having to complete a real transaction.

I would recommend retrying your process in Production and seeing if you are still having issues. I will check with our teams to see if the inability to create specific gift cards and then charge them in Sandbox was by design or is an oversight/bug.

---

<div class="post-metadata">

**Author:** ![JM0ney](https://sea1.discourse-cdn.com/square/forums/user_avatar/developer.squareup.com/jm0ney/32/666_2.png) [@JM0ney](https://developer.squareup.com/forums/u/JM0ney)\
**Post date:** [August 6, 2021, 9:37pm UTC](https://developer.squareup.com/forums/t/gift-card-id-as-source-id-for-payment-fails-in-sandbox/3169/3 "2021-08-06T21:37:53Z")

</div>

@Max-Square thanks for the reply. I look forward to hearing the response RE inability to create gift cards, then charge them in the sandbox.

---

<div class="post-metadata">

**Author:** ![Max-Square](https://avatars.discourse-cdn.com/v4/letter/m/c89c15/32.png) [@Max-Square](https://developer.squareup.com/forums/u/Max-Square)\
**Post date:** [August 6, 2021, 11:45pm UTC](https://developer.squareup.com/forums/t/gift-card-id-as-source-id-for-payment-fails-in-sandbox/3169/4 "2021-08-06T23:45:50Z")

</div>

Hi Jason, I received confirmation that the only gift card source\_id that works for the Sandbox Payments API is the test token `cnon:gift-card-nonce-ok`, and this is by design. I do think there could be value in changing this so that the full gift card feature set can be explored in a test environment. I will submit a feature request to our teams!

---

<div class="post-metadata">

**Author:** ![JM0ney](https://sea1.discourse-cdn.com/square/forums/user_avatar/developer.squareup.com/jm0ney/32/666_2.png) [@JM0ney](https://developer.squareup.com/forums/u/JM0ney)\
**Post date:** [August 7, 2021, 12:11am UTC](https://developer.squareup.com/forums/t/gift-card-id-as-source-id-for-payment-fails-in-sandbox/3169/5 "2021-08-07T00:11:16Z")

</div>

Thanks @Max-Square I appreciate it.

For what it’s worth, nuances like this might be worth including in documentation as well, as I’ve been pulling my hair out trying to figure out why gift card api calls haven’t been working.
