> ## Documentation Index
> Fetch the complete documentation index at: https://docs.slm.m1amdocs.com/llms.txt
> Use this file to discover all available pages before exploring further.

# AutoBill.redeemGiftCard

The `redeemGiftCard` method redeems a gift card represented by the input `GiftCard` object, and grants the resultant amount of credit to the `AutoBill`. This method should be called after the `statusInquiry()` method is called on the `GiftCard` object provided as input to this method. If the `statusInquiry()` method indicates that status of the `GiftCard` object is `Active`, you may call this method. For more information, see [The GiftCard Object](The_GiftCard_Object).

For redemption of a gift card, Subscribe contacts a gift card processor (where supported). If the gift card is redeemable, the processor returns an SKU or a UPC number. This number is unique for each type of gift card, and is defined by a prior agreement between you and the gift card processor. Subscribe uses the number to look up a `Product` object with the same `merchantProductId`. Subscribe then grants credit to the `AutoBill` as defined in the `creditGranted` attribute of the `Product` object. For each type of gift card you wish to accept, create (in advance) `Product` objects with the selected amount of credit specified in their `creditGranted` attributes.

Subscribe currently supports only full redemption of the credit associated with a gift card.

See the [Credit Subobject](Credit_Subobject) for more information on it and related subobjects. See Credit Grants and Gift Cards in the Subscribe Programming Guide, for more information on gift card redemption.

## Input

*srd*: sparse response description, a SOAP string (which must be a JSON object), in which you specify the elements you want returned.This parameter enables the calling system to constrain a `method` call to return only components you specify. This gives you greater control over returned content, and improves response time within the Vindicia platform by reducing the processing needed for the call.

Some fields are required, either practically or in the WSDL, and will be returned regardless of the *srd*. A null *srd* returns the complete response.

*autobill*: an `AutoBill` object to which you wish to grant credit, if redemption of the gift card is successful. Use the or `VID` to identify the object.

*giftcard*: a `GiftCard` object encapsulating information about the gift card you wish to redeem. For more information, see [The GiftCard Object](The_GiftCard_Object). If you called the `statusInquiry()` method before calling this method, you should have the `VID` of the `GiftCard` object. Use the `VID` to identify the `GiftCard`.

*credit*: a `Credit` object specifying the amount and type of credit you wish to redeem. (This parameter is used with partial credit redemption, and is currently not in use.)

## Output

*return*: an object of type `Return` that indicates the success or failure of the call.

*giftcard*: the `GiftCard` that was redeemed, with an updated `status`.

*autobill*: the `AutoBill` input object to which Subscribe grants credit if redemption of the input gift card is successful. This object contains the updated array of `Credit` objects.

## Returns

In addition to those listed in [The Return Object](The_Return_Object), this call returns:

| Return Code | Return String |
| - | - |
| `400` | One of the following: - `AutoBill not found.` - `Failed to translate gift card *error-description*.` - `Failed to redeem gift card *error-description*.` - `Failed to retrieve gift card after redemption attempt.` - `Failed to save AutoBill after gift card redemption attempt.` - `Failed to reload AutoBill after gift card redemption attempt *error-description*.` - `Redemption attempt failed for Gift Card ID *gift-card-details*.` |

## Example

```

$abill = new AutoBill();
// autobill id for an existing subscription to which the customer
// wishes to redeem a gift card and add credit to the autobill
$abill->set('SBCR312345');
$gc = new GiftCard(); 
   // set the VID of the gift card, obtained when we checked the 
   // status of the gift card and determined that it was active
$gc->setVID($gcVID); 
// Now make the SOAP API call to redeem the gift card
$response = $abill->redeemGiftCard($gc);
if ($response['returnCode'] == 200) {
   // Redemption successful. Check if credit was added to the autobill
   $updatedABill = $response['data']->autobill;
   $availableCredits = $updatedABill->getCredit();
   $availableTokens = $availableCredits->getTokenAmounts();
   print "Available token credits: \n";
   foreach($availableTokens as $tkAmt) {
      print "Token type: " . $tkAmt->getMerchantTokenId() . " ";
      print "Amount: " . $tkAmt->getAmount() . "\n";
   }
   // Also make sure status of the gift card is 'Redeemed'
   $updatedGc = $response['data']->giftcard;
   print "Status of the gift card: ";
   print $updatedGc->getStatus()->getStatus() . "\n";
}
else {
   // Error while granting credit to the account
   print $response['returnString'] . "\n";
}
```

**Parent topic:**[AutoBill Methods](../topics/AutoBill_Methods)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.