Payment
Endpoint Info
METHOD | URL |
---|---|
POST | /orders/{orderId}/pay |
EXAMPLE | https://test.api.macropay.com/v2/orders/{orderId}/pay |
Overview
The payment form of the Revup SDK gathers all required information to call this endpoint automatically on submit, therefore you only need to send requests to it when charging recurring payments with a token. For the latter case, you need to provide the order ID generated in the previous step as a path parameter, the token ID generated in the initial recurrence within the data attribute and the paymentMethod attribute set to credit_card_token (it must have always that value for recurring payments).
For the latter case:
- Provide the order ID generated in the previous step as a path parameter
- Provide the token ID generated in the initial recurrence within the data attribute
- Set the
paymentMethod
tocredit_card_token
(it must have always that value for recurring payments)
The payment form of the Revup SDK also manages the returned API response. However you will need to do it yourself for merchant initiated transactions. The response of this endpoint indicates the associated transaction ID, transaction status, message and / or error. There are 4 possible statuses, and depending on the payment being synchronous, asynchronous or requiring 3DS authentication, the retrieved status could not be the final. Be aware that a 200 API response does not mean the payment was successful, it only means that Revup was able to process your request and forward it to the provider. However a non-200 API response always means the payment has failed.
- A 200 response means Revup processed the request and forwarded it to the provider, not that the payment was successful.
- A non-200 response means the payment failed.
3DS Payments Behavior
When payments undergo a 3DS process, they are always managed asynchronously, meaning that their first reported status will be either in_process or waiting_user_interaction:
Status: in_process
- Merchants must wait for the transaction to change its status, which can be reported via redirectUrl, notification, or retrieving the transaction information from the Revup API. The status change might take seconds or minutes, depending on the case.
Status: waiting_user_interaction
- The transaction will contain an action object. It holds the required parameters to perform the 3DS process: mainly the HTTP method and URL to redirect the user to the challenge, and optionally the headers and additional parameters that some providers require (the method and data for the challenge request depends entirely on the PSP and not on Revup). Once the user completes that step, they will be redirected to the URL provided in the order or to the default URL in the merchant configuration.
If the payment does not reach a final status, Revup will handle resolution via supplier status polling.
Request Body Example – Perform Payment
{
"data": "43d2c921-2cba-49a6-aada-c80c37362dc3",
"paymentMethod": "credit_card_token"
}
SUCCESS RESPONSES - PERFORM PAYMENT
HTTP CODE | DESCRIPTION |
---|---|
200 | Response contains the transaction ID, the success status and the message “The payment has been processed successfully” in JSON format. It means the connection with the issuer and the payment were successful. |
200 | Response contains the transaction ID, the failed status and the message “The payment has failed” in JSON format. It means the connection with the issuer was successful but the payment was not processed or the authentication information was not enough or invalid. In this case, a more specific message will be sent through the callback to redirectURL. |
200 | Response contains the transaction ID, the in_process status and the message “The payment is being processed” in JSON format. It means the connection with the issuer was successful but the final payment status is not known yet. |
200 | Response contains the transaction ID, the waiting_user_interaction status, the action object and the message “The payment is being processed” in JSON format. It means the connection with the issuer was successful but it requires the user to be redirected to a 3DS challenge. |
Success Response Example – Perform Payment
{
"transactionStatus": "waiting_user_interaction",
"message": "The payment is being processed",
"transactionId": "433296ec-a1cd-47b3-bf3a-db87d5926262",
"action": {
"url": "https://www.redirect-url-domain.es",
"method": "POST",
"headers": [
{
"key": "authReq",
"value": "YYYYXXXX"
},
{
"key": "headerReq",
"value": "AAAXXYYYYZZZZZ"
}
],
"parameters": [
{
"key": "connector",
"value": "THREEDSECURE"
},
{
"key": "PaReq",
"value": "XXXXYYYYZZZZZ"
}
]
},
"version": 2
}
Error Responses
HTTP CODE | ERROR CODE | ERROR MESSAGE | DESCRIPTION |
---|---|---|---|
400 | 0905 | Problem Parsing Request | The request syntax is incorrect. |
400 | 0300 | Invalid Request | The request body does not match the JSON schema, the order ID is not an UUID, the token is not valid or the decoded ciphered data has not some required field / has unexpected or invalid parameters. |
400 | 0108 | Transaction Not Found | The order does not exist nor has it been processed. It might be created but also expired. |
400 | 0906 | Request Already Processed | Orders can only be processed once, if it was already used a new order must be created. |
400 | 0303 | Invalid Card Number | The card number might be written incorrectly, maybe with hyphens and / or spaces. |
400 | 0306 | Invalid Cardholder Name | The cardholder name must be provided. |
400 | 0309 | Invalid CVV | The value should be a number of three or four digits. |
400 | 0310 | Invalid Expiry Date | The card month and year must represent a valid date above the current one. |
400 | 0312 | Missing or Invalid Data | The requested payment has invalid or missing data. Remember that the credit card token method is only valid to pay recurrences or consumer initiated payments and the credit card ciphered data method only allows credit card payments or initial recurrences. |
400 | 0150 | Recurring Data Reference Not Available | A recurring or final recurrence requires a parent transaction ID indicated in the order belonging to a successful initial recurrence which is not associated with any final recurrence. |
400 | 0151 | Token Not Found | The provided token does not exist in the system. |
400 | 0204 | Expired Card | The credit card related to the token has an expired expiration date. |
400 | 0907 | Configuration Error - MID Required | There is not a correctly configured MID for these parameters. |
403 | - | User is not authorized to access this resource with an explicit deny | This response is returned when the user is not authorized to access to this resource |
500 | 0900 | Internal Server Error | The server experienced an unexpected error. |
Error Response Example – Perform Payment
{
"transactionStatus": "failed",
"error": {
"code": "0300",
"message": "Invalid Request"
}
}