ChargeGameCashByApple
Android
public BackndReturnObject ChargeGameCashByGoogle(string receiptJson, string details);
iOS
public BackndReturnObject ChargeGameCashByApple(string productId, string receiptToken, string details);
Parameters
Android
Value | Type | Description |
---|---|---|
receiptJson | string | Value of Purchasing.PurchaseEventArgs.purchasedProduct.receipt |
details | string | Additional details to be stored |
iOS
Value | Type | Description |
---|---|---|
productId | string | ID value of the purchased product |
receiptToken | string | Receipt token issued after purchase |
details | string | Additional details to be stored |
Description
After validating the receipt token, GameCash(The Backnd Coin) that matches the productId is provided.
To call the ChargeGameCashByApple or ChargeGameCashByGoogle 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 ChargeGameCashByApple or ChargeGameCashByGoogle 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){
Backnd.GameCash.ChargeGameCashByGoogle(args.purchasedProduct.receipt, "Big discount!");
return PurchaseProcessingResult.Complete;
}
Asynchronous
public Purchasing.PurchaseProcessingResult ProcessPurchase(Purchasing.PurchaseEventArgs args)
{
Backnd.GameCash.ChargeGameCashByGoogle(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){
Backnd.GameCash.ChargeGameCashByApple("pId", args.purchasedProduct.receipt, "Big discount!");
return PurchaseProcessingResult.Complete;
}
Asynchronous
public Purchasing.PurchaseProcessingResult ProcessPurchase(Purchasing.PurchaseEventArgs args)
{
Backnd.GameCash.ChargeGameCashByApple("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
}