Skip to main content

Validate purchase in Stripe, provide access level, and import transaction history from Stripe with server-side API

Validates a purchase using the provided Stripe token using the credentials of Stripe in your App Settings inside Adapty Dashboard. If the purchase is valid, the transaction history is imported from Stripe to the profile in Adapty with the specified customer_user_id. If there was no profile with this customer_user_id before — it will be created.

Profile events are generated along the way and imported transactions are counted towards MTR.

Method and endpoint

POST https://api.adapty.io/api/v2/server-side-api/purchase/stripe/token/validate/
warning

This request requires different authorization parameters:

Example request

--location 'https://api.adapty.io/api/v1/sdk/purchase/stripe/token/validate/' \
--header 'Content-Type: application/vnd.api+json' \
--header 'Authorization: Api-Key <PUBLIC_OR_PRIVATE_KEY>' \
--data-raw '{
"data": {
"type": "stripe_receipt_validation_result",
"attributes": {
"customer_user_id": "<CUSTOMER_USER_ID>",
"stripe_token": "sub_1OM8brJTlbIG45BdDRFOHWAU"
}
}
}'

Parameters

ParamTypeRequiredNullableDescription
customer_user_idStringThe ID of your user in your system. You can see it in the Customer user ID field on the Adapty Dashboard -> Profiles -> specific profile page. For it to work, you must identify the users in your mobile app code via Adapty SDK
stripe_tokenStringToken of a Stripe object that represents a unique purchase. Could either be a token of Stripe's Subscription (sub_XXX) or Payment Intent (pi_XXX).

Successful response

{
"data": null
}

Errors

400 Bad request

Contain a list of errors with parameters.

Parameters

ParameterTypeDescription
detailStringDescriptive information about the error.
sourceStringAn object containing a "pointer" that references the exact location in the request document causing the issue
StatusIntegerHTTP status. Always 400

Response example

{
"errors": [
{
"detail": "none is not an allowed value",
"source": {
"pointer": "/data/attributes/stripe_token"
},
"status": "400"
}
]
}

See also: