0

I am trying to test in app purchases in my application following plugin. Also I have checked this and thousands of other officical/not official articles but there is no result. I do not thins there is a problem in my code because I asked another developer to share me his code and I use it in my app. In his project this code works perfect but I have InAppBillingPurchaseException "Can not connect to Itunes Store". I also logged out of my real accounts before entering sandbox credentials. This is the code but the I do not think the problem is here:

public async Task<bool> PurchaseItemAsync()
    {
        var billing = CrossInAppBilling.Current;
        LastExceptionMessage = null;

        try
        {
            var connected = await billing.ConnectAsync();
            if (connected == false)
                return false;

            var purchase = await billing.PurchaseAsync(_kProductId, ItemType.InAppPurchase, _kPayload);

            if (purchase == null)
                return false;
            else if (purchase.State == PurchaseState.Purchased)
                return true;
        }
        catch (InAppBillingPurchaseException ex)
        {
            OnPurchaseException(ex);
        }
        catch (Exception ex)
        {
            //Dlog.Error("Issue connecting: " + ex);
            LastExceptionMessage = ex.Message;
        }
        finally
        {
            await billing.DisconnectAsync();
        }

        return false;
    }
S. Koshelnyk
  • 478
  • 1
  • 5
  • 20
  • Did you check the item In-App Purchase in your app ID? – Lucas Zhang Nov 20 '18 at 06:34
  • How to do that? I do not think the problem is in item id because first of all it must connect to itunes store but it can not – S. Koshelnyk Nov 20 '18 at 09:16
  • https://learn.microsoft.com/en-us/xamarin/ios/platform/in-app-purchasing/in-app-purchase-basics-and-configuration Refer this document – Lucas Zhang Nov 20 '18 at 09:18
  • Yes, I did this steps. But I did not published my app jet. I want to test it in sandbox – S. Koshelnyk Nov 20 '18 at 09:33
  • any solution you got it? – Adil Saiyad Mar 17 '20 at 09:28
  • @AdilSaiyad we solved it but we do not know if this was exactly the solution that solved this problem. We think it started to work after filling legal info on the site (ITunesConnect or how it calls.) We think it started to work after filling this: https://help.apple.com/app-store-connect/#/devb6df5ee51. Also after this you need to upload app with a purchase. Probably this two steps can help you. – S. Koshelnyk Mar 17 '20 at 09:59
  • @S.Koshelnyk okay after you filling details instant working or after completed banking review and show active status. – Adil Saiyad Mar 17 '20 at 10:02
  • @AdilSaiyad Currently I do not have access to that app. It was on the previous job. Also I updated comment above. Do not remember in details when and after what steps it was solved – S. Koshelnyk Mar 17 '20 at 10:06
  • okay, thanks @S.Koshelnyk – Adil Saiyad Mar 17 '20 at 10:07

1 Answers1

0

In my case, bundleID in my app was not matching with the product id of In App purchase. I had bundle ID com.xam.sample in my app code. But product ID was testiap. So I created IAP with productID com.xam.sample.testiap and I was able to solve that error this way.

Ali Raza
  • 374
  • 2
  • 6
  • 21