Client API - Uploading Apple App Store Receipts

Notify Mbaasy of, and add metadata to iOS purchases and subscription receipts using this API.

⚠ Requires Authentication.

HTTP endpoint

POST https://api.mbaasy.com/client/itunes_connect/receipts

JSON request body

Name Type Description
receipt1 String A Base64 encoded string containing the receipt.
country_code2 3 String ISO 3166-1 alpha-2 country code of the end user’s App Store region. See country_code footnote.
identifier_for_vendor2 String The [UIDevice identifierForVendor].
user_identifier2 String User ID corresponding to your user database
ip_address2 String V4 or V6 IP address of the end user. Defaults to the network request IP if omitted, send NULL to prevent the IP address from being stored.
metadata2 Object Store any arbitrary data to be recorded against the purchase order. e.g. Campaign ID or prices.

HTTP response codes

Code Reason
200 Okay The receipt signature is valid and has been synchronously validated with the App Store API.
206 Partial content The receipt and signature is valid however the App Store API was unreachable. The receipt has been enqueued for asynchronous validation with the App Store API.
401 Unauthorized The access token is invalid or the Authorization header is malformed or missing, see Authorization.
402 Payment required The receipt signature is invalid (possible fraud attempt).
422 Unprocessable Entity The request payload is invalid, check the errors in the response payload.

JSON response body

Name Type Description
id UUID Mbaasy database ID of the receipt.
style String Style of the receipt, either “transaction” or “unified”.
app_family_id UUID Mbaasy database ID of the app.
bundle_id String Bundle ID referenced in the receipt.
is_fraud Boolean Whether the receipt is fraudulent.
fraud_reason String The reason the receipt was marked as fraudulent.
environment String The environment of the receipt, either “sandbox” or “production”.
user_identifier String The user_identifier as provided from the request payload.
metadata Object The metadata as provided from the request payload.
ip_address String The ip_address as provided from the request payload.
in_app_purchases Array An array (list) of In-App Purchase resources. (Returns an array because “unified” receipts may contain multiple purchases.
created_at Timestamp4 Date and time when the receipt was created on Mbaasy.
updated_at Timestamp4 Date and time when the receipt was last updated.
  1. This property is mandatory

  2. This property is optional 2 3 4 5

  3. The country_code property is dependent on the user’s App Store region (which is not necessarily their current, physical location). It is accessible from the priceLocale instance property on the SKProduct object of any of your available products.

    The priceLocale instance extends from the Locale structure and can be cast as a NSLocale instance.

    Using the CFLocaleGetValue function, you can pass the NSLocale instance and the kCFLocaleCountryCode key property to return the country code associated to the user’s App store account.

    Here is a quick example in Objective-C:

    - (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response
    {
        SKProduct *product = [response.products objectAtIndex:0]; // Get the first product
        NSLocale* priceLocale = product.priceLocale; // Get the priceLocale
        NSString *countryCode = (NSString*)CFLocaleGetValue((CFLocaleRef)priceLocale, kCFLocaleCountryCode); // Get the country code
    }
    

    Credit to this Stack Overflow answer

  4. Timestamps are objects that contain an ms (Unix Timestamp in milliseconds) and utc property. e.g.

    {
      "utc": "2018-02-26 10:35:47 UTC",
      "ms": 1519641347834
    }
    

     2