O
O
oktolab2013-12-15 20:01:25
Objective-C
oktolab, 2013-12-15 20:01:25

How to get Reciept to verify the payment on the server in iOS 7?

Good evening.
You need to get a Reciept to verify the payment was made on the server in iOS 7.
The documentation says that now you need to use appStoreReceiptURL for this.
Here is how I get it:

- (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions
{
    for (SKPaymentTransaction *transaction in transactions)
    {
        switch(transaction.transactionState) {
            case SKPaymentTransactionStatePurchased:
                {
                    ....
                    NSURL *recieptURL = [[NSBundle mainBundle] appStoreReceiptURL];
                    NSData *recieptData = [NSData dataWithContentsOfURL:recieptURL];
                    NSString *base64Receipt = [self base64forData:recieptData];
                }
                break;
            ...
        }
    }
}

Here is an example of what I get as a result: pastie.org/8554025 .
When docked, this produces pastie.org/8554022 .
Although it should be JSON something like this:

{
"receipt": {
"original_purchase_date_pst": "2012-04-30 08:05:55 America/Los_Angeles",
"original_transaction_id": "1000000046178817",
"original_purchase_date_ms": "1335798355868",
"transaction_id": "10617080047",
"quantity": "1",
"product_id": "br.com.jera.Example",
"bvrs": "20120427",
"purchase_date_ms": "1335798355868",
"purchase_date": "2012-04-30 15: 05:55 Etc/GMT",
"original_purchase_date": "2012-04-30 15:05:55 Etc/GMT",
"purchase_date_pst": "2012-04-30 08:05:55 America/Los_Angeles",
"bid": "br.com.jera.Example",
"item_id": "521129812"
},
"status": 0
}

How to properly get Recipept in iOS 7?

Answer the question

In order to leave comments, you need to log in

[[+comments_count]] answer(s)
S
s0L, 2013-12-26
@s0L

appStoreReceiptURL is a receipt for the purchase of the application, not In-App
To check In-App, it must be taken from transaction.transactionReceipt

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question