iOS In-App purchases: When and why does SKPaymentTransactionStateRestored
get sent back as status of a transaction?
Does it related to having a recurring subscripti开发者_如何学Con plan?
You get SKPaymentTransactionStateRestored
transactions instead of SKPaymentTransactionStatePurchased
transactions when you are restoring the user's purchases by sending a restoreCompletedTransactions
message to the SKPaymentQueue
.
General rule is to process both callbacks: for purchase and restore purchase.
- (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions
{
for (SKPaymentTransaction *transaction in transactions)
{
switch (transaction.transactionState)
{
case SKPaymentTransactionStatePurchased:
[self completeTransaction:transaction];
break;
case SKPaymentTransactionStateFailed:
[self failedTransaction:transaction];
break;
case SKPaymentTransactionStateRestored:
[self restoreTransaction:transaction];
default:
break;
}
}
}
- (void) completeTransaction: (SKPaymentTransaction *)transaction
{
[self recordTransaction: transaction content:transaction.payment.productIdentifier];
[[SKPaymentQueue defaultQueue] finishTransaction: transaction];
}
- (void) restoreTransaction: (SKPaymentTransaction *)transaction
{
[self recordTransaction: transaction content:transaction.originalTransaction.payment.productIdentifier];
[[SKPaymentQueue defaultQueue] finishTransaction: transaction];
}
精彩评论