
这是发生了什么:
>用户按下按钮以购买续订订阅
>用户提供其iTunes密码并确认购买
>该应用程序将从应用商店收到的收据提交给我的服务器以检查有效性
>服务器返回“ok”或“not ok”字符串.应用程序仅在“ok”上调用finishTransaction
我在第3步出现网络故障时遇到问题.我无法验证收据.但是如果用户试图再次购买,应用商店会告诉他他已经订阅了,即使我没有调用finishTransaction方法来完成购买!
这是预期的行为吗? app-store不应该将未完成的交易视为未完成,或者我错过了什么?
我欢迎任何解决这个问题的建议.
-(voID) userPurchase:(SKProduct*) product{ SKPayment *payment = [SKPayment paymentWithProduct:product]; [[SKPaymentQueue defaultQueue] addPayment:payment];}-(voID)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions { NSLog(@"paymentQueue updatedTransaction"); for (SKPaymentTransaction * transaction in transactions) { switch (transaction.transactionState) { case SKPaymentTransactionStatePurchasing: break; case SKPaymentTransactionStatePurchased: [self recordSubscription:transaction]; break; case SKPaymentTransactionStateFailed: [[SKPaymentQueue defaultQueue] finishTransaction:transaction]; break; case SKPaymentTransactionStateRestored: [self recordSubscription:transaction]; break; default: NSLog(@"Default"); break; } };}-(voID) recordSubscription:(SKPaymentTransaction*)transaction{ Nsstring *JsonObjectString = [self encode:(uint8_t *)transaction.transactionReceipt.bytes length:transaction.transactionReceipt.length]; NSMutableDictionary *params = [[NSMutableDictionary alloc] initWithObjectsAndKeys:JsonObjectString,@"receiptdata",nil]; [[AFNetworkSubClass sharedClIEnt] postPath:@"myserver" params:params success:^(AFhttpRequestoperation *operation,ID output) { /* some code */ if([valstring isEqualToString:@"ok"]){ [[SKPaymentQueue defaultQueue] finishTransaction:transaction]; } } }failure:^(AFhttpRequestoperation *operation,NSError *error) { NSLog(@"valIDation Failed"); }解决方法 我想在你调用recordSubscription方法之前,你可以调用finish finishTransaction方法从支付队列中删除付款,因为你已经完成了对苹果服务器的购买行为. 如果网络故障导致您无法验证应用程序收据,则只需记录收据并再次将收据验证到您自己的服务器,或者验证何时可以再次访问网络.
我希望它可以帮到你.
总结以上是内存溢出为你收集整理的ios – 自动续订订阅:尽管未调用finishTransaction,app-store也会完成事务全部内容,希望文章能够帮你解决ios – 自动续订订阅:尽管未调用finishTransaction,app-store也会完成事务所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)