Closed ptmkenny closed 6 months ago
amountUSD
and amountMicros
are included but not part of spec, use at your own risk. It's the amount from the last transaction (which is where the purchase state is retrieved from).
Notice also that iaptic's reported amounts are a best guess, as it's not an information provided by Apple / Google.
Ok, thank you for the information.
May I ask why there are details outside the spec that are also included? I wanted to do a strict JSON schema validation, but the presence of additional properties will cause such validation to fail.
In short, it's for internal reasons (in that instance, data from the last transactions is merged into purchase data).
But I advise you set "additionalProperties": true
. When we will extend the webhook content with new data, this shouldn't make your server crash.
Ok, thank you. I ended up by validating the receipt with "additionalProperties": true
and then processing the receipt to strip the properties before validating again with a stricter spec for my own server and then saving it in the database.
I am doing this in Drupal, so I removed the site-specific parts of my code and published an example module for Drupal here:
https://github.com/ptmkenny/iaptic_webhook_validator
The JSON schemas are here:
https://github.com/ptmkenny/iaptic_webhook_validator/tree/main/json_schema
Observed behavior
I'm using the latest version of the plugin. Based on the docs at https://www.iaptic.com/documentation/api/v3/#api-Types-Purchase, I started to create a JSON Schema to verify the webhook call to my server.
I noticed that the list of fields for
Purchase
is incomplete.Specifically, the requests sent from Iaptic to my webhook include
amountMicros
andamountUSD
fields, which are not listed in the docs.My schema so far
I will be preparing a full JSON schema for your webhook response; if you're interested, I would be happy to prepare it as a PR as a doc example.