I have a serious problem. I am working on an app purchase. When I try to buy the first time, it works fine, and the second time my full transactional call is called twice. I do not know why I got this problem.
After I received the receipt, I call my verification method, and if you confirm that you, as a server, send me an audio file in http responce and I am downlaod, and when I successfully upload the file, I will call endtransaction.
Here is my code
- (void)startPurchase { [[SKPaymentQueue defaultQueue] addTransactionObserver:self]; if([SKPaymentQueue canMakePayments]) { NSLog(@"IN-APP:can make payments"); SKProductsRequest *request = [[SKProductsRequest alloc] initWithProductIdentifiers: [NSSet setWithObject:myIdentifier]]; request.delegate = self; NSLog(@"** Productdata is ** %@",myIdentifier); [request start]; } else { NSLog(@"IN-APP:can't make payments"); loadingHUD.hidden=YES; } } - (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response { NSLog(@"IN productsRequest END %d",[response.products count]); @try { SKProduct *product = [response.products objectAtIndex:0]; SKPayment *newPayment = [SKPayment paymentWithProduct:product]; [[SKPaymentQueue defaultQueue] addPayment:newPayment]; NSLog(@"IN-APP:productsRequest END"); loadingHUD.hidden=YES;
In the VerifyTransaction method in the successful transaction block, I do the transaction completion transaction
[operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) { [[SKPaymentQueue defaultQueue] finishTransaction: transaction]; // Finish the transaction // NSLog(@"Successfully downloaded file to %@",[[NSString alloc] initWithData:operation.responseData encoding:NSASCIIStringEncoding]); // Give alert that downloading successful. NSLog(@"Successfully downloaded file to %@", destPath); // NSLog(@"response: %@", operation.responseString); // Give alert that downloading successful. // [self.target parserDidDownloadItem:destPath]; //loadingHUD.detailsLabelText = [NSString stringWithFormat:@"%@ %i%%",@"Downloading",100]; [loadingHUD hide:TRUE]; [DBHelper savePurchaseId:fileName]; // save the purchase itune id into local database to populate hover image of play button on main List [self movieReceived]; }
user1597878
source share