Skip to content

Validating In-App Purchase

The App Store receipt is a Base-64 encoded binary data which is encrypted and signed with an Apple Certificate.  It is used as a protection measure against fraudulent transactions made in the App Store.  The receipt becomes available in the app after the first in-app purchase, and depending on the platform can be validated using the API described below.

Signatures

- (void)verifyAppleReceiptWithReceiptData:(NSString * _Nonnull)receiptData password:(NSString * _Nonnull)password responseHandler:^(NSDictionary<NSString *,id> * _Nonnull)responseHandler errorHandler:^(Fault * _Nonnull)errorHandler;

- (void)verifyAppleReceiptWithReceiptData:(NSString * _Nonnull)receiptData password:(NSString * _Nonnull)password excludeOldTransactions:(BOOL)excludeOldTransactions responseHandler:^(NSDictionary<NSString *,id> * _Nonnull)responseHandler errorHandler:^(Fault * _Nonnull)errorHandler;
func verifyAppleReceipt(receiptData: String, password: String, responseHandler: (([String : Any]) -> Void)!, errorHandler: ((Fault) -> Void)!)

func verifyAppleReceipt(receiptData: String, password: String, excludeOldTransactions: Bool, responseHandler: (([String : Any]) -> Void)!, errorHandler: ((Fault) -> Void)!)

where:

Argument                Description
receiptData The Base64-encoded receipt data.
password The app’s shared secret which is a hexadecimal string.
excludeOldTransactions Set this value to true if you want to include only the latest renewal transactions for any subscription. Use this parameter only if a receipt contains auto-renewable subscriptions.

In case you want to fetch the receipt-data, we recommend reading this material.

To generate a password(shared secret) navigate to the following document.

Return Value

Returns an HTTP Status code as an integer value, and also an object with the receipt contents.

{  
  "httpCode": int,  
  "body": Nested JSON object  
}

where:

Argument                Description
httpCode An HTTP status code, which indicates the final execution status of the method.
body A JSON representation of the receipt that was sent for verification.

Example

- (void)verifyAppleReceiptWithReceiptData:(NSString * _Nonnull)receiptData password:(NSString * _Nonnull)password responseHandler:^(NSDictionary<NSString *,id> * _Nonnull)responseHandler errorHandler:^(Fault * _Nonnull)errorHandler;

- (void)verifyAppleReceiptWithReceiptData:(NSString * _Nonnull)receiptData password:(NSString * _Nonnull)password excludeOldTransactions:(BOOL)excludeOldTransactions responseHandler:^(NSDictionary<NSString *,id> * _Nonnull)responseHandler errorHandler:^(Fault * _Nonnull)errorHandler;
func verifyAppleReceipt(receiptData: String, password: String, responseHandler: (([String : Any]) -> Void)!, errorHandler: ((Fault) -> Void)!)

func verifyAppleReceipt(receiptData: String, password: String, excludeOldTransactions: Bool, responseHandler: (([String : Any]) -> Void)!, errorHandler: ((Fault) -> Void)!)