Payment and promotional entitlement webhooks
Receive InAppify webhooks over POST with payment and gift payload examples, HMAC verification, delivery retries, and idempotent processing.
Webhooks send project events from InAppify to your backend. You create the receiving endpoint; it is not an InAppify public REST API endpoint. The JSON body contains the event directly, without a status or data wrapper.
Enable and configure the endpoint
- Open the project's Settings → Payment webhook and enable the webhook.
- Enter a public HTTPS URL such as
https://api.example.com/webhook. The receiving route must accept POST requests with a JSON body. - Select subscription, consumable, or non-consumable products. Trial starts require both subscriptions and the trial option. Promotional grants require Subscription and do not depend on the trial option.
- Copy the signing key when it is issued and store it only on your backend. Signature verification uses the complete value, including its
whsec_prefix.
The webhook signing key is separate from your REST API secret key. Incoming requests do not rely on a user session or Authorization: Bearer; authenticate them through the signature. Configure the server-to-server route so browser login or browser CSRF protection does not prevent delivery.
URLs must not contain credentials or a fragment such as #section. Local, private, and non-public destinations are rejected. Redirects are not followed; register the final HTTPS URL.
Changing the enabled state, URL, or product/trial filters starts a new delivery window at that change and discards pending deliveries associated with the previous settings. Saving unchanged settings does not reset the window. Events preceding activation are not backfilled.
Current event types
eventType | When it is produced |
|---|---|
payment.succeeded | After a successful payment commits, including a previously failed payment confirmed through inquiry or a selected trial start |
entitlement.promotional_granted | After a promotional grant commits through the dashboard or promotional entitlement API, with subscriptions selected |
Initial delivery is queued after commit without waiting for the scheduled retry cycle. Arrival depends on queue processing and server availability. The scheduled processor also recovers missed events.
An API gift extension that creates a new grant record has a new eventId. Editing/revoking access and refunds do not currently have separate events in this contract. A payment webhook does not announce later subscription state changes or final consumable delivery.
HTTP request and signature
This example is sent to your backend endpoint. X-Inappify-Timestamp is the send time as a Unix timestamp in seconds. The signature is a lowercase hexadecimal HMAC-SHA256 digest:
Preserve the exact raw request body before parsing JSON. Whitespace, key order, and escaping affect the signature; do not reserialize the JSON. Compare signatures in constant time.
PHP signature verification example
The function verifies the signature before parsing the event. The five-minute replay window is a recommended policy in this example; keep your server clock synchronized. INAPPIFY_WEBHOOK_SECRET is your own backend environment variable containing the key issued in the dashboard.
This code only authenticates and parses. Your route handler must reject authentication errors and return success only after durable event storage or a committed local transaction.
A new key is only displayed when issued. After rotation, replace it on your backend; subsequent deliveries and retries use the current signing key.
Successful payment payloads
Subscription
An example subscription payment in Iranian rial, using fictitious data:
Consumable
Trial start
A non-consumable uses productType: "NonConsumable" and normally has deliveryId: null. A trial start is the same payment.succeeded event with paymentType: "Trial" and isTrial: true; it is not a cash payment.
Payment fields
| Field | Type | Meaning |
|---|---|---|
eventId | string | Stable event identifier; currently payment.succeeded.<paymentId> |
eventType | string | Always payment.succeeded |
paidAt | string | Payment success time as an ISO 8601 UTC timestamp |
paymentNumber | string | InAppify transaction number, distinct from the event ID and gateway reference |
amount | string | Stored amount as a numeric string; do not convert it to a float |
paymentType | string | Payment type enum name, not its numeric value |
isTrial | boolean | Whether this transaction represents a trial start |
appIdentifier | string | Dashboard app identifier key, not an Android package name |
appUserIdentifier | string | Customer identifier within the project |
productIdentifier | string | Purchased product identifier |
productType | string | Exactly Subscription, Consumable, or NonConsumable |
deliveryId | integer or null | Associated consumable delivery ID, when present; its presence does not mean delivery was acknowledged |
Defined customer purchase paymentType names are Trial, IranStore, ForeignStore, PersonalGateIRR, PersonalGateUSD, ShareGateIRR, and ShareGateUSD. The value depends on the purchase path.
This payload has no separate currency field. For IRR types and rial purchase paths, the amount is in rial, not toman. Do not treat USD types as rial. Match the unit to the payment type and product configuration. In the rial example, "100000.00" means 100,000 rial.
Promotional entitlement payload
| Field | Type | Meaning |
|---|---|---|
eventId | string | Stable event identifier; currently entitlement.promotional_granted.<customerEntitlementId> |
eventType | string | Always entitlement.promotional_granted |
grantedAt | string | Gift record creation time as an ISO 8601 UTC timestamp |
appUserIdentifier | string | Customer identifier within the project |
entitlementIdentifier | string | Entitlement identifier, not a product identifier |
customerEntitlementId | integer | Gift access record ID |
expiresAt | string or null | Expiry as an ISO 8601 UTC timestamp, or null when absent |
periodType | string | Always Promotional |
A gift does not create a payment. Fields such as amount, paymentNumber, appIdentifier, and productIdentifier are absent from this event. See the promotional entitlement API for granting and extending access.
Receiver response and retries
Any HTTP status from 200 through 299 marks a delivery successful, for example:
Your response body is ignored; no particular JSON response is required. Network errors, timeouts, and any non-2xx code, including 3xx and 4xx, count as failures. The HTTP request timeout is five seconds and the connection timeout is two seconds.
| Attempt | Eligible time after the preceding failure |
|---|---|
| 1 | Initial dispatch after the event commits |
| 2 | 2 minutes |
| 3 | 30 minutes |
| 4 | 64 minutes |
| 5 | 360 minutes |
There are at most five attempts. A minute-based scheduled processor checks retries; the table specifies minimum delays rather than exact arrival times. No further automatic delivery occurs after the attempt budget is exhausted.
Retries retain the same body and eventId, while the timestamp and signature are generated again for each delivery. Event arrival order is not guaranteed. A missing webhook alone does not establish that a payment failed.
Idempotent processing and consumables
- Verify POST, the signature, and the timestamp. Resolve the project from the receiving route configuration and that project's signing key.
- Choose a handler by
eventType. Tolerate additional fields; do not apply financial effects for an authenticated but unknown event type. - Commit a unique
(project, eventId)marker and the business effect in one local transaction, or first persist the event in your durable queue. For an already processed event, return 2xx without repeating the effect. - Do not return success if durable storage or required processing fails, so a retry remains possible.
Your server may process an event while its response fails to reach InAppify. Expect duplicates. Do not replace newer state with an older event solely because of its arrival time.
For wallet top-ups from consumables, map productIdentifier to server-configured credit. Also enforce a ledger key on (project, deliveryId) so reconciliation and webhook delivery cannot credit the same purchase twice.
A webhook does not acknowledge consumable delivery. For direct web-link purchases, use deliveryId, appIdentifier, and appUserIdentifier to verify current delivery eligibility and acknowledge after your local commit. That endpoint checks the paid, unrefunded purchase within the project, app, and customer scope.
When inquiry confirms a previously failed payment, its webhook is created when success is committed. See payment inquiry.