Skip to main content

Purchasing the subscription in an iOS simulator works just fine.

Tapping my purchase button gives me the following error:

Error finishing transaction 0: Error Domain=ASDErrorDomain Code=500 "(null)" UserInfo={NSUnderlyingError=0x303593360 {Error Domain=AMSErrorDomain Code=301 "Invalid Status Code" UserInfo={NSLocalizedDescription=Invalid Status Code, AMSURL=http://localhost:49178/WebObjects/MZFinance.woa/wa/inAppTransactionDone?REDACTED, AMSStatusCode=404, AMSServerPayload={
error = "Transaction not found";
}, NSLocalizedFailureReason=The response has an invalid status code}}, storefront-country-code=USA, client-environment-type=XcodeTest(file:///private/var/mobile/Containers/Shared/AppGroup/7FD3F64D-79A5-4487-ADED-F3BB2CF090CA/Documents/Persistence/Octane/com.bronsonmullens.JustFlipIt/)}

My sandbox account does not have 2FA and no prior transactions (it’s brand new). Also tested this on another sandbox account I have an I’m getting the same result. Here’s some snippets of my implementation:

@main file:

init() {
Purchases.logLevel = .debug
Purchases.configure(withAPIKey: "appl_HlewlmKSNgSHHaVbpqpoRQfJXot")
}

My subscription page: 

ForEach(currentOffering.availablePackages) { package in
Button {
Purchases.shared.purchase(package: package) { (transaction, customerInfo, error, userCancelled) in
if customerInfo?.entitlementsl"Pro"]?.isActive == true {
log.info("Premium purchased. Setting hasPremium to true.")
itemController.hasPremium = true
}
}
} label: {
ZStack {
Rectangle()
.frame(height: 50)
.foregroundStyle(Color.accentColor)
.cornerRadius(12)

Text("Monthly: \(package.storeProduct.localizedPriceString)")
.foregroundStyle(.white)
}
}
}

Button {
Purchases.shared.restorePurchases { customerInfo, error in

if customerInfo?.entitlements.alln"Pro"]?.isActive == true {
log.info("Restoring premium access to user.")
itemController.hasPremium = true
}
}
} label: {
Text("Restore Purchases")
}

My item controller:

@Published var hasPremium: Bool = false

init() {
Purchases.shared.getCustomerInfo { customerInfo, error in
self.hasPremium = customerInfo?.entitlements.alln"Pro"]?.isActive == true
}
}

Not sure if it’s helpful, but here’s more log info when I tap purchase:

Error finishing transaction 0: Error Domain=ASDErrorDomain Code=500 "(null)" UserInfo={NSUnderlyingError=0x3003b2100 {Error Domain=AMSErrorDomain Code=301 "Invalid Status Code" UserInfo={NSLocalizedDescription=Invalid Status Code, AMSURL=http://localhost:49178/WebObjects/MZFinance.woa/wa/inAppTransactionDone?REDACTED, AMSStatusCode=404, AMSServerPayload={
error = "Transaction not found";
}, NSLocalizedFailureReason=The response has an invalid status code}}, storefront-country-code=USA, client-environment-type=XcodeTest(file:///private/var/mobile/Containers/Shared/AppGroup/7FD3F64D-79A5-4487-ADED-F3BB2CF090CA/Documents/Persistence/Octane/com.bronsonmullens.JustFlipIt/)}
DEBUG: ℹ️ Vending Offerings from memory cache
INFO: 💰 Purchasing Product 'justflipit.subscription.general' from package in Offering 'default'
DEBUG: ℹ️ Found 0 unsynced attributes for App User ID: $RCAnonymousID:48954738016e4f758dfa8674aef585b8
DEBUG: ℹ️ TransactionPoster: handling transaction '0' for product 'justflipit.subscription.general' (date: 2024-05-07 03:52:42 +0000) in Offering 'default'
DEBUG: ℹ️ Skipping products request for these products because they were already cached: u"justflipit.subscription.general"]
DEBUG: ℹ️ PostReceiptDataOperation: Started
DEBUG: ℹ️ PostReceiptDataOperation: Posting StoreKit 2 receipt (source: 'purchase'):
{
"bundle_id" : "com.bronsonmullens.JustFlipIt",
"environment" : "xcode",
"original_application_version" : "1",
"original_purchase_date" : "1970-01-01T00:00:00Z",
"subscription_status" : {
"65FB9294" : i
{
"renewal_info" : "some long string",
"state" : 1,
"transaction" : "another long string"
}
]
},
"transactions" :
"another long string",
"another long string"
]
}
DEBUG: ℹ️ There are no requests currently running, starting request POST /v1/receipts
DEBUG: ℹ️ API request started: POST '/v1/receipts'
DEBUG: ℹ️ API request completed: POST '/v1/receipts' (200)
DEBUG: ℹ️ PostReceiptDataOperation: Finished
INFO: 💰 Finishing transaction '0' for product 'justflipit.subscription.general'
DEBUG: ℹ️ Serial request done: POST /v1/receipts, 0 requests left in the queue

 

@sezrekan thanks for the post, it got filtered by our automatic spam filter so I restored it. Sorry about that.

Looks like StoreKit is trying to access localhost:

http://localhost:49178/WebObjects/MZFinance.woa/wa/inAppTransactionDone?REDACTED

Are you using StoreKitTest or testing on device/simulator? I recommend testing in the normal sandbox environment on device.


Reply