Skip to content

Pre-validate purchase

/me/order/pre_validate_purchase

Target audience: Developers

Release version: 4.3.5

Pre-validate purchase

Introduction

This endpoint is used to pre-validate a order for an authenticated user. The following criterion will be checked:

  • Whether the customer already has the package they are attempting to purchase.
  • Whether the customer already has the campaign they are attempting to purchase.
  • Whether the customer already has the base package of the campaign they are attempting to purchase.
  • Whether campaign purchase rules exist for the campaign they are attempting to purchase.

If you are only interested in validating configured campaign purchase rules rather than the entire list above, we recommend using the Eligible for campaign endpoint instead.

URI

Environment URI
Stage https://payway-api.stage.adeprimo.se/external/api/v1/me/order/pre_validate_purchase
Production https://backend.worldoftulo.com/external/api/v1/me/order/pre_validate_purchase

Requirements

Identity Scope
Yes /external/me/order/w

Parameters

Field Required Type Description
product_code Required String The product code for a package/campaign that should be pre validated.
Size range: 1..1024
subscription_extension Optional Boolean Decides whether the pre-purchase validation should follow the rules of a normal purchase or a subscription extension purchase. Defaults to false.
article_purchase Optional Boolean Decides whether the pre-purchase validation should follow the rules of a normal purchase or a article purchase. Defaults to false.
article_id Optional String The identifying string that should be used to validate whether the customer already has access to this article, or not. Required if the article_purchase flag is set to true.

Curl Example

curl --request GET \
  --url 'https://payway-api.stage.adeprimo.se/external/api/v1/me/order/pre_validate_purchase?product_code=some_product_code' \
  --header 'Accept: application/json' \
  --header 'Authorization: Bearer <insert identity token here>'

Response

Field Description
can_purchase Boolean stating whether a purchase of the package/campaign would be possible.
can_purchase_base_package Boolean stating whether a purchase of the base package would be possible. For a package this is the package itself and mirrors can_purchase. For a campaign this is the base package the campaign is based on, evaluated separately (e.g. can_purchase may be false because the campaign was already purchased, while can_purchase_base_package is true because the customer does not have the base package).
reason Code describing why can_purchase is true or false. Possible values:
campaign_purchase_rules_does_not_permit_purchase
campaign_already_purchased
package_already_active
base_package_already_active
purchase_allowed
{
  "item": {
    "can_purchase": true,
    "can_purchase_base_package": true,
    "reason": "purchase_allowed"
  }
}

Errors

This API uses the common error conventions of the Payway API

See common error responses