Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to verify in-app purchase receipt?
    primarykey
    data
    text
    <p>I am trying to verify my IAP receipt with the following code, but it's not working:</p> <pre> - (void)completeTransaction:(SKPaymentTransaction *)transaction { NSString* receiptString = [self createEncodedString:transaction.transactionReceipt]; NSURL *url = [NSURL URLWithString:@"http://my.website.com/"]; AFHTTPClient *httpClient = [[AFHTTPClient alloc] initWithBaseURL:url]; NSDictionary *params = [NSDictionary dictionaryWithObjectsAndKeys: receiptString, @"receipt", NO, @"isSandbox", nil]; NSMutableURLRequest *request = [httpClient requestWithMethod:@"POST" path:@"/verifyReceipt.php" parameters:params]; AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request]; [operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) { NSLog(@"success: %@", operation.responseString); } failure:^(AFHTTPRequestOperation *operation, NSError *error) { NSLog(@"error: %@", operation.responseString); } ]; [self recordTransaction:transaction]; [self provideContent:transaction.payment.productIdentifier]; [[SKPaymentQueue defaultQueue] finishTransaction:transaction]; } </pre> <pre> - (NSString*) createEncodedString:(NSData*)data { static char table[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; const int size = ((data.length + 2)/3)*4; uint8_t output[size]; const uint8_t* input = (const uint8_t*)[data bytes]; for (int i = 0; i > 18) & 0x3F]; output[index + 1] = table[(value >> 12) & 0x3F]; output[index + 2] = (i + 1) > 6) & 0x3F] : '='; output[index + 3] = (i + 2) > 0) & 0x3F] : '='; } return [[NSString alloc] initWithBytes:output length:size encoding:NSASCIIStringEncoding]; } </pre> <p>The PHP script that i am using to verify the data can be found here: <a href="http://www.phpriot.com/articles/verifying-app-store-receipts-php-curl" rel="nofollow">http://www.phpriot.com/articles/verifying-app-store-receipts-php-curl</a></p> <p>What am i doing wrong?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload