Error back from CreateGiftCardActivityRequest

I am trying to activate a gift card in sandbox after order is created.

First off, is activating gift cards in sandbox even possible? I really don’t want to switch over to production to test…

I have an order ID and line item uid from the order and am calling everything exactly as the api explorer has it as well. I get the same response from the api explorer. I’m using the php sdk but here is the curl call with some things scrubbed out for security

curl \
  -X POST \
  -H 'Square-Version: 2022-10-19' \
  -H 'Authorization: Bearer xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' \
  -H 'Content-Type: application/json' \
  -d '{
    "gift_card_activity": {
      "type": "ACTIVATE",
      "activate_activity_details": {
        "amount_money": {
          "currency": "USD",
          "amount": 1000
        "order_id": "xNF3nHJ58QTYPqEsY5i17FRw8gYZY",
        "line_item_uid": "GJxjlfcjN83MWujDM1vg1C"
      "location_id": "<xxxxxxxxxxx>",
      "gift_card_gan": "7783320006361414"
    "idempotency_key": "778a5ec9-d61f-4def-84f2-b1457ae9ef97"

I’m getting back this error from the call:

400 Response

cache-control: no-cache
content-length: 178
content-type: application/json
date: Mon, 14 Nov 2022 22:41:58 GMT
square-version: 2022-10-19

  "errors": [
      "code": "BAD_REQUEST",
      "detail": "Provide either order_id and line_item_uid OR provide amount and buyer_payment_instrument_id",
      "category": "INVALID_REQUEST_ERROR"

If you remove either the order_id or the line_item_uid does it work? :slightly_smiling_face:

just tried without each of them one at a time and it still gave the same error. The error response seems to indicate that both are needed if not using a buyer_payment_instrument_id

I just tested your exact request and it worked as expected. Is the order and the gift card being created by the same application? :slightly_smiling_face:

Yes, the plugin that am using for square stores the “create order” response data so I get the order ID and line item uid from that and then I create the gift card in square via api and then am attempting to activate it - all within the same flow.

Could it be an issue if the line item in the order is listed as ITEM instead of GIFT_CARD ?

Hmm, is you create the order and then the activity with the same app does it work? The line item will need to be type GIFT_CARD. I ran into that when I tested but there’s a very clear error message for that. :slightly_smiling_face:

Yep, I’ll have to deal with the line item not being GIFT_CARD from the plugin that syncs the order data and then I also realized that the wording of the original error message indicates that if you use an order id and line item uid then you don’t need to include the amount since it’s already in the order line item.

Thanks for the assistance.