Android Question Android App With In App Purchase

BitsAndBytes

Active Member
Licensed User
I have an application which has free version and user has 5 saves limit and payed version which user can save with no limit. How i will check on the begining of my program if user has all ready made the in app purchase and remove the limit?
I am receiving ERROR IAB HELPER NOT SETUP.... error. What i am doing wrong?

B4X:
Activity_Create
tameio.Initialize("tameio", PrivateKey)
tameio.DebugLogging = True
tameio.GetOwnedProducts

Sub tameio_ownedProducts(Success As Boolean, purchases As Map)
  Log(Success)
  If Success Then
      For Each p As Purchase In purchases.Values
         Dim p As Purchase
         If p.ProductId = "full_version" And p.PurchaseState = p.STATE_PURCHASED  Then
             HasApplicationBeenPayed = True
          Else
         HasApplicationBeenPayed = False
         End If
      Next
  End If
End Sub


Sub tameio_BillingSupported (Supported As Boolean, Message As String)
   If Supported Then tameio.GetOwnedProducts
End Sub


Sub tameio_PurchaseCompleted (Success As Boolean, Product As Purchase)
  If Success = True Then
     HasApplicationBeenPayed = True
     ToastMessageShow("Thank you for your donation!",True)
     TerminateMyApplication
  Else
      HasApplicationBeenPayed = False
  End If
End Sub


Private Sub ButtonSaveRecord_Click
   If HasApplicationBeenPayed = True Then   
     SaveRecord 
   Else if HasApplicationBeenPayed = False Then
     If RecordsTable.GetRowCount < 4 Then
       SaveRecord
     Else If RecordsTable.GetRowCount >= 4 Then
       Dim Purch As Purchase
       Dim i As Int
       Log(Purch.ProductId)
       i = Msgbox2(PurchaseMessages(0),"title", PurchaseMessages(1),"Demo","",Null)
       If i = DialogResponse.POSITIVE Then
         tameio.RequestPayment("full_version","inapp","title" & Application.VersionName)
       End If
     End If
   End If       
End Sub
 
Last edited:

BitsAndBytes

Active Member
Licensed User
One user buyed my app and after he opens the application he see that. The problem still exists. Can you help? :(
 

Attachments

  • Καταγραφή.PNG
    Καταγραφή.PNG
    11.3 KB · Views: 120
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
One user buyed my app and after he opens the application he see that. The problem still exists. Can you help? :(

Premise: never published apps, never used in-app.

The error message means you are trying to "access" some object that does not exist (it's impossible to say what object, without the source code).
Post the event routine (xxx_ownerproducts - which name should be the name you set when you initialized the BillingManager3 object + the event name, so I don't know why it is "main_tameio_ownerproducts, but given that it starts, should be ok).

You wrote:
One user buyed my app and after he opens the application he see that.
Buyed he the app or an in-app product (or both?)
 
Last edited:
Upvote 0

BitsAndBytes

Active Member
Licensed User
B4X:
 Sub tameio_ownedProducts(Success As Boolean, purchases AsMap)

Log(Success)

If Success Then
For Each p AsPurchaseIn purchases.Values

Dim p As Purchase

If p.ProductId = "full_version"And p.PurchaseState = p.STATE_PURCHASED Then
HasApplicationBeenPayed = True
Else
HasApplicationBeenPayed = False
EndIf
Next
EndIf

End Sub
that is the code . The user buy the in app purchase [full version]
 
Last edited:
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
B4X:
 Sub tameio_ownedProducts(Success As Boolean, purchases AsMap)

Log(Success)

If Success Then
For Each p AsPurchaseIn purchases.Values

Dim p As Purchase

If p.ProductId = "full_version"And p.PurchaseState = p.STATE_PURCHASED Then
HasApplicationBeenPayed = True
Else
HasApplicationBeenPayed = False
EndIf
Next
EndIf

End Sub
that is the code . The user buy the in app purchase [full version]

In the loop:

For Each p As Purchase...
p is already declared and it is got from the map.

Remove:

Dim p As Purchase
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
In the loop:

For Each p As Purchase...
p is already declared and it is got from the map.

Remove:

Dim p As Purchase


Given this Erels's answer:
The keys in the map are the products ids (or Skus)
probably you could write, more simply:
B4X:
Sub tameio_ownedProducts(Success As Boolean, purchases AsMap)
Log(Success)

If Success Then

   dim P as purchase = purchases.get("full_version")
   If p <> Null Then
       if p.PurchaseState = p.STATE_PURCHASED Then
       ...
   End If

End If

If you instead use the loop, you can use Exit right before next (you have alread found the element so you don't need to continue the searching)
 
Upvote 0
Top