gpt4 book ai didi

ios - 生产时应用内购买收据未发送到服务器

转载 作者:行者123 更新时间:2023-11-29 02:40:21 24 4
gpt4 key购买 nike

我一直在尝试上传包含非续订应用内购买的新版应用,但没有成功。已经吊销快两个月了,我找不到问题。

当我使用沙盒 帐户进行测试时,购买会发送到我的服务器,我会验证收据,然后更新我的用户状态。但是当我的应用程序去审查时,审查者说我的应用程序不提供用户的付费内容,但我在我的服务器上没有一次尝试。

我对我的 Objective-C 代码做了一些更改,希望错误可能是超时,现在我将其更改为 45.0 秒。应该多长时间?

我还对我的服务器代码进行了一些更改,以检查购买是否是由沙盒或生产帐户进行的。

所以...这是在 SKPaymentTransactionStatePurchased 之后调用的方法。

#pragma mark pagamento
-(void)completarTransacao:(SKPaymentTransaction *)transacao
{
[SVProgressHUD dismiss];

receipt = [NSData dataWithContentsOfURL:[[NSBundle mainBundle] appStoreReceiptURL]];

if (!receipt)
{
receipt = transacao.transactionReceipt;
}

[UIApplication sharedApplication].networkActivityIndicatorVisible = YES;

[SVProgressHUD showWithStatus:NSLocalizedString(@"Efetuando assinatura...", nil)];

NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@assinaturaplano/", [[NSDictionary dictionaryWithContentsOfFile:configuracoes_plist] objectForKey:@"Dominio"]]] cachePolicy:nil timeoutInterval:45.0];

[request setHTTPMethod:@"POST"];

[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField: @"Content-Type"];

[request setAllHTTPHeaderFields:[NSHTTPCookie requestHeaderFieldsWithCookies:[[NSHTTPCookieStorage sharedHTTPCookieStorage] cookiesForURL:[NSURL URLWithString:@"http://temp"]]]];

NSString *postString = [NSString stringWithFormat:@"receipt=%@&transactionIdentifier=%@&origem=%@", [receipt.base64Encoding urlencode], transacao.transactionIdentifier, [[NSDictionary dictionaryWithContentsOfFile:[home_documents stringByAppendingPathComponent:@"compra"]] objectForKey:@"origem"]];

[request setHTTPBody:[NSData dataWithBytes:[postString UTF8String] length:postString.length]];

[NSURLConnection sendAsynchronousRequest:request queue:[NSOperationQueue mainQueue] completionHandler:^(NSURLResponse *response, NSData *data, NSError *erro)
{
[UIApplication sharedApplication].networkActivityIndicatorVisible = NO;

[SVProgressHUD dismiss];

if ([(NSHTTPURLResponse*)response statusCode] == 200 || [(NSHTTPURLResponse*)response statusCode] == 201)
{
// SUBSCRIPTION CONFIRMED
[SVProgressHUD showSuccessWithStatus:NSLocalizedString(@"Assinatura efetuada com sucesso!", nil)];

[[NSNotificationCenter defaultCenter] postNotificationName:@"atualizarGold" object:nil];
}
else
{
// SUBSCRIPTION NOT CONFIRMED
[SVProgressHUD showErrorWithStatus:NSLocalizedString(@"Assinatura não efetuada. Tente novamente.", nil)];
}

[[SKPaymentQueue defaultQueue] finishTransaction:transacao];
}];
}

我的购买方式在审核时总是转到 else。

审核回复

Reasons 2.2: Apps that exhibit bugs will be rejected ----- 2.2 ----- We found that your app exhibited one or more bugs, when reviewed on iPad running iOS 8 and iPhone 5s running iOS 8, on both Wi-Fi and cellular networks, which is not in compliance with the App Store Review Guidelines. In App Purchase does not complete. After users tap on the In App Purchase, enter the Apple ID and password and confirm the purchase, an error message is produced. The steps to reproduce are: 1. launch app 2. sign in with the provided credentials 3. select 'Gold Membership' 4. tap '7 days' 5. enter the user's Apple ID and password 6. confirm purchase 7. error message appears

我做错了什么?为什么它只能通过沙箱工作?

最佳答案

为了查找收据信息,我执行了以下操作:

// Transaction: SKPaymentTransaction
// storeURL: Sandbox - https://sandbox.itunes.apple.com/verifyReceipt | Production - https://buy.itunes.apple.com/verifyReceipt
-(void)validateTransaction:(SKPaymentTransaction *)transaction storeURL:(NSString *)url
{
receipt = [NSData dataWithContentsOfURL:[[NSBundle mainBundle] appStoreReceiptURL]];

if (!receipt)
{
receipt = transacao.transactionReceipt;
}

NSError *error;

NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:url]];

[request setHTTPMethod:@"POST"];

[request setHTTPBody:[NSJSONSerialization dataWithJSONObject:@{@"receipt-data": [receipt base64EncodedStringWithOptions:0], @"password" : @"yourpassword"} options:0 error:&error]];

[NSURLConnection sendAsynchronousRequest:request queue:[NSOperationQueue mainQueue] completionHandler:^(NSURLResponse *response, NSData *data, NSError *connectionError)
{
if (!connectionError)
{
NSDictionary *jsonResponse = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:nil];

if ([[jsonResponse objectForKey:@"status"] intValue] == 0)
{
NSDictionary *purchaseInfo;

NSArray *inApp = [[jsonResponse objectForKey:@"receipt"] objectForKey:@"in_app"];

if (inApp)
{
for (NSDictionary *receptDictionary in inApp)
{
if ([[receptDictionary objectForKey:@"transaction_id"] isEqualToString:transacao.transactionIdentifier])
{
purchaseInfo = receptDictionary;

break;
}
}
}

// The recent has been found
// Send it to your server
}
else
{
switch ([[jsonResponse objectForKey:@"status"] intValue])
{
case 21003:
// Receipt not authenticated

[[SKPaymentQueue defaultQueue] finishTransaction:transaction];

break;
case 21005:
// Server not available

break;
case 21007:
// Sandbox receipt send it to sandbox server
[self validateTransaction:transaction storeURL:@"https://sandbox.itunes.apple.com/verifyReceipt"];
break;
case 21008:
// Production receipt send it to production
[self validateTransaction:transaction storeURL:@"https://buy.itunes.apple.com/verifyReceipt"];
break;
}
}
}
else
{
// It was not possible to connect AppStore
}
}];
}

关于ios - 生产时应用内购买收据未发送到服务器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25874359/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com