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. It will run package and campaign purchase rules and try to make sure no duplicate purchases are made.

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

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 wether a purchase of the package/campaign would be possible.
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,
    "reason": "purchase_allowed"
  }
}

Errors

Example error response

HTTP 400 Bad Request
{
    "code": "invalid_parameter",
    "field": "period_id",
    "message": "Parameter must match format (/^[a-f\d]{24}$/)"
}

HTTP 400 Bad Request

Name Type Description
invalid_parameter Object Validation error on any of the fields in the posted json
json_parser_error Object The request body could not be parsed as valid json
invalid_content_type_error Object The requests Content-Type header isn't set to application/json
unknown_parameter Object One or more of the fields in the posted json was not recognized