/v1/transactions

Initialize a Secure Fields transaction

Changed on

Proceed with the steps below to process Secure Fields payment transactions:

  • Call the /v1/transactions/secureFields endpoint to retrieve a transactionId. The success result of this API call is a HTTP 201 status code with a transactionId in the response body.
  • Initialize the SecureFields JavaScript library with the returned transactionId:
var secureFields = new SecureFields();
secureFields.init(
    transactionId, {
        cardNumber: "cardNumberPlaceholder",
        cvv: "cvvPlaceholder",
    });
  • Handle the success event of the secureFields.submit() call. Example success event data:
{
    "event":"success",
    "data": {
        "transactionId":"{transactionId}",
        "cardInfo":{"brand":"MASTERCARD","type":"credit","usage":"consumer","country":"CH","issuer":"DATATRANS"},
        "redirect":"https://pay.sandbox.datatrans.com/upp/v1/3D2/{transactionId}"
    }
}
  • If 3D authentication is required, the redirect property will indicate the URL that the browser needs to be redirected to.
  • Use the Authorize an authenticated transaction endpoint to authorize the Secure Fields transaction. This is required to finalize the authorization process with Secure Fields.
  • Use the transactionId to check the status and to settle, cancel or credit (refund) a transaction.
post/v1/transactions/secureFields

Request

  • Base URL
    https://api.sandbox.datatrans.com
  • URL
    https://api.sandbox.datatrans.com/v1/transactions/secureFields
  • Auth
    HTTP basic

Request body

amountinteger

The amount of the transaction in the currency’s smallest unit. For example use 1000 for CHF 10.00.

currencystring required

3 letter <a href='https://en.wikipedia.org/wiki/ISO_4217' target='_blank'>ISO-4217</a> character code. For example CHF or USD

returnUrlstring

The URL where the browser will be redirected after the 3D authentication process. Required unless authentication.apply is explicitly set to false.

returnMethod'GET' | 'POST'

The preferred HTTP method for the redirect request (GET or POST).

returnResourcesboolean

If true, JavaScript resources with Subresource Integrity (SRI) information are returned in the response.

Response

Transaction successfully initialized

transactionIdstring

The transactionId to be used when calling SecureFields.init(). If no further action happens with the transactionId after initialization, it will be invalidated after 30 minutes.

Example response

{
  "resources": [
    {
      "uri": "https://pay.datatrans.com/upp/payment/js/secure-fields-2.0.0.js",
      "integrity": "sha384-Base64EncodedHashValue"
    }
  ]
}

Changes