StoreKit Test

RSS for tag

Create and automate tests in Xcode for your app's submission and in-app purchase transactions.

Posts under StoreKit Test tag

70 Posts
Sort by:

Post

Replies

Boosts

Views

Activity

In-app Purchases not working correctly.
I have uploaded one of my app to give some paid service. But when the user tries to make an in-app purchase, it opens one screen like the title is "Apple ID, Almost there Payment request will be created for xyzdemo@ybl" After I press the continue button this window(Screen) closes automatically. But UPI requests are sent on the particular app. So why is this happening on my app? Why does this window (Screen) dismiss automatically? I have also attached the screen. This screen automatically dismissed.
2
0
490
Feb ’24
Sandbox Testing Problems (StoreKit works fine)
I have a problem with submitting my app to the AppStore. I have an app in the AppStore with currently OneTime Purchase. Now I want to add an InApp purchase to this app. I have tested the app with a local StoreKit file (with synchronised AppStore In App Products) and everything works fine. But when I submitted this file to the store, it was not accepted. So I found out that I need to remove the local StoreKit file so that it uses the real AppStore data. But my problem is, once I remove the StoreKit file, my purchase process gets stuck in the transaction process. So when I click on the in-app purchase button, I get the payment overlay and everything about the in-app purchase is displayed there. Name, price, details. Also a sandbox title says I am not in production. As soon as I click on the "Buy" button, I have to log in with my sandbox user account that I have previously created in AppStore connect and also verify the email address by clicking on the link in the e-mail. Then the confirmation tone sounds, but after 4-5 seconds the overlay appears again (and again and again). The transaction remains in "in progress" status. My question now, since everything worked fine with StoreKit? What could be the problem. I need to submit a new appVersion (which I am working on) with my first new in-app purchase. Could it be that the payment process is not working because the IAP is still in "under review" or "submitted for review"? Where could be a difference that StoreKit IAP works just fine, but sandbox does not work. Thanks in advance for your help.
1
0
531
Feb ’24
[Sandbox] Auto-renewable subscription available to purchase for regions that restricted in availability setting
I'm working on an application that will include auto-renewable subscription functionality. I'm trying to restrict a few products within a group by using the availability option, for example, only for the US. However, for a sandbox account with the Germany region, these restricted products are also available to fetch and purchase using StoreKit after providing their IDs through SKProductsRequest. I tried another scenario where I fetched only products from this group that are available for the sandbox account region in my app. However, after purchasing one of them, in iOS settings on the sandbox account management page, I see a subscription group with all subscriptions, including restricted ones. This means the user is able to purchase them from this page. Could you please advise on an efficient way to restrict my subscriptions per region? Or maybe this is only a sandbox issue because, according to the documentation, these subscriptions should not be available for restricted regions. Thanks in advance!
0
1
486
Feb ’24
Sandbox test user web payment
I have apple web payment integrated on website, and it work fine when i test it using real cards. I wanted to test it using apple TEST cards, so i invited SANDBOX test user from here https://appstoreconnect.apple.com/access/users/sandbox and logged in to test device using this test id. but it fails to start a merchant session. System.Net.Http.HttpRequestException: An error occurred while sending the request. ---> System.Net.WebException: The underlying connection was closed: An unexpected error occurred on a send. ---> System.IO.IOException: Authentication failed because the remote party has closed the transport stream. at System.Net.TlsStream.EndWrite(IAsyncResult asyncResult) at System.Net.ConnectStream.WriteHeadersCallback(IAsyncResult ar) --- End of inner exception stack trace --- at System.Net.HttpWebRequest.EndGetRequestStream(IAsyncResult asyncResult, TransportContext& context) at System.Net.Http.HttpClientHandler.GetRequestStreamCallback(IAsyncResult ar) --- End of inner exception stack trace --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Net.Http.HttpClient.d__58.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult() at Gateway.MobileWallet.Domain.ApplePay.Clients.RequestPaymentSession.ApplePayPaymentSessionClient.d__3.MoveNext() in
1
0
635
Jan ’24
StoreKit 2: Issue with Subscription Validation in Sandbox
I'm opening this post because I've encountered a perplexing issue in my application utilizing StoreKit 2 with the Sandbox environment for subscription validation. My app makes a server call each time it opens to verify if there's an active subscription. The problem arose after successfully making a purchase in the Sandbox. When I clear history from the Sandbox user and reopen the app, it resends a request to check the subscription, indicating that the user is still subscribed even though the purchases were deleted. Has anyone encountered a similar issue? if I testing it with transaction manager in Xcode it working well. ` func updatePurchasedProducts() async { for await result in Transaction.currentEntitlements { guard case .verified(let transaction) = result else { continue } if transaction.revocationDate == nil { self.purchasedProductIDs.insert(transaction.productID) print("# purchased") } else { self.purchasedProductIDs.remove(transaction.productID) print("# canceled") } } } Thank you very much!
0
0
545
Jan ’24
Beta testers have to keep subscribing to recurring subscriptions
I have an app that I distribute to beta testers via TestFlight. The app has auto-renewable subscriptions. In the sandbox environment the subscriptions expire at an accelerated rate; every hour. They renew up to 12 times. This means that my testers have to re-subscribe every 12 hours. Is there a way to make the sandbox operate at realtime for certain users?
0
0
509
Jan ’24
How to use Sandbox for IAP testing
Need some help here. I've got an iPhone 11 PM on 16.6.1 and I'm trying to test Family Sharing IAPs. However, I can't seem to test via the Sandbox environment (which I need to validate receipt handling for Family Sharing). The app is running locally on my device and was built straight from Xcode. When I tap to make a purchase in my app (which uses StoreKit2, if that makes any difference) a sheet pops up with a purchase button which, when tapped, immediately completes and I get the following dialog box: "Your purchase was successful" [Environment: Xcode] How do I get my app to use the Sandbox environment? All documentation suggestions when I tap my purchase button I should simply be presented with a login modal and then, after the purchase has completed, be able to see my Sandbox credentials under Settings -> App Store. At the moment no dialog is presented (the purchase completes immediately) and the entire "Sandbox Account" section is missing from Settings -> App Store. Any help will be greatly appreciated!
1
0
569
Jan ’24
SKAN not receiving postbacks correctly / wrong attribution to "direct"
SKAN / SkAdNetwork Error ERROR: We never received any http request from the "skan.ourdomain.com" as expected. ERROR: All the attributions(YES! ALL OF THE INSTALLS) in the Google Analytics / Singular / AppsFlyer / Twitter / Facebook, shows the source are "direct organic". We Did These We use Google Ads and Twitter Ads and Facebook Ads to promote our apps. We spent enough money, and got thousands of paid installs from these ads. We set the NSAdvertisingAttributionReportEndpoint to "skan.ourdomain.com". We call the SKAdNetwork.updatePostbackConversionValue(1). in "AppDelegate" and "Subscribe" source codes. And from our app logs, we see there are SKAN_UPDATE_CONVERSION_VALUE_OK. Source Code if #available(iOS 15.4, *) { SKAdNetwork.updatePostbackConversionValue(1) { err in if let err = err { Tracker.shared.reportEvent(.SKAN_UPDATE_CONVERSION_VALUE_FAIL, name: err.localizedDescription, value: 1) } else { Tracker.shared.reportEvent(.SKAN_UPDATE_CONVERSION_VALUE_OK) } } } else { SKAdNetwork.registerAppForAdNetworkAttribution() Tracker.shared.reporxtEvent( .SKAN_UPDATE_CONVERSION_VALUE_OLD_VERSION, name: "AppDelegate") }
0
1
637
Jan ’24
Can't change store kit renewal rate, stuck at every two seconds
I wrote a StoreKit unit test and set the renewal rate to .oneRenewalEveryTwoSeconds for the test session. But now my App expires and renews every two seconds when running normally, even though the StoreKit Configuration file is set to "Real Time." Changing it to anything else doesn't change the renewal rate. I've tried cleaning the build folder. If, however, I set my SKTestSession explicitly to .realTime and run the test again, then my app behaves. However, again, it doesn't matter what I set the Configuration Settings to. Anyone know where this information is stored?
0
0
474
Jan ’24
SKTestSession.buyProduct(identifier: options:) doesn't work in swift package
We are doing a Swift Package to manage our iap with storekit 2. This packages also contains the unit tests for the code. (as well as all the required files .storekit, certificate, ...) when calling SKTestSession.buyProduct(identifier: options:) we catch an error : Error Domain=SKErrorDomain Code=0 "(null)" Note when trying exactly the same code but in a project instead of a package that works perfectly. Any idea what could it be? The code is really simple : var testSession: SKTestSession! override func setUpWithError() throws { testSession = try SKTestSession(configurationFileNamed: "Products") } func testExample() async throws { do { let productID = "nonConsumable.crystal.tier1" try await testSession.buyProduct(identifier: productID) } catch { XCTFail("An error occured during purchase : \(error)") } } }
0
0
410
Jan ’24
How to exit `inBillingRetryPeriod` state in Storekit2
I'm currently testing subscriptions in Sandbox. In AppstoreConnect, I set a grace period of 3 days. I subscribed for a service which expired and now it's inBillingRetryPeriod state. I thought it had to do with my payment method. After updating my payment method, it still remains in that state. I checked Status.RenewalInfo's gracePeriodExpiration and expirationReason values but both produced nil. How do I exit the inBillingRetry state? I'm new to in-app purchases. Thanks. Here's the relevant code that updates subscription status: @MainActor func updateSubscriptionStatus() async { do { guard let product = storeManager.renewables.first, let statuses = try await product.subscription?.status else {return} var highestProduct: Product? = nil var highestStatus: Product.SubscriptionInfo.Status? = nil for status in statuses { switch status.state { case .expired, .revoked: continue default: let verifiedRenewalInfo = try storeManager.checkVerified(status.renewalInfo) //Find the first subscription in the store that matches id on the `status.renewalInfo` guard let newSubscription = storeManager.renewables.first(where: {$0.id == verifiedRenewalInfo.autoRenewPreference}) else { continue } guard let currentProduct = highestProduct else { highestProduct = newSubscription highestStatus = status // next status continue } let currentProductTier = storeManager.tierDuration(for: currentProduct.id) let newTier = storeManager.tierDuration(for: newSubscription.id) if newTier > currentProductTier { //updated product and status highestProduct = newSubscription highestStatus = status } } } currentSubscription = highestProduct // currentSubscription is an @State status = highestStatus // status is an @State if let mySubcriptionStatus = status, case .verified(let renewalInfo) = highestStatus?.renewalInfo { print(mySubcriptionStatus.state) // StoreKit.Product.SubscriptionInfo.RenewalState(rawValue: 3))-- inBillingRetry. print(renewalInfo.expirationReason) // nil print(renewalInfo.gracePeriodExpirationDate) // nil } } catch { print(error) } }
1
0
449
Jan ’24
Storekit2 debug: subscription doesn't exist and code still append a subscription??!! BUG??
I am really frustrated with storekit2, is it me or is it an Apple bug? the subscription doesn't exist LITERALLY and the code still append a subscription to my currentSubscriptions!! Unfortunatelly I cannot attach an image but the susbcrioption doesn't exist in the storekit debug window but the code still append a valid subscription! https://stackoverflow.com/questions/77783897/storekit2-subscription-is-not-existant-and-still-append-subscription-bug // update the customers products @MainActor func updateCustomerProductStatus() async { var purchasedSubs: [Product] = [] var purchasedIAP: [Product] = [] //iterate through all the user's purchased products for await result in Transaction.currentEntitlements { do { //again check if transaction is verified let transaction = try checkVerified(result) //Check the `productType` of the transaction and get the corresponding product from the store. switch transaction.productType { case .consumable: if let iap = iaps.first(where: { $0.id == transaction.productID }) { purchasedIAP.append(iap) } case .autoRenewable: if let subscription = subscriptions.first(where: { $0.id == transaction.productID }) { //SUBSCRIPTION DOESN'T EXIST AND STILL GETS APPENDED!! purchasedSubs.append(subscription) } default: break } } catch { //storekit has a transaction that fails verification, don't delvier content to the user print("Transaction failed verification") } //finally assign the purchased products self.purchasedIAPs = purchasedIAP self.purchasedSubscriptions = purchasedSubs } }
0
0
396
Jan ’24
Store Kit 2 not availiable in Sandbox environment
I have implemented Store Kit for my Swift UI App. I defined all products in app store connect (auto-renewables & non-renewables). I tested everything in Xcode and it seems to run fine. However i want to test it in Sandbox to be able to check the server side dependencies. After creating Sandbox users and logging in to those accounts on my physical device, i am still only able to do payments in Xcode ("[Environment: Xcode]"). I added the In-App Purchase Capability to my project in the Signing & Capability Targets and made sure the app runs in debug mode. So according to the docs (https://developer.apple.com/documentation/storekit/in-app_purchase/testing_in-app_purchases_with_sandbox) everything seems to be set-up.
1
0
455
Jan ’24
How to exit `inBillingRetryPeriod` state in Storekit2
I'm currently testing subscriptions in Sandbox. In AppstoreConnect, I set a grace period of 3 days. I subscribed for a service which expired and now it's inBillingRetryPeriod state. I thought it had to do with my payment method. After updating my payment method, it still remains in that state. I am checking Status.RenewalInfo's gracePeriodExpiration and expirationReason values produce nil. How do I exit the inBillingRetry state? I'm new to in-app purchases. Thanks. Here's the relevant code: ... @MainActor func updateSubscriptionStatus() async { do { guard let product = storeManager.renewables.first, let statuses = try await product.subscription?.status else {return} var highestProduct: Product? = nil var highestStatus: Product.SubscriptionInfo.Status? = nil for status in statuses { switch status.state { case .expired, .revoked: continue default: let verifiedRenewalInfo = try storeManager.checkVerified(status.renewalInfo) //Find the first subscription in the store that matches id on the `status.renewalInfo` guard let newSubscription = storeManager.renewables.first(where: {$0.id == verifiedRenewalInfo.autoRenewPreference}) else { continue } guard let currentProduct = highestProduct else { highestProduct = newSubscription highestStatus = status // next status continue } let currentProductTier = storeManager.tierDuration(for: currentProduct.id) let newTier = storeManager.tierDuration(for: newSubscription.id) if newTier > currentProductTier { //updated product and status highestProduct = newSubscription highestStatus = status } } } currentSubscription = highestProduct // currentSubscription is an @State status = highestStatus // status is an @State if let mySubcriptionStatus = status, case .verified(let renewalInfo) = highestStatus?.renewalInfo { print(mySubcriptionStatus.state) // StoreKit.Product.SubscriptionInfo.RenewalState(rawValue: 3) -- inBillingRetry print(renewalInfo.expirationReason) // nil print(renewalInfo.gracePeriodExpirationDate) // nil } } catch { print(error) } }
0
0
443
Dec ’23
Not receiving REFUND notifications in sandbox
Hi, I am following https://developer.apple.com/documentation/storekit/transaction/testing_refund_requests and trying to test refund requests. I am able to trigger refund requests from my app (in sandbox) using https://developer.apple.com/documentation/swiftui/view/refundrequestsheet(for:ispresented:ondismiss:) I do see that the notification URL receives a NotificationTypeV2.CONSUMPTION_REQUEST but it's not receiving NotificationTypeV2.REFUND The product for which the refund is triggered is a consumable type Is this expected behavior? How can I test REFUND without this? Thanks
4
0
705
Mar ’24
Use of SubscriptionStoreView
I am developing my first app and having issues understanding how SubscriptionStoreView works. I used some business logic available from Apple, but I see other resources that insinuate the StoreKit views can handle all of the business logic itself, and all I need is the config file. Can anyone confirm? When I'm previewing SubscriptionStoreView, It just says, "The subscription is unavailable in the current storefront," and I cannot find what that means or what to fix.
1
0
1k
Dec ’23
StoreKit test unable to test plan change scenario in iOS 17
I have a unit test case to test subscription plan change scenario, that is working until iOS 16, but the test failed starting iOS 17 and above. Test case setup: let session = try SKTestSession(configurationFileNamed: "IAPTestConfiguration") session.disableDialogs = true session.clearTransactions() // Buy a monthly subscription first try session.buyProduct(productIdentifier: "test.apple.test_mobile.1m") if let transaction = session.allTransactions().first { let id = transaction.identifier // and disable monthly subscription try session.disableAutoRenewForTransaction(identifier: id) } // buy a yearly subscription to create a subscription change scenario. try session.buyProduct(productIdentifier: "test.apple.test_mobile.1y")` Now this is the logic I have to determine that there is going to be a plan change: if let autoRenewPreference = renewalInfo.autoRenewPreference, autoRenewPreference != renewalInfo.currentProductID, renewalInfo.willAutoRenew { // means subscription change } until iOS 16, the above test setup resulted in : renewalInfo.autoRenewPreference = "test.apple.test_mobile.1y" renewalInfo.currentProductID = "test.apple.test_mobile.1m" renewalInfo.willAutoRenew = true But in iOS 17, the above setup seems to be not working because, the second time I try to buy a product seems to have no effect. // This has no effect, when there is already an active subscription, in our case "test.apple.test_mobile.1m" . try session.buyProduct(productIdentifier: "test.apple.test_mobile.1y") I expect there should be at least two transactions with my current setup, in iOS 16 I get 2 transactions when I query session.allTransactions() at the end, but in iOS 17 I only get 1 transaction, which is the first buyProduct, the last buyProduct seems to have no effect, as I do not get any callback in the SKPaymentQueue updateTransactions method for the last buyProduct call. In iOS 16, I get callbacks in SKPaymnetQueue for both buyProduct calls. I also tried to use async buyProduct in iOS 17, and updated my test case accordingly, but it resulted in the same behaviour. Please let me know if you need any other detail that could help sort this issue.
0
0
364
Dec ’23
Introductory offer does not appear for Sandbox testing
Hi, I currently have an introductory offer set up in App Store Connect, which is in the 'Ready to Submit' state. When testing with the StoreKit configuration testing for Xcode, the introductory offer appears correctly, and I can successfully make and cancel purchases. However, when testing on a device without the StoreKit configuration, using a new sandbox account, the introductory offer does not appear, though the introductory price is visible for subscription. Could you advise on how to ensure the introductory offer is displayed in this scenario? Using Storekit 2
2
0
650
Jan ’24