Need advice on how to implement multi payments with gift card and credit card

Hi Team,

Need advice on how to implement multi payments with gift card and credit card.

I want to first charge the gift card with order money, and then charge the credit card if the gift card balance cannot fully cover the order money.

Currently I met an issue that if I try to create gift card payment with an amount of money that greater than gift card balance, API will return insufficient fund error.

I understand the error was throw on purpose, but I cannot find a way to check the gift card balance at first.

You’ll need to utilize the accept_partial_authorization parameter in the CreatePayment call: https://developer.squareup.com/reference/square/payments-api/create-payment#request__property-accept_partial_authorization. If you set it to true, then you can charge a Square Gift Card, and it doesn’t need to cover the full amount. For more information take a look at the Partial amount with Square Gift Cards documentation.

Hi @sjosey

Yes, I did add accept_partial_authorization: true in request and insufficient error happened, here is my API call

import SquareConnect from 'square-connect';

// set square access token...

const paymentApi = new SquareConnect.PaymentsApi();

paymentApi.createPayment({
      source_id: 'cnon:gift-card-nonce-insufficient-funds',
      order_id: 'xxx',
      location_id: 'xxx',
      idempotency_key: 'xxx',
      autocomplete: false,
      delay_duration: 'PT1H',
      accept_partial_authorization: true,
      amount_money: {
          amount: 524,
          currency: 'USD',
      },
})

Guess I cannot use the testing gift card nonce mentioned in this page and api will return approved payment in production?

Hm, probably correct. I imagine that test value will automatically make it fail no matter what, since that’s what it was designed to do. I think you’ll need to actually create a gift card to see this in prod.