iOS Question Purchase in the App

toro1950

Active Member
Licensed User
A warm greeting to the whole forum, on December 15th I made a StoreKit 2 post asking how to sell my app on the Apple store through an annual subscription.
I had found on the Apple store that I had to use StoreKit 2 and in that post I asked how to use it. Erel replied:
It will be difficult to use Store Kit 2 as it is a Swift + Swift UI SDK. I think that it is only a wrapper above the standard StoreKit.
From Alexander Stolte I had this Link where I found
a fairly complicated procedure, but perhaps not insurmountable by my little knowledge, for example I have already created the trial account,
I hope I can continue without problems
but what I can't understand is how to set the code shown on the link
the first part of the code is easily understandable
B4X:
Dim MyStore As Store 'declare it in Process Globals
...
MyStore.Initialize("MyStore")
If MyStore.CanMakePayments = False Then ...
but the second and most important part
B4X:
MyStore.RequestPayment("product.id")

Sub MyStore_PurchaseCompleted (Success As Boolean, Product As Purchase)
   Log("Purchase completed")
   If Product.IsInitialized Then
     Log("Product: " & Product.ProductIdentifier & ", date=" & DateTime.Time(Product.TransactionDate) & _
       ", Transaction identifier=" & Product.TransactionIdentifier)
   End If
   Log("Success = " & Success)
End Sub

I can't understand the only part that I managed to understand "product.id" which
is equivalent to the number that I will enter for the App I remain with it I understand;
Erel, replying to another person who asked for a complete example, replied that the code was the one he posted.
I would like the app to work for a year once paid and downloaded, then it will have to be repurchased to make
it work for another year and so on in the following years. At the beginning I had entered a key that had to be
replaced every year, I would have sent the key via SMS or WhatsApp after receiving the transfer from the
customer without going through Apple but I was told that this is not possible, I have to make the purchase in the App.
How do I have to change that code to do all this? in date=" & DateTime.Time(Product.TransactionDate) What do I have
to enter?. Once I have entered the correct code, and downloaded the app, how do I test it?
Excuse my ignorance, it's the first time I've done this and excuse me for the bad English (Google translate)
 

toro1950

Active Member
Licensed User
Hi, I don't think anyone on the forum has ever done something like this, Purchase in the App, so I think I didn't explain myself well. I'll try to ask the question in a different way.
If I understand correctly, I should make a routine that checks the time passed after installing the app after the desired time, for example a year, using the iStore library, I should use the code
MyStore.RequestPayment("product.id")
for payment request, I think this request was intercepted by the Apple store,
Once the user has paid for the app, how does it detect that it has been paid?
I think with the following code
B4X:
Sub MyStore_PurchaseCompleted (Success As Boolean, Product As Purchase)
   Log("Purchase completed")
   If Product.IsInitialized Then
     Log("Product: " & Product.ProductIdentifier & ", date=" & DateTime.Time(Product.TransactionDate) & _
       ", Transaction identifier=" & Product.TransactionIdentifier)
   End If
   Log("Success = " & Success)
End Sub

but I don't really understand what the code is giving me back
B4X:
If Product.IsInitialized Then
     Log("Product: " & Product.ProductIdentifier & ", date=" & DateTime.Time(Product.TransactionDate) & _
       ", Transaction identifier=" & Product.TransactionIdentifier)
   End If
product.id? payment date?
transaction number?
where do I enter the code?
in B4XPage Appear
is this the only code I have to use?









I also don't understand how this sub detects that the payment has been made
 
Upvote 0
Top