Create a token from payment
Payments
The payments REST services allow you to initiate a payment, retrieve the payment details or perform specific actions like refunding or requesting capture of a payment. A payment is identified by its paymentId. Some payment products allow a two step approach allowing you to control when the authorization takes place separate from when the funds are actually captured.
Request
Use this call if you want to convert the payment details into a re-usable token. This call is especially useful if you don't have access to sensitive data like card data, but you have processed transaction successfully based on card data that has been collected either using our MyCheckout hosted payment pages or through one of the Client SDKs that encrypted this data.
PayloadTokenizePaymentRequest
Properties
|
|||
Property | Type | Required | Details |
---|---|---|---|
alias | string (100) | no | read close |
close
DescriptionAn alias for the token. This can be used to visually represent the token.
If no alias is given, a payment product specific default is used, e.g. the obfuscated card number for card payment products. Do not include any unobfuscated sensitive data in the alias. |
Request example
This scenario you will probably use the most
-
var body = new TokenizePaymentRequest(); body.Alias = "Some alias"; var response = await client.V1.WithNewMerchant("merchantId").Payments.Tokenize("paymentId", body);
Responses
Please find below an overview of the possible responses.
Response 200 - OKCreateTokenResponse
A new token has not been created as one already existed. You will get this response if you tried to create a token for a card that has already been tokenized for this merchantId. You should verify if you would like to update the data that is stored in the existing token as no data is updated when a duplicate token is detected. The only way to update the data stored in a token you will need to use the update token call.
Properties
|
|||
Property | Type | Required | Details |
---|---|---|---|
isNewToken | boolean | no | read close |
close
DescriptionIndicates if a new token was created
|
|||
originalPaymentId | string | no | read close |
close
DescriptionThe initial Payment ID of the transaction from which the token has been created
|
|||
token | string | no | read close |
close
DescriptionID of the token
|
Response example
This scenario you will probably use the most
-
{ "isNewToken" : false, "token" : "bfa8a7e4-4530-455a-858d-204ba2afb77e" }
Response 201 - CreatedCreateTokenResponse
A new token has been created based on the payment data stored in the payment object.
Properties
|
|||
Property | Type | Required | Details |
---|---|---|---|
isNewToken | boolean | no | read close |
close
DescriptionIndicates if a new token was created
|
|||
originalPaymentId | string | no | read close |
close
DescriptionThe initial Payment ID of the transaction from which the token has been created
|
|||
token | string | no | read close |
close
DescriptionID of the token
|
Response example
This scenario you will probably use the most
-
{ "isNewToken" : true, "token" : "bfa8a7e4-4530-455a-858d-204ba2afb77e" }
Response 400 - Bad requestErrorResponse
Properties
|
|||
Property | Type | Required | Details |
---|---|---|---|
errorId | string | yes | read close |
close
DescriptionUnique reference, for debugging purposes, of this error response
|
|||
array of object | yes | read close | |
close
DescriptionList of one or more errors
|
|||
object | no | read close | |
category | string | no | read close |
close
DescriptionCategory the error belongs to. The category should give an indication of the type of error you are dealing with.
Possible values:
|
|||
code | string | yes | read close |
close
DescriptionError code
|
|||
httpStatusCode | integer | no | read close |
close
DescriptionHTTP status code for this error that can be used to determine the type of error
|
|||
id | string | no | read close |
close
DescriptionID of the error. This is a short human-readable message that briefly describes the error.
|
|||
message | string | no | read close |
close
DescriptionHuman-readable error message that is not meant to be relayed to customer as it might tip off people who are trying to commit fraud
|
|||
propertyName | string | no | read close |
close
DescriptionReturned only if the error relates to a value that was missing or incorrect.
Contains a location path to the value as a JSonata query. Some common examples:
|
|||
requestId | string | no | read close |
close
DescriptionID of the request that can be used for debugging purposes
|
Response example
This scenario you will probably use the most
-
{ "errorId" : "15eabcd5-30b3-479b-ae03-67bb351c07e6-00000092", "errors" : [ { "code" : "20000000", "propertyName" : "bankAccountBban.accountNumber", "message" : "PARAMETER_NOT_FOUND_IN_REQUEST" } ] }
Response 404 - Not foundErrorResponse
The payment you are trying to convert into a token could not be found.
Properties
|
|||
Property | Type | Required | Details |
---|---|---|---|
errorId | string | yes | read close |
close
DescriptionUnique reference, for debugging purposes, of this error response
|
|||
array of object | yes | read close | |
close
DescriptionList of one or more errors
|
|||
object | no | read close | |
category | string | no | read close |
close
DescriptionCategory the error belongs to. The category should give an indication of the type of error you are dealing with.
Possible values:
|
|||
code | string | yes | read close |
close
DescriptionError code
|
|||
httpStatusCode | integer | no | read close |
close
DescriptionHTTP status code for this error that can be used to determine the type of error
|
|||
id | string | no | read close |
close
DescriptionID of the error. This is a short human-readable message that briefly describes the error.
|
|||
message | string | no | read close |
close
DescriptionHuman-readable error message that is not meant to be relayed to customer as it might tip off people who are trying to commit fraud
|
|||
propertyName | string | no | read close |
close
DescriptionReturned only if the error relates to a value that was missing or incorrect.
Contains a location path to the value as a JSonata query. Some common examples:
|
|||
requestId | string | no | read close |
close
DescriptionID of the request that can be used for debugging purposes
|
Response example
This scenario you will probably use the most
-
{ "errorId" : "657b10da-d2f9-4088-a948-bf190ef516b1-00000261", "errors" : [ { "code" : "400300", "message" : "PAYMENTATTEMPT_NOT_FOUND" } ] }