4

I am developing an application in which user can purchase auto-renewable subscription. Buying part is woking alright but problem occurs when user deletes the application and tries to restore his purchases. following is the code I wrote to handle that.

  1. I have given a button titled "Already a Subscriber". When user tap that I call following code.

    [[SKPaymentQueue defaultQueue] addTransactionObserver:self];
    [[SKPaymentQueue defaultQueue] restoreCompletedTransactions];           
    
  2. And this is how I handle restore in - (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions method.

            case SKPaymentTransactionStateRestored:
            duration = [strDuration intValue];
            if(transaction.transactionReceipt != nil){
                receipt = [[NSString alloc] initWithData:[b64 dataByBase64EncodeFromData:transaction.transactionReceipt] encoding:NSASCIIStringEncoding];
                [userDefault setObject:transaction.transactionReceipt forKey:@"LastReceipt"];
                [queue finishTransaction:transaction];
                [self callReceiptInfoImpl];
            }
            break;
    
  3. Following is delegate method when restore transaction is completed.

    -(void)paymentQueueRestoreCompletedTransactionsFinished:(SKPaymentQueue *)queue{ NSLog(@"COMPLETED TRANSACTION RESTORED"); }

Problem is that, when user clicks button "Already a subscriber" then Step 1. gets called but Step 2. never gets called. Finally I can see message "COMPLETED TRANSACTION RESTORED" on screen.

If anybody has faced similar problem then please guide.

Thanks for reading.....

Mohammad
  • 1,636
  • 1
  • 13
  • 17
  • http://stackoverflow.com/questions/6149764/do-auto-renewable-subscriptions-send-an-skpaymenttransactionstatepurchased-restor – Praveen-K Sep 13 '11 at 07:20
  • having the same issue, are purchases in the sandbox never restored? – Corey Floyd Jan 11 '12 at 13:09
  • Hi, correct way to do this is to store a receipt in local(in iPhone OR in iPAD). Then when you want to restore send that receipt to your server(as it cannot be verified iPhone OR iPAD) and that server will send receipt to apple for verification. Apple will send result back to your server and it will send it to device. For further details read documentation as it provides clear idea. following may be helpful. http://stackoverflow.com/a/7244084/919049 – Mohammad Jan 12 '12 at 13:23
  • Sure you know some in app purchases can't be restored so make sure your IAP type is a restorable. Might be why you aren't seeing step 2 because these items aren't added to the queue – Alex Reynolds Sep 06 '13 at 18:42

1 Answers1

0

Within your class, you have to implement the callback function paymentQueue:updatedTransactions:

This function will receive updates on the transactions as and when it’s made. Because your transactions take place even when the app is closed, you should be ready to receive these notifications as soon as you open the app. So the best place is to initialize it in applicationDidFinishLaunching or equivalent method.

from this link

Praveen-K
  • 3,401
  • 1
  • 23
  • 31
  • Thanks for answer, but everything mentioned in paragraph and in link you gave is being satisfied but its still not working.... – Mohammad Sep 13 '11 at 07:38