Skip to main content

Android Receipt Validation

Validates receipt information for Android in-app purchases.

Call Information

// If using Unity IAP
IAP.Android(string receipt, PlayNANOODelegate callback) {}
IAP.Android(string receipt, bool duplicateAllow, PlayNANOODelegate callback) {}


// If not using Unity IAP
IAP.Android(string receipt, string skuDetails, string signature, PlayNANOODelegate callback) {}
IAP.Android(string receipt, string skuDetails, string signature, bool duplicateAllow, PlayNANOODelegate callback) {}

Call Information Details

ParameterDescriptionType
receiptTable Codestring
skuDetails안드로이드 상품 정보string
signatureAndroid Signaturestring
duplicateAllowAllow duplicate receipt validationboolean
callbackCommunication resultPlayNANOODelegate
Source Code
using PlayNANOO;

public class PlayNANOOExample : MonoBehaviour
{
Plugin plugin;

void Awake()
{
plugin = Plugin.GetInstance();
}

// If using Unity IAP
public PurchaseProcessingResult ProcessPurchase(PurchaseEventArgs args)
{
plugin.IAP.Android(args.purchasedProduct.receipt, (status, errorMessage, jsonString, values) => {
if (status.Equals(Configure.PN_API_STATE_SUCCESS))
{
Debug.Log(values["UserID"]);
Debug.Log(values["PackageName"]);
Debug.Log(values["OrderID"]);
Debug.Log(values["ProductID"]);
Debug.Log(values["Currency"]);
Debug.Log(values["Quantity"]);
Debug.Log(values["Price"]);
}
else
{
Debug.Log("Fail");
}
});
}

// If not using Unity IAP
public void AndroidValidate()
{
string receipt = "string";
string skuDetails = "string";
string signature = "string";
plugin.IAP.Android(receipt, skuDetails, signature, (status, errorMessage, jsonString, values) => {
if (status.Equals(Configure.PN_API_STATE_SUCCESS))
{
Debug.Log(values["UserID"]);
Debug.Log(values["PackageName"]);
Debug.Log(values["OrderID"]);
Debug.Log(values["ProductID"]);
Debug.Log(values["Currency"]);
Debug.Log(values["Quantity"]);
Debug.Log(values["Price"]);
}
else
{
Debug.Log("Fail");
}
});
}
}

Communication Result

HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
{
"UserID" : "String",
"PackageName" : "String",
"OrderID" : "String",
"ProductID" : "String",
"Currency" : "String",
"Quantity" : "Integer",
"Price" : "String"
}

Result Information Details

Data KeyDescriptionType
UserIDUser IDString
PackageNameApp package nameString
ProductIDProduct IDString
OrderIDOrder IDString
CurrencyPayment Currency CodeString
QuantityPurchase quantityinteger
PriceItem priceinteger

Error Information

Receipt validation failed
ErrorCode : 20000
ErrorMessage : ValidationFailException

App package name does not match
ErrorCode : 20002
ErrorMessage : NotMatchPackageNameException

Receipt has already been used
ErrorCode : 20005
ErrorMessage : ExistsReceiptException