Account.decrementTokens
Web Session Object
Transaction Object
Token Object
Season Set Object
Refund Object
RatePlan Object
Product Object
Payment Provider Object
Payment Method Object
NameValuePair Object
GiftCard Object
Entitlement Object
Chargeback Object
Campaign Object
BillingPlan Object
AutoBill Object
Address Object
Activity Object
Account Object
Account.decrementTokens
The decrementTokens method deducts the specified number of tokens, of named token types, from the Account object. Before calling decrementTokens, call tokenBalance() to verify that there are enough tokens of the specified type to fulfill the call. Use decrementTokens to deduct tokens from an Account object without conducting a formal CashBox transaction.
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.
account: the Account object from which to deduct tokens. Use the merchantAccountId or VID to identify the object.
tokenAmounts: an array of one or more TokenAmount objects, each of which specifies the type of token to deduct and its quantity. The quantity must be a positive number. Before calling decrementTokens, you must have created the token types.
Output
return: an object of type Return that indicates the success or failure of the call.
tokenAmounts: an array of one or more TokenAmount objects, each of which specifies a type of token, and its balance (quantity) in the Account object, if the call succeeds.
Returns
This method returns the codes listed in Standard Return Codes.
Example
// to deduct tokens from an existing account
$acct = new Account();
// Reference an existing account from which tokens are to be deducted
$acct = new Account();
$acct->setMerchantAccountId('9876-5432');
// Refer to an existing token type using its id
$tok = new Token();
$tok->setMerchantTokenId("US_FREQ_BOOK_BUYER_PT");
// create a TokenAmount object and populate it with token type and
// quantity
$tokAmt = new TokenAmount();
$tokAmt->setToken($tok);
$tokAmt->setAmount(2);
// Refer to another existing token type using its id
$tok2 = new Token();
$tok2->setMerchantTokenId("US_FREQ_DVD_BUYER_PT");
// create a TokenAmount object and populate it with token type and
// quantity
$tokAmt2 = new TokenAmount();
$tokAmt2->setToken($tok2);
$tokAmt2->setAmount(2);
$tokAmounts = array($tokAmt, $tokAmt2);
// make the SOAP call to decrement tokens
$response = $acct->decrementTokens($tokAmounts);
if($response['returnCode']==200) {
// the call returns new token balances on the account
// print those out
$newTokBalances = $response['tokenAmounts'];
foreach ($newTokBalances as $newTokBal) {
print "Token type" . $newTokBal->token->merchantTokenId . "\n";
print "Token amount available" . $newTokBal->amount . "\n";
}
}
For Users
Learn More