# How integrate in-app payment in iOS App

**URL:** <https://forum.xojo.com/t/how-integrate-in-app-payment-in-ios-app/35272>\
**Category:** iOS\
**Created:** [January 3, 2017, 11:21am UTC](https://forum.xojo.com/t/how-integrate-in-app-payment-in-ios-app/35272 "2017-01-03T11:21:11Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gabriele\_Marchionni](https://forum.xojo.com/user_avatar/forum.xojo.com/gabriele_marchionni/32/18893_2.png) [@Gabriele\_Marchionni](https://forum.xojo.com/u/Gabriele_Marchionni)\
**Post date:** [January 3, 2017, 11:21am UTC](https://forum.xojo.com/t/how-integrate-in-app-payment-in-ios-app/35272/1 "2017-01-03T11:21:11Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Jeremie\_L](https://forum.xojo.com/user_avatar/forum.xojo.com/jeremie_l/32/150_2.png) [@Jeremie\_L](https://forum.xojo.com/u/Jeremie_L)\
**Post date:** [January 11, 2017, 5:49pm UTC](https://forum.xojo.com/t/how-integrate-in-app-payment-in-ios-app/35272/2 "2017-01-11T17:49:50Z")

</div>

Hi Gabriele,

Jason King’s iOSKit has the necessary classes for handling inApp purchases: [https://github.com/kingj5/iOSKit](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

---

<div class="post-metadata">

**Author:** ![Jason\_King](https://forum.xojo.com/letter_avatar_proxy/v4/letter/j/e480ec/32.png) [@Jason\_King](https://forum.xojo.com/u/Jason_King)\
**Post date:** [January 11, 2017, 7:05pm UTC](https://forum.xojo.com/t/how-integrate-in-app-payment-in-ios-app/35272/3 "2017-01-11T19:05:54Z")

</div>

[quote=309253:@JrmieLeroy]Hi Gabriele,

Jason King’s iOSKit has the necessary classes for handling inApp purchases: [https://github.com/kingj5/iOSKit](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](https://www.raywenderlich.com/127423/in-app-purchases-tutorial)

---

<div class="post-metadata">

**Author:** ![Jason\_King](https://forum.xojo.com/letter_avatar_proxy/v4/letter/j/e480ec/32.png) [@Jason\_King](https://forum.xojo.com/u/Jason_King)\
**Post date:** [January 12, 2017, 1:55am UTC](https://forum.xojo.com/t/how-integrate-in-app-payment-in-ios-app/35272/4 "2017-01-12T01:55:15Z")

</div>

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](https://www.dropbox.com/s/6atpyrrnbjmzxq2/StoreKit%20Test.xojo_binary_project?dl=1)

---

<div class="post-metadata">

**Author:** ![Jon-Paul\_Kelly](https://forum.xojo.com/user_avatar/forum.xojo.com/jon-paul_kelly/32/12471_2.png) [@Jon-Paul\_Kelly](https://forum.xojo.com/u/Jon-Paul_Kelly)\
**Post date:** [June 10, 2017, 11:47pm UTC](https://forum.xojo.com/t/how-integrate-in-app-payment-in-ios-app/35272/5 "2017-06-10T23:47:40Z")

</div>

[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]](https://www.dropbox.com/s/6atpyrrnbjmzxq2/StoreKit%20Test.xojo_binary_project?dl=1%5B/quote%5D)

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!

---

<div class="post-metadata">

**Author:** ![Jason\_King](https://forum.xojo.com/letter_avatar_proxy/v4/letter/j/e480ec/32.png) [@Jason\_King](https://forum.xojo.com/u/Jason_King)\
**Post date:** [June 11, 2017, 12:01am UTC](https://forum.xojo.com/t/how-integrate-in-app-payment-in-ios-app/35272/6 "2017-06-11T00:01:30Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Jon-Paul\_Kelly](https://forum.xojo.com/user_avatar/forum.xojo.com/jon-paul_kelly/32/12471_2.png) [@Jon-Paul\_Kelly](https://forum.xojo.com/u/Jon-Paul_Kelly)\
**Post date:** [June 11, 2017, 6:13am UTC](https://forum.xojo.com/t/how-integrate-in-app-payment-in-ios-app/35272/7 "2017-06-11T06:13:02Z")

</div>

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.

1. 

`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`

1. 

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

1. 

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

1. 

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

1. 

`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:  
 ![](http://jp-kelly.com/images/before.png)

After:  
 ![](http://jp-kelly.com/images/after.png)

---

<div class="post-metadata">

**Author:** ![Antonio\_Rinaldi](https://forum.xojo.com/user_avatar/forum.xojo.com/antonio_rinaldi/32/331_2.png) [@Antonio\_Rinaldi](https://forum.xojo.com/u/Antonio_Rinaldi)\
**Post date:** [June 11, 2017, 8:30am UTC](https://forum.xojo.com/t/how-integrate-in-app-payment-in-ios-app/35272/8 "2017-06-11T08:30:21Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Kevin\_Currie](https://forum.xojo.com/letter_avatar_proxy/v4/letter/k/e56c9b/32.png) [@Kevin\_Currie](https://forum.xojo.com/u/Kevin_Currie)\
**Post date:** [November 23, 2017, 2:21am UTC](https://forum.xojo.com/t/how-integrate-in-app-payment-in-ios-app/35272/9 "2017-11-23T02:21:19Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Jason\_King](https://forum.xojo.com/letter_avatar_proxy/v4/letter/j/e480ec/32.png) [@Jason\_King](https://forum.xojo.com/u/Jason_King)\
**Post date:** [November 23, 2017, 2:56am UTC](https://forum.xojo.com/t/how-integrate-in-app-payment-in-ios-app/35272/10 "2017-11-23T02:56:49Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Kevin\_Currie](https://forum.xojo.com/letter_avatar_proxy/v4/letter/k/e56c9b/32.png) [@Kevin\_Currie](https://forum.xojo.com/u/Kevin_Currie)\
**Post date:** [November 23, 2017, 3:02am UTC](https://forum.xojo.com/t/how-integrate-in-app-payment-in-ios-app/35272/11 "2017-11-23T03:02:53Z")

</div>

Thanks Jason,

Another question:

```auto
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?

---

<div class="post-metadata">

**Author:** ![Jason\_King](https://forum.xojo.com/letter_avatar_proxy/v4/letter/j/e480ec/32.png) [@Jason\_King](https://forum.xojo.com/u/Jason_King)\
**Post date:** [November 28, 2017, 4:40am UTC](https://forum.xojo.com/t/how-integrate-in-app-payment-in-ios-app/35272/12 "2017-11-28T04:40:52Z")

</div>

[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

> [@](#):
>
> Is there a way to clear a purchase from Sandbox so it shows they didnt purchase?

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.

---

<div class="post-metadata">

**Author:** ![system](https://forum.xojo.com/uploads/default/original/1X/455b4dcc0e61630e9f81940004ddffa49c432a46.png) [@system](https://forum.xojo.com/u/system)\
**Post date:** [October 29, 2020, 6:36pm UTC](https://forum.xojo.com/t/how-integrate-in-app-payment-in-ios-app/35272/13 "2020-10-29T18:36:05Z")

</div>


