我们最近收到了一些电子邮件,其中用户抱怨在应用程序购买中对消耗品收取双倍费用。我不知道,这怎么可能。此外,似乎只有少数用户遇到这种问题。但如果这样做,它会发生多次。我错过了什么吗?数量默认为 1,不是吗?您是否遇到过双重收费的问题?我发现很多用户抱怨在各种应用程序上被双重收费。这是 Apple/iTunes 的问题还是许多开发人员做错了什么?
这是交易的相关代码。我一次只允许一个事务,使用成员变量transactionRunning并检查 SKPaymentQueue 队列中有多少事务。
任何意见或经验将不胜感激。任何解决此问题的帮助将不胜感激。
- (void)purchaseProduct:(NSString*)productIdentifier
{
NSArray * array = [SKPaymentQueue defaultQueue].transactions;
if (transactionRunning == false && [array count] == 0)
{
transactionRunning = true;
SKPayment *payment = [SKPayment paymentWithProductIdentifier:productIdentifier];
[[SKPaymentQueue defaultQueue] addPayment:payment];
}
}
- (void)finishTransaction:(SKPaymentTransaction *)transaction wasSuccessful:(BOOL)wasSuccessful
{
transactionRunning = false;
[[SKPaymentQueue defaultQueue] finishTransaction:transaction];
}
- (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions
{
for (SKPaymentTransaction *transaction in transactions)
{
switch (transaction.transactionState)
{
case SKPaymentTransactionStatePurchasing:
break;
case SKPaymentTransactionStatePurchased:
[self provideContent:transaction.originalTransaction.payment.productIdentifier];
[self finishTransaction:transaction wasSuccessful:YES];
break;
case SKPaymentTransactionStateFailed:
[self failedTransaction:transaction];
break;
case SKPaymentTransactionStateRestored:
[self restoreTransaction:transaction];
break;
default:
break;
}
}
}