How integrate in-app payment in iOS App

How can I integrate the in-app payment in my iOS App made xojo?
I must add a fee credits. Example: the user buy 10 credits for 1 dollar ans use them in my App.
There is a guide that can help me to add the payment in-app?

Hi Gabriele,

Jason King’s iOSKit has the necessary classes for handling inApp purchases: https://github.com/kingj5/iOSKit
Unfortunately there is no guide for the moment, I had some difficulties adding this to my app but now it works perfectly.

  1. You need to create the App in iTunesConnect, and register the bundleID

  2. You need to create a new inAppPurchase in iTunesConnect to get the inAppPurchase ID

  3. In Xojo > Build Settings > iOS > Inspector > “Cog-wheel” icon (entitlements) > Activate inApp Purchases

[quote=309253:@JrmieLeroy]Hi Gabriele,

Jason King’s iOSKit has the necessary classes for handling inApp purchases: https://github.com/kingj5/iOSKit
Unfortunately there is no guide for the moment, I had some difficulties adding this to my app but now it works perfectly.

  1. You need to create the App in iTunesConnect, and register the bundleID

  2. You need to create a new inAppPurchase in iTunesConnect to get the inAppPurchase ID

  3. In Xojo > Build Settings > iOS > Inspector > “Cog-wheel” icon (entitlements) > Activate inApp Purchases[/quote]
    Indeed they are in iOSKit. I’m sorry there is no guide. Since iOSKit is open source you can feel free to write a quick guide which I’ll add to the notes or wiki or submit a pull request adding it. The readme has a little bit but I recommend that you check out ray wenderlich’s tutorials since all of the classes you will need from it are in iOSKit (including the iAPHelper class).

Edit: https://www.raywenderlich.com/127423/in-app-purchases-tutorial

Also I forgot I made this, maybe it will help someone… Its a small example project of how to use the classes in an app. I haven’t looked at it in a while but it should still work.
https://www.dropbox.com/s/6atpyrrnbjmzxq2/StoreKit%20Test.xojo_binary_project?dl=1

[quote=309311:@Jason King]Also I forgot I made this, maybe it will help someone… Its a small example project of how to use the classes in an app. I haven’t looked at it in a while but it should still work.
https://www.dropbox.com/s/6atpyrrnbjmzxq2/StoreKit%20Test.xojo_binary_project?dl=1[/quote]

I am trying to figure out the IAP example in Jason’s code above.
I cot a few errors when launching the project. I think I fixed those but I cannot figure out how to add products.
Any help will be appreciated!

Can you elaborate on the errors? It’s hard to diagnose if I/we don’t know what’s going wrong. Did you follow the tutorial posted above? It shows how to add them in iTunes and its in the example project how to add them in Xojo.

Sure sorry…
When launching the project I get a warning that the launch images are not there. I deleted the launch images from the project to stop that warning.

When building I get the following errors.

view1.RowData, line 4 The constructor of this class is protected, and can only be called from within this class. dim result as new iOSTableCellData

View1.name This class is missing the RowCount method from the interface iOSTableDataSource View1

View1.name This class is missing the RowData method from the interface iOSTableDataSource View1

View1.name This class is missing the SectionCount method from the interface iOSTableDataSource View1

View1.name This class is missing the SectionTitle method from the interface iOSTableDataSource View1

I disabled the iOSTableDataSourceinterface for View1 then re-enabled it and the last 4 errors went away. The structure of the methods for the interface changed. See images.

Before:

After:

The interface has changed (some times ago)
Move the code from the without table parameter to the with table parameter ones and remove the without table parameter methods. (they’ll never called)

to create a iosTableCell you can’t use new iosTableCell but you have to use:
result = table.iOSTable.CreateCell

or .createCustomCell if you want to use a custom cell.

When i run the In-App purchase from a simulator it gets as far as asking to sign in then confirms the Buy or indicates you have purchased already etc but the response is always failedTransaction with “Cannot Connect to App Store.”

When i build and run from my Ipad i get the CompleteTransaction events showing completed.

Is there anyway to make this work in a Simulator?

In the simulator you have to setup a special sandbox. Read the Apple docs, they explain what you need to do.

Thanks Jason,

Another question:

if not StoreKit.InAppPurchaseHelper.GetInstance.isproductPurchased(product.productIdentifier) 

So if the above returns a False it means the In-App has not been purchased yet?

Is there a way to clear a purchase from Sandbox so it shows they didnt purchase?

[quote=361120:@Kevin Currie]Thanks Jason,

Another question:

if not StoreKit.InAppPurchaseHelper.GetInstance.isproductPurchased(product.productIdentifier)
So if the above returns a False it means the In-App has not been purchased yet?[/quote]
Yes

Probably but I’m not sure. I believe you are recommended to save to UserDefaults when a user makes a purchase so you don’t have to check with StoreKit every time.