In-App purchase testing

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Aduro91
Posts: 56
Joined: Sat Jul 22, 2023 8:49 pm

In-App purchase testing

Post by Aduro91 » Wed Jan 01, 2025 11:26 pm

Hey all,

I am looking to test in-app purchases.

1. I have set up a non-consumable purchase in the app store
2. I have reworded the following code:

In a button:

Code: Select all

on mouseUp
   mobileStoreEnablePurchaseUpdates
   mobileStoreSetProductType "com.runrev.sampleapp.nonconsumable" ((changed to "com.mydomain.myapp.myproductID" to match my internal app ID and product ID on Apple Connect)), "inapp"
   mobileStoreMakePurchase "com.runrev.sampleapp.nonconsumable" ((changed to "com.mydomain.myapp.myproductID" to match my internal app ID and product ID on Apple Connect)), "1", "This belongs to me"
end mouseUp

 
And in the stack script:

on purchaseStateUpdate pPurchaseID, pProductID, pState
   switch pState
      case "paymentReceived" 
         answer "payment received!"
         offerPurchasedProduct pProductID
         mobileStoreConfirmPurchase pProductID
         mobileStoreDisablePurchaseUpdates
         break
      case "error"
         answer "Error occured during purchase handling:" & return & return & mobileStorePurchaseError(pPurchaseID)
         mobileStoreDisablePurchaseUpdates
         break
      case "invalidSKU"
         answer "Invalid SKU."
         mobileStoreDisablePurchaseUpdates
         break
      case "alreadyEntitled"
         answer "Already Owned."
         mobileStoreDisablePurchaseUpdates
         break
      case "restored"
         answer "restored"
         offerPurchasedProduct pProductID
         mobileStoreConfirmPurchase pProductID
         mobileStoreDisablePurchaseUpdates
         break
      case "cancelled"
         answer "Purchase Cancelled:" && pProductID
         mobileStoreDisablePurchaseUpdates
         break     
   end switch
end purchaseStateUpdate

 

on offerPurchasedProduct pProductID
   if pProductID is "com.runrev.sampleapp.nonconsumable" ((changed to "com.mydomain.myapp.myproductID" to match my internal app ID and product ID on Apple Connect)) then
      put "success" into field result
end if
end offerPurchasedProduct	
I use a sandbox account that I didn't log into the app store with seperately and first logged in through the app.

But i get:

Error occured during pruchase handling: an unknown error occured.

Any ideas?

Aduro91
Posts: 56
Joined: Sat Jul 22, 2023 8:49 pm

Re: In-App purchase testing

Post by Aduro91 » Fri Jan 03, 2025 8:36 pm

SOLVED: The problem was that I needed to add bank details in order to complete the Paid App agreement, which was stuck on pending user info.

Post Reply