Skip to main content
Version: 5.9.6

ChargeTBC


Android

public BackendReturnObject ChargeTBC(string receiptJson, string details);

iOS public BackendReturnObject ChargeTBC(string productId, string receiptToken, string details);

Parameters

Android

ValueTypeDescription
receiptJsonstringValue of Purchasing.PurchaseEventArgs.purchasedProduct.receipt
detailsstringAdditional details to be stored

iOS

ValueTypeDescription
productIdstringID value of the purchased product
receiptTokenstringReceipt token issued after purchase
detailsstringAdditional details to be stored

Description

After validating the receipt token, TBC(The Backend Coin) that matches the productId is provided.

To call the ChargeTBC method, you must first register the cash that matches the corresponding productId(product ID) in BACKND Console.
For more information on how to register cash, refer to Console guide - game cash management.

For the ChargeTBC method, the methods to be called in Android and iOS vary.
For iOS, productId is not included in the receipt token; therefore, you must enter the productId as the first parameter value.

Android Example

Receipt verification using receiptJson obtained via Unity IAP service

Synchronous

public Purchasing.PurchaseProcessingResult ProcessPurchase(Purchasing.PurchaseEventArgs args){
Backend.TBC.ChargeTBC(args.purchasedProduct.receipt, "Big discount!");
return PurchaseProcessingResult.Complete;
}

Asynchronous

public Purchasing.PurchaseProcessingResult ProcessPurchase(Purchasing.PurchaseEventArgs args)
{
Backend.TBC.ChargeTBC(args.purchasedProduct.receipt, "Big discount!", (callback) =>
{
// Post-process
});
return PurchaseProcessingResult.Complete;
}

SendQueue

public Purchasing.PurchaseProcessingResult ProcessPurchase(Purchasing.PurchaseEventArgs args)
{
SendQueue.Enqueue(Backend.TBC.ChargeTBC, args.purchasedProduct.receipt, "Big discount!", callback =>
{
// Post-process
});
return PurchaseProcessingResult.Complete;
}

iOS Example

Receipt verification using the receipt token obtained via Unity IAP service

Synchronous

public Purchasing.PurchaseProcessingResult ProcessPurchase(Purchasing.PurchaseEventArgs args){
Backend.TBC.ChargeTBC("pId", args.purchasedProduct.receipt, "Big discount!");
return PurchaseProcessingResult.Complete;
}

Asynchronous

public Purchasing.PurchaseProcessingResult ProcessPurchase(Purchasing.PurchaseEventArgs args)
{
Backend.TBC.ChargeTBC("pId", args.purchasedProduct.receipt, "Big discount!", (callback) =>
{
// Post-process
});
return PurchaseProcessingResult.Complete;
}

SendQueue

public Purchasing.PurchaseProcessingResult ProcessPurchase(Purchasing.PurchaseEventArgs args)
{
SendQueue.Enqueue(Backend.TBC.ChargeTBC, "pId", args.purchasedProduct.receipt, "Big discount!", callback =>
{
// Post-process
});
return PurchaseProcessingResult.Complete;
}

Return cases

Success cases

When the recharging is successful
statusCode : 201

returnValue : refer to GetReturnValuetoJSON

Error cases

Expired receipt token
statusCode : 400
errorCode : BadParameterException

Receipt of refund/cancellation
statusCode : 402
errorCode : AbnormalReceipt

When a product not in BACKND Console was purchased
statusCode : 404
errorCode : NotFoundException

Already used receipt token
statusCode : 409
errorCode : UsedReceipt

GetReturnValuetoJSON

{ 
usedTBC: 450, // Amount of recharged TBC
amountTBC: 947.047 // User's total TBC after recharging
}