Additional parameters can be transferred in the request, for example:
description – invoice description,phone – phone number linked to the wallet;account – card number;The list of these parameters depends on the payway (payway). The required additional parameters for the payway can be found in the request “Getting payment methods for input” shop_input_config/shop in the add_ons_config response field.
If the request is successful, API will return the parameters necessary to redirect the user to the payment system for payment. These parameters will be in the data field of the response. The data.data field contains the parameters to be transferred during redirection (in the form of GET or POST request parameters).
The redirection method depends on the method parameter. The generated request must be sent to the URL specified in the url field of the data field.
For example, if you receive a POST in the method parameter to redirect a client to pay an invoice, you need to generate an HTML form from the parameters received in the response body (these parameters will differ for different payment systems).
An example of forming an HTML form using the jinja2 template language:
<form method="POST" action="{{ data['url'] }}">
{% for param, value in data['data'].items() %}
<input name="{{ param }}" value="{{ value }}" />
{% endfor %}
</form>
For the data specified in the example response below, the following HTML form will be obtained:
<form method="POST" action="https://example.checkout.com/form/">
<input name="transaction_id" value="1231" />
<input name="payment_type" value="card" />
<input name="fail_url" value="https://example.com/payment/?status=fail" />
<input name="success_url" value="https://example.com/payment/?status=success" />
<input type="submit" />
</form>
In case of "method": "GET" it is required to perform HTTP redirect to the URL with the parameters (using percent‐encoding), received in the data.data response field.
The URL is generated according to the following algorithm:
import urllib.parse
redirect_url = '{url}?{parameters}'.format(url=data['url'], parameters=urllib.parse.urlencode(data['data']))
An example of the formed URL: https://example.checkout.com/form/?transaction_id=1231&payment_type=card&fail_url=https%3A%2F%2Fexample.com%2Fpayment%2F%3Fstatus%3Dfail&success_url=https%3A%2F%2Fexample.com%2Fpayment%2F%3Fstatus%3Dsuccess
Please note that the parameters failed_url, success_url, callback_url, callback_rejected_url specified in the shop settings have priority over those specified in request. If you want to use unique url for each request, you need to inform the manager about it.
For 3ds 2.0 payments with card data to be successful, the payer’s browser information must be collected.
You can collect the data yourself or let our service perform this for you. If you collect the data on your end, please ensure that all the necessary values are included to the payment initiation request /invoice/create.
As an example, the provided JavaScript code could be employed to obtain the Payer Browser information. Please be aware that the client_info fields provided below do not include browser_accept_header.
let client_info = {
"browser_java_enabled": window.navigator.javaEnabled(),
"browser_javascript_enabled": true,
"browser_language": window.navigator.language,
"browser_color_depth": window.screen.colorDepth.toString(),
"browser_screen_height": window.screen.height.toString(),
"browser_screen_width": window.screen.width.toString(),
"browser_tz": (new Date()).getTimezoneOffset().toString(),
"browser_user_agent": window.navigator.userAgent,
"challenge_window_size": "05"
}
If the payer’s browser data is not provided in the /invoice/create request, it will be necessary to redirect the payer to our service as an intermediate step using a data object, so that our service can collect the necessary browser data. See Redirecting to invoice payment forms for the details on redirect.
Fields involved in request signature generation:
amountcurrencypaywayshop_idshop_order_idDocumentation Index
Fetch the complete documentation index at: https://docs.m4psp.com/llms.txt
Use this file to discover all available pages before exploring further.
Every API request must be signed so that we can identify your account.
The signature is transferred in the request body through the sign parameter, for example:
{
"shop_id": 1520,
"shop_order_id" : "5b0efa8a-153b-4421-abac-2aba4d772a86",
"amout": "6320.91",
"currency": 840,
"payway": "card_invoice_usd",
"description": "Payment for shop_id=1520",
"sign": "77a6f7a30876d480d4e771d08cb83800dd5cb874664c77e515ffc052b20293c6"
}"sign" parameter, nevertheless your real requests must include it in the request body where required.
Signature line is generated according to the following algorithm: all request parameters involved in signature generation are ordered in the alphabetical order of keys, the values are concatenated with a colon (":") and the account secret key is added at the end (without the: sign), a sha256 hash is generated from the resulting line and its hex representation is passed in the sign request parameter.
Fields involved in request signature generation:
shop_idshop_order_idamountcurrencypayway"amount", "currency", "payway", "shop_id", "shop_order_id"
"6320.91:840:card_invoice_usd:1520:5b0efa8a-153b-4421-abac-2aba4d772a86account-secret-key"
Where account-secret-key is the secret identification key for your account. You can request a key from the support service.
>>> string_to_sign = '6320.91:840:card_invoice_usd:1520:5b0efa8a-153b-4421-abac-2aba4d772a86account-secret-key'
>>> import hashlib
>>> sign = hashlib.sha256(string_to_sign.encode()).hexdigest()
>>> print(sign)
'77a6f7a30876d480d4e771d08cb83800dd5cb874664c77e515ffc052b20293c6'Unique shop identifier in the M4 system.
1520
Order ID in your system. Must be unique for each new invoice.
255"5b0efa8a-153b-4421-abac-2aba4d772a86"
Amount received or withdrawn.
Example: "227.34"
"6320.91"
Payment way for payment. Invoice currency depends on the specified payment way.
There are two ways to get a list of all payment directions available to the shop:
150^[A-Za-z_,\[\]]+$"card_payway_usd"
Payer IP address
"192.168.1.1"
Optional payment description.
255"Payment for shop_id=1520"
URL where the payer will be redirected after unsuccessful invoice payment.
"https://your-domain.com/status/failed/"
URL where the payer will be redirected after successful invoice payment.
"https://your-domain.com/status/success/"
URL where the notification about successful payment will be sent.
"https://your-domain.com/status/callback/"
URL where the notification about unsuccessful payment will be sent.
"https://your-domain.com/status/rejected/"
Bank card details should be sent when:
In case the payment way to the cards is used and the card data is not transmitted, the response to the request will contain a link to redirect the buyer to enter the card details.
Also, method, url and data will be filled in if the user needs to be redirected to pass the 3DSecure check.
This parameter is used to generate a payment token. More details invoice/recurrent
false
Payer browser information.
See Payer Browser Authentication for 3D Secure for the details of the data gathering.
Boolean value, in case of successful response it will be true, in case of error – false
true
A textual description of the error, in case of success - simply Ok
"Ok"
If this value is greater than 0, then the request ended with an error. Description of error codes
0