Skip to main content
Version: 5.11.4

IsValidateOneStorePurchase

public BackendReturnObject IsValidateOneStorePurchase(string productId, string purchaseToken, string receiptDescription);

Invalid special characters

Special CharacterDescription
'Single quotation mark
\ Backslash

Valid special characters

Special CharacterDescription
.Period
,Comma
"Double quotation mark
()Parentheses
!Exclamation mark
?Question mark
~Tilde
@At sign
*Asterisk
+Plus
-Hyphen
/Slash

If you are using special characters that are not listed above, manually check that the receipt verification works properly before applying.

Parameters

ValueTypeDescription
productIdstringOneStore.Purchasing.PurchaseData.purchase.ProductId
purchaseTokenstringOneStore.Purchasing.PurchaseData.purchase.PurchaseToken
receiptDescriptionstringAdditional details to be stored

Description

IPurchaseCallback.OnConsumeSucceeded() in the In-app payment service supported by ONE store accepts the receipt for the purchased product and verifies it via the BACKND server.

  • BACKND verifies the validity of the receipt itself and the purchased productId.
  • You must be logged in to BACKND to use its verification function.

Example

Synchronous

    public void BuyButton(int i)
{
string productId = "gold";

// Payment logic
ProductType productType = ProductType.INAPP;
var purchaseFlowParams = new PurchaseFlowParams.Builder()
.SetProductId(productId) // Needs to be added
.SetProductType(productType) // Needs to be added
.SetDeveloperPayload("Enter any additional information if necessary") // Optional
.Build();
purchaseClient.Purchase(purchaseFlowParams);
}

public void OnPurchaseSucceeded(List<PurchaseData> purchases)
{
/*
Processing BACKND receipt verification
*/
for(int i = 0; i < purchases.Count; i++) {

BackendReturnObject validation = Backend.Receipt.IsValidateOneStorePurchase(purchases[i].ProductId, purchases[i].PurchaseToken, "receiptDescription");

// When receipt verification is successful
if (validation.IsSuccess()) {
Debug.Log($"ProcessPurchase: PASS. Product: {purchases[i].ProductId}");

if (purchases[i].ProductId == "gold") {
// Hand out Gold
}

} else {
Debug.Log($"ProcessPurchase: FAIL. Unrecognized product: {purchases[i].ProductId}");
}
}
}

Asynchronous

    public void BuyButton(int i)
{
string productId = "gold";

// Payment logic
ProductType productType = ProductType.INAPP;
var purchaseFlowParams = new PurchaseFlowParams.Builder()
.SetProductId(productId) // Needs to be added
.SetProductType(productType) // Needs to be added
.SetDeveloperPayload("Enter any additional information if necessary") // Optional
.Build();
purchaseClient.Purchase(purchaseFlowParams);
}

public void OnPurchaseSucceeded(List<PurchaseData> purchases)
{
/*
Processing BACKND receipt verification
*/
for(int i = 0; i < purchases.Count; i++) {

Backend.Receipt.IsValidateOneStorePurchase(purchases[i].ProductId, purchases[i].PurchaseToken, "receiptDescription", (callback) =>
{
// When receipt verification is successful
if (callback.IsSuccess()) {
Debug.Log($"ProcessPurchase: PASS. Product: {purchases[i].ProductId}");

if (purchases[i].ProductId == "gold") {
// Hand out Gold
}

} else {
Debug.Log($"ProcessPurchase: FAIL. Unrecognized product: {purchases[i].ProductId}");
}
});
}
}

SendQueue

    public void BuyButton(int i)
{
string productId = "gold";

// Payment logic
ProductType productType = ProductType.INAPP;
var purchaseFlowParams = new PurchaseFlowParams.Builder()
.SetProductId(productId) // Needs to be added
.SetProductType(productType) // Needs to be added
.SetDeveloperPayload("Enter any additional information if necessary") // Optional
.Build();
purchaseClient.Purchase(purchaseFlowParams);
}

public void OnPurchaseSucceeded(List<PurchaseData> purchases)
{
/*
Processing BACKND receipt verification
*/
for(int i = 0; i < purchases.Count; i++) {

SendQueue.Enqueue(Backend.Receipt.IsValidateOneStorePurchase, purchases[i].ProductId, purchases[i].PurchaseToken, "receiptDescription", (callback) =>
{
// When receipt verification is successful
if (callback.IsSuccess()) {
Debug.Log($"ProcessPurchase: PASS. Product: {purchases[i].ProductId}");

if (purchases[i].ProductId == "gold") {
// Hand out Gold
}

} else {
Debug.Log($"ProcessPurchase: FAIL. Unrecognized product: {purchases[i].ProductId}");
}
});
}
}

Return cases

Success cases

When successful
statusCode : 201

returnValue : {"usedDate":"2018-10-15T05:17:49Z"}

Error cases

When the ONE store information in the console is incorrect
statusCode : 400
errorCode : UndefinedParameterException

When receipt verification is not valid
statusCode : 400
errorCode : BadParameterException

When the receipt token is string.Empty
statusCode : 400
errorCode : BadParameterException

When productId is string.Empty
statusCode : 400
errorCode : BadParameterException

Tampered/forged receipt token
statusCode : 400
errorCode : BadParameterException

Already used receipt token
statusCode : 409
errorCode : UsedReceipt