3.20. /api/v4/tokenize/create-ephemeral-ticket

Introduction

Ephemeral ticket creation is initiated through HTTPS POST request by using URLs and the headers specified below. The request is signed with OAuth 1.0a — for example OAuth RSA-SHA256, as in the examples on this page; other signature methods are supported as well, see Request Authentication Methods.

The ticket is used by the card fields of Hosted Fields: the Connecting Party server requests it and embeds it into the payment page. Tokenization must be enabled on the Endpoint, and the Endpoint must belong to the login the request is signed with.

A ticket is of one of two kinds, chosen by the request:

  • without card_recurring_payment_id — for the card fields (number, expiry date and CVV), see Step 1;

  • with card_recurring_payment_id — only for the CVV of that saved card, see Saved Card: CVV Only.

A ticket of the wrong kind is declined at tokenization with 4005 and is not spent.

API URLs

Note

The path in API URL should not be hardcoded, as it may be changed in future.

Integration

Production

https://sandbox.payments.cx/paynet/api/v4/tokenize/create-ephemeral-ticket/ENDPOINTID

https://gate.payments.cx/paynet/api/v4/tokenize/create-ephemeral-ticket/ENDPOINTID

Request Headers

Header

Description

Authorization

OAuth 1.0a signature of the request, see Authorization headers. oauth_consumer_key is the Connecting Party’s login.

Content-Type

application/x-www-form-urlencoded when card_recurring_payment_id is sent. Without parameters the request has no body (Content-Length: 0).

Request Parameters

The Endpoint is taken from the URL, the Connecting Party from the Authorization header. The only parameter is optional; like any POST parameter it is part of the OAuth signature base string, so it cannot be changed without the signing key.

Parameter name

Description

Value

card_recurring_payment_id

The saved card the CVV is collected for. The ticket is issued only if the card is available to the Endpoint and can be charged with card_recurring_payment_id (a source card). Such a ticket is good only for the CVV tokenization of this card, and the CVV token it produces is accepted only in a payment with this card_recurring_payment_id.

Necessity: Optional
Type: Long

Response Parameters

Note

A successful response has status 200 and Content-Type: application/json. A request failing the signature check is answered with status 403 and the body type=error&serial-number=…&error-message=…&error-code=…. Other rejections are answered with status 400 or 401 and an x-www-form-urlencoded body with the parameters below.

Parameter name

Description

Format

ephemeralTicket

Single-use ticket passed to the Hosted Fields SDK on the payment page. Issued for the Endpoint from the URL, valid for 15 minutes and consumed by a single tokenization.

Type: String

error-id

Only in a rejection. Identifier of the error, to be quoted to support.

Type: String

message

Only in a rejection. The reason the request was rejected.

Type: String

code

Only in a rejection. Numeric code: 4006 — card_recurring_payment_id is not available, see below; 4900 — the ticket could not be issued on the Payer-Gateway side.

Type: Integer

A 400 with code=4006 means the card_recurring_payment_id cannot be used for this ticket: it is empty or not a number, does not exist, does not belong to the Endpoint, or is not a card the Endpoint may charge. The reasons are deliberately not distinguished. This is a mistake in the request — correct the card_recurring_payment_id instead of repeating the same request.

A 403 means the request failed the signature check or authentication. Most common: the server clock is outside the oauth_timestamp window (10 minutes by default), oauth_nonce is reused, the Endpoint does not belong to the login from oauth_consumer_key, or a wrong signing key is configured on the Endpoint. The body does not name the reason (error-message is usually Forbidden); it is recorded on the Payer-Gateway side — quote serial-number to support.

A 401 with code=4900 means the ticket could not be issued on the Payer-Gateway side. Repeat the request later; if it persists, quote error-id to support.

Request Example

POST /paynet/api/v4/tokenize/create-ephemeral-ticket/ENDPOINTID HTTP/1.1
Host: sandbox.payments.cx
Authorization: OAuth oauth_consumer_key="MERCHANTLOGIN",
                     oauth_signature_method="RSA-SHA256",
                     oauth_timestamp="...", oauth_nonce="...", oauth_version="1.0",
                     oauth_signature="..."
Content-Length: 0

Request for a Saved Card Example

POST /paynet/api/v4/tokenize/create-ephemeral-ticket/ENDPOINTID HTTP/1.1
Host: sandbox.payments.cx
Authorization: OAuth oauth_consumer_key="MERCHANTLOGIN",
                     oauth_signature_method="RSA-SHA256",
                     oauth_timestamp="...", oauth_nonce="...", oauth_version="1.0",
                     oauth_signature="..."
Content-Type: application/x-www-form-urlencoded

card_recurring_payment_id=1234567

Success Response Example

HTTP/1.1 200 OK
Content-Type: application/json

{
  "ephemeralTicket": "eyJhbGciOi..."
}

Fail Response Example

HTTP/1.1 403 Forbidden

type=error
&serial-number=00000000-0000-0000-0000-000000000001
&error-message=Forbidden
&error-code=102
HTTP/1.1 401 Unauthorized

error-id=6f1f0b0e-1c2a-4c1e-9a3e-2f7d5b8c9a10
&message=unexpected+exception
&code=4900
HTTP/1.1 400 Bad Request

error-id=0c5d2b8e-4f7a-4e21-b3a9-7d1e6f0a2c44
&message=card_recurring_payment_id+is+not+available+for+the+endpoint
&code=4006