# No notification of failure when calling purchaseProduct without internet connection

**URL:** <https://forum.juce.com/t/no-notification-of-failure-when-calling-purchaseproduct-without-internet-connection/55097>\
**Category:** MacOSX and iOS\
**Created:** [February 23, 2023, 4:43pm UTC](https://forum.juce.com/t/no-notification-of-failure-when-calling-purchaseproduct-without-internet-connection/55097 "2023-02-23T16:43:48Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jpo](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/jpo/32/503_2.png) [@jpo](https://forum.juce.com/u/jpo)\
**Post date:** [February 23, 2023, 4:43pm UTC](https://forum.juce.com/t/no-notification-of-failure-when-calling-purchaseproduct-without-internet-connection/55097/1 "2023-02-23T16:43:48Z")

</div>

Hi,

On iOS, if I call `InAppPurchases::purchaseProduct` while the internet connection is off, the purchase obviously fails but the `InAppPurchases::Listener` gets no notification. Here is a suggested change to `requestDidFailWithError` (not sure why it is not called on the message thread in that case, but I had to add a callAsync).

```auto
        } else if (auto productRequest = getAs<SKProductsRequest> (request)) {
            for (auto i = 0; i < pendingProductInfoRequests.size(); ++i)
            {
                auto& pendingRequest = *pendingProductInfoRequests[i];

                if (pendingRequest.request.get() == productRequest)
                {
                    MessageManager::callAsync([this]() {
                        owner.listeners.call ([&] (Listener& l) { l.purchasesListRestored ({}, false, NEEDS_TRANS ("Cannot connect to the App Store")); });}
                        );
                    pendingProductInfoRequests.remove (i);
                    return;
                }
            }
        }

```

(this code just mirrors the code that handles `SKReceiptRefreshRequest` errors).

UPDATE: it would probably be better to call `l.productPurchaseFinished` instead of `purchasesListRestored` when `pendingRequest.type == PendingProductInfoRequest::Type::purchase`.

---

<div class="post-metadata">

**Author:** ![reuk](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/reuk/32/21494_2.png) [@reuk](https://forum.juce.com/u/reuk)\
**Post date:** [March 2, 2023, 7:35pm UTC](https://forum.juce.com/t/no-notification-of-failure-when-calling-purchaseproduct-without-internet-connection/55097/2 "2023-03-02T19:35:17Z")

</div>

Thanks for raising this issue. I’ve pushed a fix here:

> <https://github.com/juce-framework/JUCE/commit/cb54044c1c8e1a0ecd5456246af2ef8b6fce0a2f>
