Consumable in-app purchases
Hi, I am trying to create in my game in the app store so that players can buy virtual currencies which are consumables. But I'm a little unsure if my approach is correct or not. So I think it would be nice to ask for help here.
After clicking the Buy button, the buyProductIdentifier is called
- (void)buyProductIdentifier:(NSString *)productIdentifier {
NSLog(@"Buying %@...", productIdentifier);
SKPayment *payment = [SKPayment paymentWithProductIdentifier: productIdentifier];
[[SKPaymentQueue defaultQueue] addPayment:payment];
}
and then complete the payment
- (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions
{
CCLOG(@"PAYMENT QUEUE CALLED!");
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;
}
}
}
I tried commenting out the SKPaymentTransactionStateRestored case to force the player to make a purchase every time, rather than popping up a message saying "you already bought this but it hasn't been downloaded."
Is this approach correct? if not can you guys give me some advice?
Many thanks.
+3
source to share