credit attribute of the AutoBill object holds the array of Credit amount objects available to the AutoBill. Do not set this field directly by calling AutoBill.update. Instead, use AutoBill methods such as grantCredit() and revokeCredit() to alter credits available to the AutoBill, and provide an audit trail in the credit log. Currency-, time-, and token-based credits may be used with AutoBill objects. Subscribe manages credits available to an AutoBill object as follows:
- Subscribe draws currency- and token-based credits from the
AutoBillfor each periodic transaction it generates for theAutoBill. - If the
Accountassociated with theAutoBillalso has currency- or token-based credits available to it, when theAutoBillis billed,AutoBillcredits are redeemed beforeAccountcredits. - If an
AutoBillhas an associated time credit, Subscribe uses this credit before redeeming any token-based or currency credits. - Subscribe uses currency and token-based credit to process an
AutoBill’s periodic transaction only if both of the following are true:- The payment method specified on the
AutoBillis a currency or token-based payment method that specifies a type of applicable token. - The billing plan associated with the
AutoBillhas a price listed in terms of the same token type or currency.
- The payment method specified on the
- When Subscribe applies time-based credit to an
AutoBill, it adjusts the next billing date of theAutoBillaccordingly. For example, a 15-day credit will postpone anAutoBillobject’s next billing date by 15 days. Application of such a credit does not generate a transaction.
Granting Credit to an AutoBill
Some situations may require you to extend a customer’s subscription to your site. For example, if a technical problem at your site prevented a customer from accessing the site for two days, a customer service representative might decide to extend the customer’s subscription by two days, to guarantee customer satisfaction. The grantCredit() method of the AutoBill object allows you to add time credit to an AutoBill object to implement such an extension.
Use grantCredit to add time credit to an AutoBill:
Revoking Credit from an AutoBill
Some activities a customer performs at your site might revoke credit from an AutoBill object. For example, an online game company might offer subscriptions that are paid for by points a customer earns in the game. If the customer loses some points in the game, the company might deduct the same number of points from the customer’s subscription. (Note: Time-based credit granted to an AutoBill cannot be revoked.)
Use revokeCredit to revoke currency or Token-based credits from an AutoBill:
AutoBill, and the transaction fails due to insufficient credit.
Fetching AutoBill Credit Transactions
Subscribe stores token- and currency-based periodic transactions in the same way that it storesAutoBill paid for with currency payment methods. Fetch token-based transactions with API calls such as the Transaction object’s fetchByAutoBill() method. These transactions contain a Transaction item with sku attribute set to VIN_Credit, and price attribute set to a negative value equivalent to the amount of the transaction (signifying that Subscribe deducted the credit).
Fetching AutoBill Credit History
Subscribe maintains a log of credit-related events for each AutoBill object. This log tracks credit-related events such as credit granted, revoked, consumed, and earned due to a gift card redemption. Retrieve the audit log with the AutoBill object’s fetchCreditHistory() method. (Because the method includes paging and a time range, you may limit the number of records returned.)
fetchCreditHistory() returns an array of CreditEventLog objects. Each CreditEventLog object holds the Credit object used for that specific event, a timestamp, the type of activity performed with the Credit object, and a text note field.
Use fetchCreditHistory to return an array of CreditEventLog objects:

