If PIN checking has been set up for purchases in your deployment, the client application uses version 2 of the purchase request. It works like Making a purchase, but it also takes the PIN that the user entered, and the platform checks the PIN before it makes the purchase. See Server-side PIN checks in PIN and parental control management.
Version 2 works only where PIN checking has been set up for purchases. Otherwise it returns an HTTP 500 status. Ask your NAGRAVISION representative whether your deployment uses it.
Request
To make a purchase with a PIN, send a POST request to:
https://<host>:<port>/purchase_service/v2/user/product/actions/purchase
Headers
-
Authorization– the client's access token, as a bearer token (Bearer <access token>). This is theaccess_tokenthat the client gets when it signs in – see Authentication token. This header is mandatory. -
Content-Type: application/json -
x-correlation-id– identifier for logging, to correlate messages across a call flow
Mandatory arguments
The following argument is in the request body:
-
productId– the ID of the product to be purchased
Other arguments
The following argument is in the request body:
-
pin– the PIN that the user entered. Required when the deployment's PIN policy for purchases makes the PIN mandatory. Otherwise it is ignored.
Example
A request with this payload purchases the product with the specified ID, supplying the PIN:
{
"productId": "1234DFG5sd",
"pin": "1234"
}
Response
A successful request returns an HTTP 201 status, for example:
{
"productId": "1234DFG5sd",
"purchaseAuthRequestReference": "CRM_PARTNER_AUTH_REQUEST_REFERENCE/X-CORRELATION-ID"
}
A bad request returns an HTTP 400 status – for example, if a PIN is required but the request has no pin ("errorCode": "4106"), or if there is no productId.
An unauthorised request returns an HTTP 401 status ("errorCode": "1001") if the account has no PIN of the type that is checked.
A forbidden request returns an HTTP 403 status – for example:
-
"errorCode": "4566"– the PIN is wrong. -
"errorCode": "7123"– the PIN is wrong and the user has a limited number of attempts left, or the PIN is locked after too many wrong attempts. -
The access token is missing, invalid, or has expired, or the purchase is not allowed.
For example, a wrong PIN returns:
{
"errorCode": "4566",
"status": 403,
"message": "Pin value does not match Account Pin set for type parentalPin of account account7",
"purchaseAuthRequestReference": "9a62e5f9-6015-46bd-9a65-e7f3136ccb3c"
}
In Purchase Service error responses, errorCode is a string.
If the specified product does not exist, the request returns an HTTP 404 status.
If PIN checking has not been set up for purchases in the deployment, the request returns an HTTP 500 status ("errorCode": "3005").
See also
-
Making a purchase (version 1, without a PIN check)
-
See Managing purchases for an explanation of how to integrate a CRM with the Purchase Service.
-
For full details of this API, see the Purchase Service API documentation.