Repository: flutter
Issue: [in_app_purchase][iOS] Interrupted purchase flow is not working
Labels: platform-ios,p: in_app_purchase,package,has reproducible steps,P2,found in release: 3.0,found in release: 3.1,team-ios,triaged-ios

[The Apple documentation](https://developer.apple.com/documentation/storekit/in-app_purchase/testing_in-app_purchases_with_sandbox/testing_an_interrupted_purchase) states that an in-app purchase can be interrupted, for example because the user may need to update their payment method, or accept new Terms & Conditions before continuing with their transaction. That same page describes how to test an interrupted purchase.

Having followed the instructions on that page, the behaviour I'm seeing when testing an interrupted purchase with this plugin deviates from the expected behaviour described on said page. Specifically, after the purchase is initiated, a transaction with status `PurchaseStatus.pending` appears in the purchase stream, as I would expect (assuming that this state corresponds to the `SKPaymentTransactionState.purchasing` in step 4 on that page), but then, after authenticating the payment sheet, I do not receive any further transaction in the purchase stream. I would expect to see a transaction corresponding to `SKPaymentTransactionState.failed` in step 6.

Consequently, step 7 (removing said transaction by calling `completePurchase`/`finishTransaction`) does not get executed. In addition, in step 8, instead of being presented with a valid Terms & Conditions screen, a screen with the text "Cannot Connect" appears, with the only buttons available on it being "Retry" and "Cancel". It's unclear to me whether this secondary issue is a result of step 6 not behaving as expected, or whether it is an issue that would occur regardless (i.e. one that needs to be fixed by Apple).

## Steps to reproduce
I tested this on a device running iOS 15.3.1 (and made sure there were no connection problems).

Use this plugin to test the interrupted purchase behaviour described in [the Apple documentation](https://developer.apple.com/documentation/storekit/in-app_purchase/testing_in-app_purchases_with_sandbox/testing_an_interrupted_purchase), i.e.
1. On the test device, sign in with the Sandbox Apple ID that has interrupted purchases enabled
2. In the example plugin app, select Buy or Subscribe to make an in-app purchase (in my case, the product was a non-renewing subscription)
3. A payment sheet shows up; **don't authenticate it just yet**
4. Note that `InAppPurchase.instance.purchaseStream` now contains a transaction with status `PurchaseStatus.pending`, as expected
5. Proceed to authenticate the payment sheet

**Expected result**
After step 5, the aforementioned Apple documentation states that the payment should fail; I would therefore expect there to be a transaction with a state corresponding to `SKPaymentTransactionState.failed` in `InAppPurchase.instance.purchaseStream`.

**Actual result**
After step 5, no transaction (corresponding to `SKPaymentTransactionState.failed`) appears in `InAppPurchase.instance.purchaseStream`,  thus leaving the app in a "pending" state.

Furthermore, proceeding past step 5 by clicking "OK" in the prompt that appears (asking the user to read the new Terms & Conditions) results not in a valid Terms & Conditions screen, but rather a screen with the text "Cannot Connect", with the only buttons available on it being "Retry" and "Cancel". Pressing "Retry" does nothing, pressing "Cancel" closes the screen, but leaves the app displaying a constantly spinning loading indicator, reflecting the `PurchaseStatus.pending` state of the latest  transaction that appeared in `InAppPurchase.instance.purchaseStream`. Again, it's unclear to me whether this secondary issue is a result of step 6 not behaving as expected.