<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"><channel><category>pcsoft.us.windev</category><copyright>Copyright 2026, PC SOFT</copyright><lastBuildDate>29 Sep 2017 21:40:00 Z</lastBuildDate><pubDate>29 Sep 2017 21:40:00 Z</pubDate><description>Sorry for the long post but hopefully the code will help. This is my first in-app purchase attempt. I'm testing just android for now. I have one test user for a free version of the app in Alpha release. I've apparently successfully purchased one each of the 3 products according to my google play account, but each purchase showed the "purchase fail" error. Additional purchase attempts gives no response in the app.&#13;
&#13;
I then checked if there were any unconsumed products. That code only gives an error of "Failure checking the received data when validating the inapp purchase"&#13;
I thought I followed the help examples accurately but I can't see what's wrong.&#13;
&#13;
Thanks, Bill&#13;
&#13;
&#13;
App Start up:&#13;
&#13;
arrIdentifier is array of strings&#13;
arrIdentifier = ["student1", "student5", "student10"]&#13;
&#13;
garrProducts is array of inAppProduct&#13;
gMyProduct is inAppProduct&#13;
gnStudentPurchaseQty is int&#13;
&#13;
IF inAppListProductInfo(arrIdentifier, ListProductInfo) = False AND NOT InTestMode() THEN&#13;
Error("Unable to access in-app Products: " + ErrorInfo)&#13;
END&#13;
&#13;
PROCEDURE ListProductInfo(bSuccess is boolean, arrProducts is array of inAppProduct)&#13;
IF NOT bSuccess THEN&#13;
Error("Error: " + ErrorInfo())&#13;
RETURN&#13;
END&#13;
&#13;
garrProducts &lt;= arrProducts&#13;
&#13;
&#13;
***********************************************&#13;
&#13;
List Products Window, Looper Init:&#13;
&#13;
LooperDeleteAll(LOOP_ProductInfo)&#13;
FOR i = 1 _TO_ garrProducts..Occurrence&#13;
LooperAddLine(LOOP_ProductInfo, garrProducts.Caption, i, garrProducts.Price)&#13;
END&#13;
&#13;
***********************************************&#13;
&#13;
List Products Window, Select row:&#13;
&#13;
nIdx is int = LOOP_ProductInfo&#13;
gMyProduct = garrProducts[nIdx]&#13;
&#13;
SWITCH gMyProduct.Identifier&#13;
CASE "student1"&#13;
gnStudentPurchaseQty = 1&#13;
&#13;
CASE "student5"&#13;
gnStudentPurchaseQty = 5&#13;
&#13;
CASE "student10"&#13;
gnStudentPurchaseQty = 10&#13;
OTHER CASE&#13;
Info("Unknown Product")&#13;
END&#13;
&#13;
inAppPurchaseProduct(gMyProduct, PurchaseProduct)&#13;
&#13;
&#13;
PROCEDURE PurchaseProduct(bSuccess is boolean, PurchasedProduct is inAppProduct, PurchaseID)&#13;
&#13;
IF NOT bSuccess THEN&#13;
Info("purchase fail " + PurchasedProduct.Identifier + "--" + ErrorInfo(errFullDetails))&#13;
RETURN&#13;
ELSE&#13;
IF InAndroidMode() THEN&#13;
// Consume the product (optional)&#13;
IF inAppConsumeProduct(PurchasedProduct, PurchaseID, ConsumeProduct) &lt;&gt; True THEN&#13;
Info("consume fail " + PurchasedProduct.Identifier + "--" + ErrorInfo(errFullDetails))&#13;
END&#13;
END&#13;
IF IniOSMode() THEN&#13;
// Activate the product in the application&#13;
ConsumeProduct(bSuccess)&#13;
END&#13;
END&#13;
&#13;
PROCEDURE ConsumeProduct(bSuccess is boolean)&#13;
IF NOT bSuccess THEN&#13;
ToastDisplay(ErrorInfo())&#13;
ELSE&#13;
HReadFirst(Settings)&#13;
Settings.MaxStudents += gnStudentPurchaseQty&#13;
HSave(Settings)&#13;
&#13;
END&#13;
&#13;
***********************************************&#13;
&#13;
Unconsumed Purchases Window:&#13;
&#13;
inAppListPurchase(ListUnusedPurchases, inAppOrderId)&#13;
&#13;
PROCEDURE ListUnusedPurchases(bSuccess is boolean, sPurchaseList is string)&#13;
&#13;
LooperDeleteAll(LOOP_ProductInfo)&#13;
&#13;
IF NOT bSuccess THEN&#13;
Info("list unused: " + ErrorInfo(errFullDetails))&#13;
ELSE&#13;
// Browses the purchases performed&#13;
FOR EACH STRING sPurchaseInfo OF sPurchaseList SEPARATED BY CR&#13;
// Retrieves the identifier of the product&#13;
sProductID is string = ExtractString(sPurchaseInfo, 1, TAB)&#13;
// Retrieves the identifier of the purchase&#13;
sPurchaseID is string = ExtractString(sPurchaseInfo, 2, TAB)&#13;
// Consumes the product if necessary&#13;
LooperAddLine(LOOP_ProductInfo, sProductID, sPurchaseID)&#13;
END&#13;
END</description><ttl>30</ttl><generator>WEBDEV</generator><language>en_US</language><link>https://forum.pcsoft.fr/es-ES/pcsoft.us.windev/62800-wm21-inapp-purchase-and-consume/read.awp</link><title>WM21 inapp Purchase and Consume</title><managingEditor>moderateur@pcsoft.fr (El moderador)</managingEditor><webMaster>webmaster@pcsoft.fr (El webmaster)</webMaster></channel></rss>
