Skip to main content
Vindicia Knowledge Center

AutoBill.revokeCredit

AutoBill.revokeCredit

AutoBill.revokeCredit

The revokeCredit method deducts credit from an AutoBill object. If the deduction results in a negative amount for a given type of credit, CashBox sets its balance to 0. This method returns the AutoBill object with resultant credit balance.

Specify the amount, type, and VID of the Credit you wish to revoke from the Account as a Credit object.

Credit and related subobjects are described with the Credit Subobject. See Credit Grants and Gift Cards in the CashBox Programming Guide for more information on working with credit.

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: the AutoBill object from which you wish to revoke credit. Use the merchantAutoBillId or VID to identify the object.

credit: a Credit object specifying the amount and type of credit you wish to deduct from the AutoBill.

note: an optional memo regarding the credit revocation.

Output

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

autobill: the AutoBill object from which you revoked credit. This object contains the updated array of Credit objects.

Returns

In addition to those listed in Standard Return Codes, this call returns:

Return Code

Return String

400

One of the following:

  • AutoBill not found.
  • Failed to translate credit error-description.
  • Failed to revoke credit error-description.
  • Failed to save AutoBill after revoking credit.
  • Failed to reload AutoBill after revoking credit error-description.
  • Data validation error: Missing required parameter credit.

Example

// to revoke credit from an autobill

$abill = new AutoBill();

// autobill id for customer's existing subscription
// to a game

$abill->setMerchantAutoBillId('STARWARS-239181');

$tok = new Token();

// specify id of an existing token type.
// the autobill has a payment method defined in terms
// of this token type. Also the billing plan used by
// the autobill specifies a price in terms of this token
// type.

$tok->setMerchantTokenId('STARWARS_POINTS');

$tokAmt = new TokenAmount();
$tokAmt->setToken($tok);
$tokAmt->setAmount(100); // customer lost 100 points in the game

$cr = new Credit();
$cr->setTokenAmounts(array($tokAmt));

// Now make the SOAP API call to deduct points from customer's
// subscription

$response = $abill->revokeCredit($cr);

if ($response['returnCode'] == 200) {

// Credit successfully revoked from the autobill

$updatedAbill = $response['data']->autobill;
$availableCredits = $updatedAbill->getCredit();
$availableTokens = $availableCredits->getTokenAmounts();

print "Available points to subscription: \n";
foreach($availableTokens as $tkAmt) {

print "Token type: " . $tkAmt->getMerchantTokenId() . " ";
print "Amount: " . $tkAmt->getAmount() . "\n";

}

}

else {

// Error while revoking credit from the autobill

print $response['returnString'] . "\n";

}

For Users

Learn More
For Users

Cashbox Features

Learn More
Cashbox Features
Back to Top