Subscription API
General provisions
Endpoint:
https://statgw.devtodev.com/subscriptions/api?apikey={project’s API key}
Query type: POST
The query body is a JSON object with fields described in the table below.
Fields
notificationType
Type of notification
originalTransactionId
ID of the original transaction
transactionId
Transaction ID
startDateMs
Subscription start date in milliseconds in UTC
expiresDateMs
Subscription expiration date in milliseconds in UTC
product
Subscription SKU
productType
Subscription type (line)
price
Subscription price
currency
Currency of the subscription payment
isTrial
The event is flagged if it is trial and is not flagged if it’s a subscription
gracePeriod
Extension of subscription renewal date in days. If this field is filled in and the user did not renew the subscription before the expiration date, then wait for gracePeriod
days value to flag it as expired.
Fields for user identification (Attention! Regardless of the type of notification, at least one of the user IDs must be specified in the query)
idfa
Available platforms: iOS
idfv
Available platforms: iOS
advertisingId
Available platforms: Android, Windows
androidId
Available platforms: Android
userId
The same as Main ID in user card
customId
String custom user ID
Available platforms: all platforms
devtodevId
d2d numeric user id. Available platforms: all platforms
Notification types
purchase
First-time subscription purchase
renewal
Active subscription renewal
refund
Money refund
cancellation
Cancellation of an active subscription and proportional refund
Server response
If the notification is accepted, the response status is 200. If the query is incorrect, the response status is 400. In case of an internal error, the response status is 500.
In case the status is 400 or 500, the error description will be indicated in the query body as a JSON object:
{
"title": "Bad request",
"error": "Not set parameter api-key"
}
Notification types and corresponding fields
Available notification types for a trial (all postbacks should be flagged as ‘
isTrial
= true’):
purchase – trial subscription
cancellation – subscription cancellation before the end of that trial
2. Available notification types for subscription purchase:
purchase – subscription purchase
renewal – subscription renewal
cancellation – premature termination of a subscription and proportional refund
refund – money refund
Trial purchase
notificationType
Notification type = purchase
originalTransactionId
ID of the original transaction
transactionId
Transaction ID
startDateMs
Trial start date in milliseconds in UTC
expiresDateMs
Trial expiration date in milliseconds in UTC
product
Subscription SKU
productType
Subscription type (line)
isTrial
true
Trial cancellation
notificationType
Notification type = cancellation
originalTransactionId
ID of the original transaction
transactionId
Transaction ID
expiresDateMs
Trial expiration date in milliseconds in UTC
product
Subscription SKU
productType
Subscription type (line)
isTrial
true
Subscription purchase
notificationType
Notification type = purchase
originalTransactionId
ID of the original transaction
transactionId
Transaction ID
startDateMs
Subscription start date in milliseconds in UTC
expiresDateMs
Subscription expiration date in milliseconds in UTC
product
Subscription SKU
productType
Subscription type (line)
isTrial
false
price
Subscription price
currency
Currency of the subscription payment
gracePeriod
Extension of subscription renewal date in days
Subscription renewal
notificationType
Notification type = renewal
originalTransactionId
ID of the original transaction
transactionId
Transaction ID
startDateMs
Subscription start date in milliseconds in UTC
expiresDateMs
Subscription expiration date in milliseconds in UTC
product
Subscription SKU
productType
Subscription type (line)
isTrial
false
price
Subscription price
currency
Currency of the subscription payment
gracePeriod
Extension of subscription renewal date in days
Subscription cancellation
notificationType
Notification type = cancellation
originalTransactionId
ID of the original transaction
transactionId
Transaction ID
expiresDateMs
Subscription expiration date in milliseconds in UTC
product
Subscription SKU
productType
Subscription type (line)
isTrial
false
Subscription refund
notificationType
Notification type = refund
originalTransactionId
ID of the original transaction
transactionId
Transaction ID
expiresDateMs
Subscription expiration date in milliseconds in UTC
product
Subscription SKU
productType
Subscription type (line)
isTrial
false
price
The amount of money refunded to the user
currency
Currency of the subscription payment
Query example
POST https://statgw.devtodev.com/subscriptions/api?apikey=ak-cDNRQl0Lypq4AOUrx8aGGMnmJT1FSebd
{
"notificationType":"PURCHASE",
"transactionId":"transactionId",
"startDateMs":1640072573468,
"expiresDateMs":1640245373468,
"product":"com.demo.bundle.weekly",
"price":90.9,
"currency":"RUB",
"isTrial":false,
"devtodevId":4064192
}
Last updated
Was this helpful?