What is the correct way to verify a valid IAP with an Apple server?

From iOS7, Apple has deprecated the transactionReceipt property of the SKPaymentTransaction instance, and now we have one large receipt containing everything. In my application, I have several spending purchases. My code is:

#pragma mark -
#pragma mark SKPaymentTransactionObserver

- (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray<SKPaymentTransaction *> *)transactions {

    for (SKPaymentTransaction *transaction in transactions) {

        switch (transaction.transactionState) {

            case SKPaymentTransactionStatePurchased:
                [self completeTransaction:transaction];
                break;

           ...
    }

}

- (void)completeTransaction:(SKPaymentTransaction *)transaction {
//    [self sendRecieptToServer:transaction.transactionReceipt]; // deprecated
    [self testMainReceipt];
    [self deliverPurchaseNotificationFirIdentifier:transaction.payment.productIdentifier];
    [SKPaymentQueue.defaultQueue finishTransaction:transaction];
}

- (void)testMainReceipt {
    NSURL *receiptURL = [[NSBundle mainBundle] appStoreReceiptURL];
    NSData *receipt = [NSData dataWithContentsOfURL:receiptURL];

    [self sendRecieptToServer:receipt]; //look at the 'status' field and determine whether a good purchase or not
}

From Apple's answer, I see "in_app" filed with an array, always containing 1 element - the most recent purchase, no matter how many times I have made purchases before. Is it right that this concerns how consumer purchases work? And do I always get an array with 1 point and "status" for this last purchase? Or is there his best way?

+6
source share
2 answers

enter image description here

, , . , . , iPod touch, iPhone, , , iPhone, .

, , .

, & .

. .

+2

All Articles