Pre-validate purchase
/accounts/pre_validate_purchase
Target audience: Developers
Pre-validate purchase¶
Introduction¶
This endpoint validates whether a customer can purchase a specific product based on their email address. It operates in the context of a customer (using their email) rather than requiring the customer to be logged in.
The endpoint checks for various eligibility rules including active subscriptions, campaign purchase rules, account status, and more. If no account exists with the provided email, the endpoint returns that the purchase is allowed.
URI¶
| Environment | URI |
|---|---|
| Stage | https://payway-api.stage.adeprimo.se/external/api/v4/accounts/pre_validate_purchase |
| Production | https://backend.worldoftulo.com/external/api/v4/accounts/pre_validate_purchase |
Requirements¶
| Identity | Scope |
|---|---|
| No | /external/account/r |
Parameters¶
| Field | Required | Type | Description |
|---|---|---|---|
| product_code | Required | String | The product code to validate purchase eligibility Size range: ..256 |
| contact_email | Required | String | The email address of the customer Size range: ..256 |
Curl Example¶
curl --request GET \
--url https://payway-api.stage.adeprimo.se/external/api/v4/accounts/pre_validate_purchase \
--header 'accept: application/json' \
--header 'authorization: Bearer <token_without_identity>' \
--header 'content-type: application/json' \
--data '{
"product_code": "digital_monthly",
"contact_email": "customer@example.com"
}'
Response¶
| Field | Description |
|---|---|
| can_purchase | Whether the customer is eligible to purchase the product |
| can_purchase_with_active_subscription | Whether the customer could purchase if they had an active subscription (relevant for future features) |
| reason | The reason for the eligibility decision |
Purchase allowed¶
HTTP 200 OK
{
"item": {
"can_purchase": true,
"can_purchase_with_active_subscription": false,
"reason": "purchase_allowed"
}
}
Purchase not allowed - package already active¶
HTTP 200 OK
{
"item": {
"can_purchase": false,
"can_purchase_with_active_subscription": true,
"reason": "package_already_active"
}
}
Eligibility Reasons¶
| Reason | Description |
|---|---|
purchase_allowed |
The customer is eligible to purchase the product |
package_already_active |
The customer already has an active subscription for this package |
base_package_already_active |
The customer already has the base package that this campaign is based on |
campaign_already_purchased |
The customer has already purchased this campaign |
campaign_purchase_rules_does_not_permit_purchase |
Campaign purchase rules prevent this purchase |
account_archived |
The customer's account has been archived |
account_inactive |
The customer's account is inactive |
Errors¶
This API uses the common error conventions of the Payway API