Domain=NSURLErrorDomain Code=-1202 "The certificate for this server is invalid. You may be connecting to a server masquerading as a "auth-sandbox.itunes.apple.com", which threatens the security of your confidential information. "
StoreKit
RSS for tagSupport in-app purchases and interactions with the App Store using StoreKit.
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
Received error that does not have a corresponding StoreKit Error: Error Domain=AMSErrorDomain Code=305 "Purchase Failed Server canceled the purchase
More details:
Error Domain=AMSErrorDomain Code=305 "Purchase Failed Server canceled the purchase" UserInfo={AMSFailureReason=Server canceled the purchase, AMSURL=https://sandbox.itunes.apple.com/WebObjects/MZBuy.woa/wa/inAppBuy?guid=00008110-000A4DC10E51401E, AMSDescription=Purchase Failed, AMSStatusCode=200, AMSServerPayload={
"cancel-purchase-batch" = 1;
customerMessage = "Unable to process your request.";
dialog = {
defaultButton = ok;
explanation = "Please try again later.\n\n[Environment: Sandbox]";
initialCheckboxValue = 1;
isFree = 1;
"m-allowed" = 0;
message = "Unable to process your request.";
okButtonString = OK;
};
failureType = "";
"m-allowed" = 0;
metrics = {
actionUrl = "sandbox.itunes.apple.com/WebObjects/MZBuy.woa/wa/inAppBuy";
asnState = 0;
dialogId = "MZCommerce.SystemError";
eventType = dialog;
message = "Unable to process your re";
mtEventTime = "2025-07-28 12:34:22 Etc/GMT";
mtTopic = "xp_its_main";
options = (
OK
);
};
pings = (
);
}, NSDebugDescription=Purchase Failed Server canceled the purchase}
Received error that does not have a corresponding StoreKit Error: Error Domain=ASDErrorDomain Code=500 "(null)" UserInfo={client-environment-type=Sandbox, storefront-country-code=IND, NSUnderlyingError=0x1276116e0 {Error Domain=AMSErrorDomain Code=305 "Purchase Failed Server canceled the purchase" UserInfo={AMSFailureReason=Server canceled the purchase, AMSURL=https://sandbox.itunes.apple.com/WebObjects/MZBuy.woa/wa/inAppBuy?guid=00008110-000A4DC10E51401E, AMSDescription=Purchase Failed, AMSStatusCode=200, AMSServerPayload={
"cancel-purchase-batch" = 1;
customerMessage = "Unable to process your request.";
dialog = {
defaultButton = ok;
explanation = "Please try again later.\n\n[Environment: Sandbox]";
initialCheckboxValue = 1;
isFree = 1;
"m-allowed" = 0;
message = "Unable to process your request.";
okButtonString = OK;
};
failureType = "";
"m-allowed" = 0;
metrics = {
actionUrl = "sandbox.itunes.apple.com/WebObjects/MZBuy.woa/wa/inAppBuy";
asnState = 0;
dialogId = "MZCommerce.SystemError";
eventType = dialog;
message = "Unable to process your re";
mtEventTime = "2025-07-28 12:34:22 Etc/GMT";
mtTopic = "xp_its_main";
options = (
OK
);
};
pings = (
);
}, NSDebugDescription=Purchase Failed Server canceled the purchase}}}
Purchase did not return a transaction: Error Domain=ASDErrorDomain Code=500 "(null)" UserInfo={client-environment-type=Sandbox, storefront-country-code=IND, NSUnderlyingError=0x1276116e0 {Error Domain=AMSErrorDomain Code=305 "Purchase Failed Server canceled the purchase" UserInfo={AMSFailureReason=Server canceled the purchase, AMSURL=https://sandbox.itunes.apple.com/WebObjects/MZBuy.woa/wa/inAppBuy?guid=00008110-000A4DC10E51401E, AMSDescription=Purchase Failed, AMSStatusCode=200, AMSServerPayload={
"cancel-purchase-batch" = 1;
customerMessage = "Unable to process your request.";
dialog = {
defaultButton = ok;
explanation = "Please try again later.\n\n[Environment: Sandbox]";
initialCheckboxValue = 1;
isFree = 1;
"m-allowed" = 0;
message = "Unable to process your request.";
okButtonString = OK;
};
failureType = "";
"m-allowed" = 0;
metrics = {
actionUrl = "sandbox.itunes.apple.com/WebObjects/MZBuy.woa/wa/inAppBuy";
asnState = 0;
dialogId = "MZCommerce.SystemError";
eventType = dialog;
message = "Unable to process your re";
mtEventTime = "2025-07-28 12:34:22 Etc/GMT";
mtTopic = "xp_its_main";
options = (
OK
);
};
pings = (
);
}, NSDebugDescription=Purchase Failed Server canceled the purchase}}}
Topic:
App & System Services
SubTopic:
StoreKit
Tags:
Subscriptions
StoreKit Test
StoreKit
In-App Purchase
I'm receiving the following error when attempting to validate an in‑app purchase receipt:
Certificate verification failed at depth 0 : forge.pki.UnknownCertificateAuthority
Certificate chain validation failed: Certificate is not trusted.
This error occurs during the certificate chain validation process of the receipt's PKCS#7 container. My implementation uses node‑forge to decode the receipt, extract the embedded certificate chain, and verify that the chain properly links from the leaf certificate (which directly signed the receipt) through the intermediate certificate to the trusted Apple Inc. Root certificate.
What the Error Indicates:
"UnknownCertificateAuthority" at depth 0:
This suggests that the leaf certificate in the receipt is not being recognized as part of a valid chain because it cannot be linked back to a trusted root in my CA store.
"Certificate chain validation failed: Certificate is not trusted":
This means that the entire certificate chain does not chain up to a trusted certificate authority (in this case, the Apple Inc. Root certificate) as expected.
Steps Taken:
I verified that the receipt is a valid PKCS#7 container.
I extracted the certificate chain from the receipt. However, the receipt only provided the leaf certificate.
I manually added the intermediate certificate (AppleWWDRCAG5.pem) to complete the chain.
I loaded the official Apple Inc. Root certificate (AppleIncRootCertificate.pem) into my CA store.
Despite these steps, the validation still fails at depth 0, indicating that the leaf certificate is not recognized as being issued by a trusted authority.
Request for Assistance:
Could you please help clarify the following points:
Is the certificate chain for receipts (leaf → intermediate → Apple Inc. Root) as expected, or has there been any change in the chain that I should account for?
Is there a recommended or updated intermediate certificate I should be using for receipt validation?
Are there known issues or recent changes on Apple's side that might cause the leaf certificate to not be recognized as part of a valid chain?
Any guidance to resolve this certificate chain validation error would be greatly appreciated.
I have an auto-renewable subscription. I have two methods helping me keep track of when they are expired
@MainActor public func isPurchased(product: Product) async -> Bool {
guard let state = await product.currentEntitlement else {
return false
}
switch state {
case .unverified(_, _):
return false
case .verified(let transaction):
await transaction.finish()
return isTransactionRelevant(transaction)
}
}
private func isTransactionRelevant(_ transaction: Transaction) -> Bool {
if let revocationDate = transaction.revocationDate {
logger.error("Transaction verification failed: Transaction was revoked on \(revocationDate)")
return false
}
if let expirationDate = transaction.expirationDate,
expirationDate < Date()
{
logger.error("Transaction verification failed: Transaction expired on \(expirationDate)")
return false
}
if transaction.isUpgraded {
logger.error("Transaction verification failed: Transaction was upgraded")
return false
}
logger.info("Transaction verification succeeded")
return true
}
I also have this that I can call to get the latest state of purchases
@MainActor public func updateStoreKitSubscriptionStatus() async {
var currentProductsPurchased: [Product] = []
for await result in Transaction.currentEntitlements {
if case .verified(let transaction) = result {
if isTransactionRelevant(transaction) {
if let product = products.first(
where: { $0.id == transaction.productID
})
{
currentProductsPurchased.append(product)
}
}
await transaction.finish()
}
}
self.purchasedProducts = currentProductsPurchased
}
Right now when a subscription expires the user needs to manually do some action that triggers updateStoreKitSubscriptionStatus() as it appears that expirations do not come through in Transaction.updates.
I am surprised there does not seem to be a better way. Does StoreKit not notify you somewhere that an auto-renewable subscription has expired? Can you observe it in an ObservableObject? Or do I need to just frequently poll Transaction.currentEntitlements even if I dont expect frequent updates?
Topic:
App & System Services
SubTopic:
StoreKit
I ran into a problem. When using Storekit1 to purchase an SKU, the user payment was successful, but StoreKit1 did return paymentCancelled to my App. I would like to know under what circumstances this problem may occur? How do I fix it? Thank you
I have created a Python app and built it with pyinstaller and codesigned everything. Now I want to Sandbox test it. In my appstore connect account i have created a subscriptions id. I read that if I am logged out from the AppStore and have codesigned my .app file with a Developer Certificate i should be able to run the app on my local mac and when i click on the "Buy" button it should connect to my app store connect setup. I have implemented StoreKit in my app and use a storekit_bridge to combine the .swift code with my python app.
However when i run the app. I get this: "25-07-24 21:01:12,557 - FEC - WARNING - StoreKit: fetchProducts returned empty result
2025-07-24 21:01:12,557 - FEC - INFO - StoreKit fetch_products returned: {"products": []}
2025-07-24 21:01:12,557 - FEC - ERROR - StoreKit: Failed to parse product info: No products returned from JSON"
And no login screen appears where I should be able to enter my Sandbox email adress and password.
Anyone here who has experience with a Python app combined with In App Purchases? Hope someone can help me out with this.
users download app with Streamlined Purchasing ,but the logic of checking subscription doesn't work. there the code:
func checkSubscriptionStatus() async {
for await entitlement in Transaction.currentEntitlements {
guard case .verified(let transaction) = entitlement else { continue }
if transaction.productID == monthlyProductID || transaction.productID == yearlyProductID {
if transaction.revocationDate == nil && !transaction.isUpgraded {
let activeSubscribed = transaction.expirationDate ?? .distantFuture > .now
if activeSubscribed {
hasActiveSubscription = activeSubscribed
// other operation
}
}
}
}
}
Hey everyone,
This might be a simple fix that I’m just overlooking, but I’ve been stuck on it for the past 48 hours.
The issue is on my subscription screen — after a user completes a successful in-app purchase, the app doesn’t navigate to the main app like it’s supposed to. I’ve added logs, tried various fixes, and even asked AI for help, but nothing has worked.
From what I can tell, it seems like my listeners aren’t being registered properly after the transaction. I’ve tried reinitializing them, moving them around, and testing different flows, but still no luck.
If anyone has insight into how they’ve set this up or any suggestions I might not have considered, I’d really appreciate it.
Thanks in advance!
We use Transaction.currentEntitlements in StokeKit 2 to unlock functionality based on a Non-Consumable IAP but we have a case involving a refund that seems wrong and I am trying to understand the interation between transactionId, originalTransactionId & revocationReason.
The Context:
We have a universal App on macOS and iOS that offers a shared Non-Consumable IAP. For this example I have named it "app.lifetime"
On macOS we use StoreKit 2 and I am calling the Transaction.currentEntitlements and Transaction.all functions.
On iOS we are still using StoreKit 1.
This example customer:
Originally purchased "app.lifetime" on 2024-10-27
Was refunded by Apple for "app.lifetime" on 2024-10-29
Re-purchased "app.lifetime on 2025-02-24 (I have seen an email receipt of this transaction but it never shows up in Transaction data)
(all the above happened on the mac via StoreKit 2)
The Transactions (all lightly redacted for privacy):
on macOS the following is returned from Transaction.currentEntitlements...
{
"appTransactionId" : "...8123",
"bundleId" : "app",
"currency" : "USD",
"deviceVerification" : "...",
"deviceVerificationNonce" : "...",
"environment" : "Production",
"inAppOwnershipType" : "PURCHASED",
"originalPurchaseDate" : 1729997808000,
"originalTransactionId" : "...9955",
"price" : 1,
"productId" : "app.lifetime",
"purchaseDate" : 1729997808000,
"quantity" : 1,
"signedDate" : 1740416289102,
"storefront" : "USA",
"storefrontId" : "143441",
"transactionId" : "...7511",
"transactionReason" : "PURCHASE",
"type" : "Non-Consumable"
}
Note in the above example the originalTransactionId & transactionId are different. Transaction.all however returns both transactions:
[
{
"appTransactionId" : "...8123",
"bundleId" : "app",
"currency" : "USD",
"deviceVerification" : "...",
"deviceVerificationNonce" : "...",
"environment" : "Production",
"inAppOwnershipType" : "PURCHASED",
"originalPurchaseDate" : 1729997808000,
"originalTransactionId" : "...9955",
"price" : 1,
"productId" : "app.lifetime",
"purchaseDate" : 1729997808000,
"quantity" : 1,
"revocationDate" : 1730224102000,
"revocationReason" : 0,
"signedDate" : 1740415969925,
"storefront" : "USA",
"storefrontId" : "143441",
"transactionId" : "...9955",
"transactionReason" : "PURCHASE",
"type" : "Non-Consumable"
},
{
"appTransactionId" : "...8123",
"bundleId" : "app",
"currency" : "USD",
"deviceVerification" : "...",
"deviceVerificationNonce" : "...",
"environment" : "Production",
"inAppOwnershipType" : "PURCHASED",
"originalPurchaseDate" : 1729997808000,
"originalTransactionId" : "...9955",
"price" : 1,
"productId" : "app.lifetime",
"purchaseDate" : 1729997808000,
"quantity" : 1,
"signedDate" : 1740416289102,
"storefront" : "USA",
"storefrontId" : "143441",
"transactionId" : "...7511",
"transactionReason" : "PURCHASE",
"type" : "Non-Consumable"
}
]
Note here that the original transaction ("...9955") includes a revocationDate and revocationReason that match the expected refund but the secondary transaction that seems to match on all other details is missing the revocation info.
Looking at the iOS SK1 receipt data to compare, after a receipt refresh I see only a single transaction "...9955" which includes the cancellation info and transaction "...7511" is not present at all. The impact of this is that on iOS we are considering the purchase void but on macOS we are following currentEntitlements and consdering it still valid.
Calling the inApps/v1/history/... server API with the "...7511" transactionId that is shown in the currentEntitlements response returns the "...9955" transaction with the correct revocation status but "...7511" is no returned at all.
To Summarise:
currentEntitlements on macOS shows transaction "...7511" as active and with an originalTransactionId of "...9955"
all on macOS includes both "...7511" as active and "...9955" as revoked
iOS reciept data shows only "...9955" as revoked
Server API shows only "...9955" as revoked event when explicitly called with "...7511"
Neither of them show a more recent purchase the same customer made for the same IAP product.
My questions are:
Is this a StoreKit bug or am I mis-understanding something? If it's a bug how can I work around it to ensure revoked purchases aren't still appearing in currentEntitlements?
Under what conditions can StoreKit generate multiple transactionIds for the same underlying originalTransactionId? I had assumed (and the docs suggest) this only happens for subscriptions but here it is happening for a Non-Consumable IAP.
Why would transactionId "...7511" only be present on macOS/SK2 and not visible at all on iOS/SK1 or API?
I don't understand why the latest IAP from 2025-02-24 that the customer assures me they made (and has shown me the receipt for is not showing up in the Transactions history at all. Any ideas?
Dear Apple Support,
We are currently in the process of migrating from Apple Server Notifications v1 to v2. As you know, once we switch from v1 to v2 in App Store Connect, this change is irreversible. Our team needs to ensure that our backend environment, developed in Python with Django and using the app-store-server-library==1.5.0, is fully prepared to handle all possible notification types before making that final switch.
While we can receive a basic test notification from Apple, it doesn’t provide the range of data or scenarios (e.g., INITIAL_BUY, RENEWAL, GRACE_PERIOD, etc.) that our code must be able to process, store in our database, and respond to accordingly. Without comprehensive, example-rich raw notification data, we are left guessing the structure and full scope of incoming v2 notifications.
Could you please provide us with a set of raw, fully representative notification payloads for every notification type supported in v2? With these examples, we can simulate the entire lifecycle of subscription events, verify our logic, and confidently complete our migration.
Thank you very much for your assistance.
User Initiated a Single Consumable Purchase but Was Charged Twice
A user initiated a single in-app purchase for a consumable item, but they were charged twice. Both transactions have the same purchase token.
Additional details: After the user successfully completed the in-app purchase, the completeTransactions callback was triggered again. This was called at app launch using SwiftyStoreKit.completeTransactions to finish any pending transactions.
Could this be causing the duplicate charge? Any insights would be appreciated.
After I configured a consumable subscription(In App Purchases) on the apple platform, when I change the price in the App's server, is there any existing apple Api support to change the price on the apple platform? Of course, I know I need to resubmit.
Hi,
I have developed an app which has two in-app purchase subscriptions. During the test, the app can successfully get the status of the subscriptions. After it's released, I downloaded it from app store and subscribed it with my apple account. I found that in most cases, the app can identify that I have subscribed it and I can use its all functions. But yesterday, when I launched it again, it showed the warning that I haven't subscribed it. I checked my subscription in my account and the subscription status hasn't been changed, that is, I have subscribed it. And after one hour, I launched it again. This time the app identified that I have subscribed it. Why? The following is the code about listening to the subscription status. Is there any wrong about it?
HomeView()
.onAppear(){
Task {
await getSubscriptionStatus()
}
}
func getSubscriptionStatus() async {
var storeProducts = [Product]()
do {
let productIds = ["6740017137","6740017138"]
storeProducts = try await Product.products(for: productIds)
} catch {
print("Failed product request: \(error)")
}
guard let subscription1 = storeProducts.first?.subscription else {
// Not a subscription
return
}
do {
let statuses = try await subscription1.status
for status in statuses {
let info = try checkVerified(status.renewalInfo)
switch status.state {
case .subscribed:
if info.willAutoRenew {
purchaseStatus1 = true
debugPrint("getSubscriptionStatus user subscription is active.")
} else {
purchaseStatus1 = false
debugPrint("getSubscriptionStatus user subscription is expiring.")
}
case .inBillingRetryPeriod:
debugPrint("getSubscriptionStatus user subscription is in billing retry period.")
purchaseStatus1 = false
case .inGracePeriod:
debugPrint("getSubscriptionStatus user subscription is in grace period.")
purchaseStatus1 = false
case .expired:
debugPrint("getSubscriptionStatus user subscription is expired.")
purchaseStatus1 = false
case .revoked:
debugPrint("getSubscriptionStatus user subscription was revoked.")
purchaseStatus1 = false
default:
fatalError("getSubscriptionStatus WARNING STATE NOT CONSIDERED.")
}
}
} catch {
// do nothing
}
guard let subscription2 = storeProducts.last?.subscription else {
// Not a subscription
return
}
do {
let statuses = try await subscription2.status
for status in statuses {
let info = try checkVerified(status.renewalInfo)
switch status.state {
case .subscribed:
if info.willAutoRenew {
purchaseStatus2 = true
debugPrint("getSubscriptionStatus user subscription is active.")
} else {
purchaseStatus2 = false
debugPrint("getSubscriptionStatus user subscription is expiring.")
}
case .inBillingRetryPeriod:
debugPrint("getSubscriptionStatus user subscription is in billing retry period.")
purchaseStatus2 = false
case .inGracePeriod:
debugPrint("getSubscriptionStatus user subscription is in grace period.")
purchaseStatus2 = false
case .expired:
debugPrint("getSubscriptionStatus user subscription is expired.")
purchaseStatus2 = false
case .revoked:
debugPrint("getSubscriptionStatus user subscription was revoked.")
purchaseStatus2 = false
default:
fatalError("getSubscriptionStatus WARNING STATE NOT CONSIDERED.")
}
}
} catch {
// do nothing
}
if purchaseStatus1 == true || purchaseStatus2 == true {
purchaseStatus = true
} else if purchaseStatus1 == false && purchaseStatus2 == false {
purchaseStatus = false
}
return
}
Topic:
App & System Services
SubTopic:
StoreKit
In the sandbox environment, when I quickly and repeatedly purchase an item, Transaction.id will be repeated.
Will there be duplication in the production environment?
func pay(productId: String, orderId: String) async {
guard !productId.isEmpty, !orderId.isEmpty else { return }
let orderObj = ApplePayOrderModel.init(orderId: orderId, productId: productId)
do {
let result = try await Product.products(for: [productId])
guard let product = result.first else {
return
}
let purchaseResult = try await product.purchase()
switch purchaseResult {
case .success(let verification):
switch verification {
case .verified(let transaction):
orderObj.transactionId = String(transaction.id)
await transaction.finish()
case .unverified(let transaction, let error):
await transaction.finish()
}
case .userCancelled:
break
case .pending:
break
@unknown default:
break
}
} catch {
print("error \(error.localizedDescription)")
}
}
Topic:
App & System Services
SubTopic:
StoreKit
I am using StoreKit 2 for my products and noticed that users from Ukraine (for example) receive a wrong Product.displayPrice.
The App Store works with USD but shows the local currency UAH.
Any chance to display the correct currency (USD)?
Topic:
App & System Services
SubTopic:
StoreKit
Hello Apple Developer Team,
We're experiencing consistent IAP approval rejections under Guideline 2.1, despite successful TestFlight verification. Here's our detailed situation:
Environment
StoreKit 1 implementation
Tested on iOS 18.5 or 18.6 devices
Sandbox environment works perfectly
Verification Steps Taken
✅ Confirmed all Product IDs match App Store Connect exactly
✅ Validated 10+ successful TestFlight transactions (attached screenshot samples)
✅ Verified banking/tax agreements are active
Objective-C Code (StoreKit1 Implementation)
- (void)buyProductId:(NSString *)pid AndSetGameOrderID:(NSString *)orderID{
if([SKPaymentQueue canMakePayments]){
if (!hasAddObserver) {
[[SKPaymentQueue defaultQueue] addTransactionObserver:_neo];
hasAddObserver = YES;
}
self.neoOrderID = orderID;
[[NSUserDefaults standardUserDefaults] setValue:orderID forKey:Pay_OrderId_Key];
self.productID = pid;
NSArray * product = [[NSArray alloc]initWithObjects:self.productID, nil];
NSSet * nsset = [NSSet setWithArray:product];
SKProductsRequest * request = [[SKProductsRequest alloc]initWithProductIdentifiers:nsset];
request.delegate = self;
[request start];
}else{
NSString * Err = @"Pembelian tidak diizinkan. Silakan aktifkan perizinan di pengaturan";
// UnitySendMessage("GameManager", "IAPPurchaseFailed", [Err UTF8String]);
return;
}
}
- (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response
{
NSArray * product = response.products;
if ([product count] == 0)
{
[[SKPaymentQueue defaultQueue]removeTransactionObserver:_neo];
hasAddObserver = NO;
NSString * Err = [NSString stringWithFormat:@"Err = 01, Item tidak ditemukan %@",self.productID];
// UnitySendMessage("GameManager", "IAPPurchaseFailed", [Err UTF8String]);
return;
}
SKProduct * p = nil;
for (SKProduct * pro in product)
{
if ([pro.productIdentifier isEqualToString:self.productID]){
p = pro;
}else{
[request cancel];
[[SKPaymentQueue defaultQueue]removeTransactionObserver:_neo];
hasAddObserver = NO;
NSString * Err = [NSString stringWithFormat:@"Err = 02, %@",self.productID];
// UnitySendMessage("GameManager", "IAPPurchaseFailed", [Err UTF8String]);
return;
}
}
SKMutablePayment * mPayment = [SKMutablePayment paymentWithProduct:p];
mPayment.applicationUsername = [NSString stringWithFormat:@"%@",self.neoOrderID];
if(!hasAddObserver){
[[SKPaymentQueue defaultQueue] addTransactionObserver:_neo];
hasAddObserver = YES;
}
[[SKPaymentQueue defaultQueue] addPayment:mPayment];
}
- (void)request:(SKRequest *)request didFailWithError:(NSError *)error{
[[SKPaymentQueue defaultQueue]removeTransactionObserver:_neo];
hasAddObserver = NO;
NSString * Err = [NSString stringWithFormat:@"Err = 0%ld %@", (long)error.code, self.productID];
// UnitySendMessage("GameManager", "IAPPurchaseFailed", [Err UTF8String]);
}
- (void)requestDidFinish:(SKRequest *)request{
}
- (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transaction{
for(SKPaymentTransaction *tran in transaction){
if (SKPaymentTransactionStatePurchased == tran.transactionState){
[self completeTransaction:tran];
}else if(SKPaymentTransactionStateFailed == tran.transactionState){
[self failedTransaction:tran];
}
}
}
- (void)failedTransaction: (SKPaymentTransaction *)transaction
{
NSString * detail = [NSString stringWithFormat:@"%ld",(long)transaction.error.code];
// UnitySendMessage("GameManager", "IAPPurchaseFailed", [detail UTF8String]);
[[SKPaymentQueue defaultQueue]removeTransactionObserver:_neo];
hasAddObserver = NO;
[[SKPaymentQueue defaultQueue] finishTransaction: transaction];
}
- (void)completeTransaction:(SKPaymentTransaction *)transaction{
NSMutableDictionary * mdic = [NSMutableDictionary dictionary];
NSString * productIdentifier = transaction.payment.productIdentifier;
NSData * _recep = nil;
NSString * _receipt = @"";
if (floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_6_1) {
_recep = transaction.transactionReceipt;
_receipt = [[NSString alloc]initWithData:_recep encoding:NSUTF8StringEncoding];
} else {
_recep = [NSData dataWithContentsOfURL:[[NSBundle mainBundle] appStoreReceiptURL]];
_receipt = [_recep base64EncodedStringWithOptions:NSDataBase64EncodingEndLineWithLineFeed];
}
NSString * gameOrderid = [transaction payment].applicationUsername;
if (gameOrderid == nil) {
gameOrderid = [[NSUserDefaults standardUserDefaults] objectForKey:Pay_OrderId_Key];
}
if(_receipt != nil && gameOrderid != nil){
mdic[@"orderid"] = gameOrderid;
mdic[@"productid"] = productIdentifier;
mdic[@"receipt"] = _receipt;
}else{
[[SKPaymentQueue defaultQueue] finishTransaction:transaction];
return;
}
NSData * data = [NSJSONSerialization dataWithJSONObject:mdic options:kNilOptions error:nil];
NSString * jsonString = [[NSString alloc]initWithData:data encoding:NSUTF8StringEncoding];
if (hasAddObserver) {
[[SKPaymentQueue defaultQueue] removeTransactionObserver:_neo];
hasAddObserver = NO;
}
// UnitySendMessage("GameManager", "IAPPurchaseSuecess", [jsonString UTF8String]);
[self verifyReceipt:_recep completion:^(BOOL success, NSDictionary *response) {
if (success) {
NSLog(@"verify success");
// [[SKPaymentQueue defaultQueue] finishTransaction:transaction];
[self verifySuecessDelTransactions];
}
}];
}
- (void)paymentQueueRestoreCompletedTransactionsFinished:(SKPaymentQueue *)queue {
for(SKPaymentTransaction *tran in queue.transactions){
if (SKPaymentTransactionStatePurchased == tran.transactionState){
[self completeTransaction:tran];
}
}
}
- (void)verifySuecessDelTransactions{
SKPaymentQueue *paymentQueue = [SKPaymentQueue defaultQueue];
NSArray<SKPaymentTransaction *> *transactions = paymentQueue.transactions;
if (transactions.count == 0) {
return;
}
for (SKPaymentTransaction *transaction in transactions) {
if (transaction.transactionState == SKPaymentTransactionStatePurchased ||
transaction.transactionState == SKPaymentTransactionStateRestored) {
[paymentQueue finishTransaction:transaction];
}
}
}
The app subscription function uses StoreKit. After canceling the subscription, I try to subscribe again and get the following error. I remember it was working fine before iOS 18 was released.
{
NSLocalizedDescription = "\U53d1\U751f\U672a\U77e5\U9519\U8bef";
NSUnderlyingError = "Error Domain=ASDErrorDomain Code=825 "(null)"";
}
Hope you can help me solve this problem as soon as possible. Thanks
I'm trying to understand the IAP development process. I created my first Product on App Store Connect and am trying to build my app to use it. However it keeps failing with "Invalid product ID.". From what I've read, this is because the product has not yet gone through review. But what I don't understand is, of course it hasn't gone through review yet, because trying to use it in any capacity fails, even though I'm using a real physical device and using a Sandbox User. Is this the correct workflow? It seems very backwards that I have to submit the product for review, even before I know how it's going to be used. I'm still building the screen for the product page, and haven't even started touching any backend APIs, yet it's asking for screenshots. Am I misunderstanding something here?
Hi all,
I have a simple prototype subscription for a recurring monthly for $0.29 cheap!
And it works great!
But it only works great at sub time. It's stuck in the sandbox, constantly giving me "currently subscribed" status even though I’ve done a bunch of things:
Force-quit the app.
Deleted and re-installed it.
Rebooted my phone.
Signed out of media purchases.
Looked on AppStore connect to try to find anything that seems like it’d let me fix this
All efforts in vain.
I'm trying to avoid fully logging out of my iCloud account on my phone. Any other thoughts?
Topic:
App & System Services
SubTopic:
StoreKit
I try to access the AppDistributor.current (using try await) and the property never seem to return nor throw.
The code I'm using looks like this:
do {
print("accessing current")
let current = try await AppDistributor.current
print("current obtained")
switch(current) {
case .appStore:
return "AppStore"
default:
return "Unknown"
}
} catch {
return "Exception: \(error)"
}
But the log only shows the accessing current and never the current obtained. Trying to step in the property starts with some assembly, but at some point, the debugger just never returned. I join a full Swift file of a sample test I'm using:
SwiftMarketplaceTests.swift
Topic:
App & System Services
SubTopic:
StoreKit