Skip to main content

iOS Receipt Validation

Validates receipt information for iOS in-app purchases.

When using Unity IAP 5.0 (StoreKit 2)

This method validates Base64 receipts from Unity IAP 4.x (StoreKit 1). If you have migrated to Unity IAP 5.0 (StoreKit 2), use iOS Receipt Validation (StoreKit 2) which validates the signed transaction (JWS).

Call Information

IAP.IOS(string receipt, string productId, string currency, double price, PlayNANOODelegate callback) {}
IAP.IOS(string receipt, string productId, string currency, double price, bool duplicateAllow, PlayNANOODelegate callback) {}

Call Details

ParameterDescriptionType
receiptReceipt informationstring
productIdPayment product IDstring
currencyCurrency code (KRW, JPY, USD, CNY...).string
pricePayment amountdouble
duplicateAllowAllow duplicate receipt validationboolean
callbackCommunication resultPlayNANOODelegate

Example

When using Unity IAP Service

using PlayNANOO;

public class PlayNANOOExample : MonoBehaviour
{
Plugin plugin;

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

// Unity IAP Service
public PurchaseProcessingResult ProcessPurchase(PurchaseEventArgs args)
{
plugin.IAP.IOS(args.purchasedProduct.receipt, "PRODUCT_ID", "CURRENCY", 100, (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");
}
});
}
}

When not using Unity IAP Service

using PlayNANOO;

public class PlayNANOOExample : MonoBehaviour
{
Plugin plugin;

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

plugin.IAP.IOS("RECEIPT", "PRODUCT_ID", "CURRENCY", 100, (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");
}
});
}
}

Response

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

Response Details

Data KeyDescriptionType
UserIDUser identifier IDstring
PackageNameApp package namestring
ProductIDPayment product IDstring
OrderIDOrder IDstring
CurrencyPayment currency codestring
QuantityPurchase quantityinteger
PriceProduct priceinteger

Error Information

When receipt validation fails ErrorCode : 20000 ErrorMessage : ValidationFailException

When the application package name does not match ErrorCode : 20002 ErrorMessage : NotMatchPackageNameException

When the receipt has already been used ErrorCode : 20005 ErrorMessage : ExistsReceiptException