### Register Pre-Auth GET Request Example Source: https://alfabank.ru/sme/payservice/internet-acquiring/docs/connection-options/api/rest_rp-menuopen=undefined Example of a GET request to register a pre-authorization. It includes parameters for amount, currency, language, order number, return URL, username, JSON parameters, page view, and merchant login. ```http https://alfa.rbsuat.com/payment/rest/registerPreAuth.do?amount=100¤cy=810&language=ru&orderNumber=87654321&password=password&returnUrl=https://alfa.rbsuat.com/payment/finish.html&userName=userName&{jsonParams="param1»:"value1»,"param2»:"value2"}&pageView=MOBILE&merchantLogin=merch_child ``` -------------------------------- ### Register Pre-Auth POST Request Example Source: https://alfabank.ru/sme/payservice/internet-acquiring/docs/connection-options/api/rest_rp-menuopen=undefined Example of a POST request to register a pre-authorization. It includes parameters such as amount, currency, language, order number, return URL, page view, JSON parameters, and merchant login. Note that the format differs from the GET request. ```http amount=100¤cy=810&language=ru&orderNumber=87654321&returnUrl=https://alfa.rbsuat.com/payment/finish.html&pageView=MOBILE&{jsonParams="param1»:"value1»,"param2»:"value2"}&merchantLogin=merch_child ``` -------------------------------- ### AlfaBank API GET Request Example Source: https://alfabank.ru/sme/payservice/internet-acquiring/docs/connection-options/api/rest_rp-menuopen=1 Example of a GET request to retrieve last orders for merchants from the AlfaBank API. It includes parameters for authentication, filtering by date and transaction state, and pagination. ```URL https://alfa.rbsuat.com/payment/rest/getLastOrdersForMerchants.do?userName=userName&password=password&language=ru&page=0&size=100&from=20141009160000&to=20141111000000&transactionStates=DEPOSITED,REVERSED&merchants=SevenEightNine&searchByCreatedDate=false ``` -------------------------------- ### PHP Integration Example for Payment Gateway Source: https://alfabank.ru/sme/payservice/internet-acquiring/docs/connection-options/api/code-example This section provides a PHP code example demonstrating how to integrate with the payment gateway using SOAP. It includes constants for connection details, a custom SoapClient class for authentication, and logic for handling payment registration. ```APIDOC ## PHP Integration Example for Payment Gateway ### Description This code demonstrates how to integrate with the payment gateway using SOAP in PHP. It includes setup for connection credentials, a custom `Gateway` class that extends `SoapClient` to handle WS-Security authentication, and example logic for registering single-stage (`registerOrder`) or two-stage (`registerOrderPreAuth`) payments. ### Method POST (for form submission) ### Endpoint `/ws.php` (example, actual endpoint might vary) ### Parameters #### Request Body (for form submission) - **orderNumber** (string) - Required - The merchant's unique order number. - **amount** (string) - Required - The payment amount. ### Request Example (Form Submission) ```html
``` ### Code Structure ```php __setSoapHeaders($this->generateWSSecurityHeader()); return parent::__call($method, $data); } } // Form Display (GET request) if ($_SERVER['REQUEST_METHOD'] == 'GET' && !isset($_GET['orderId'])) { // HTML form for order details echo ''; } // Form Processing (POST request) else if ($_SERVER['REQUEST_METHOD'] == 'POST') { $client = new Gateway(WSDL); $data = array('orderParams' => array( 'returnUrl' => RETURN_URL, 'merchantOrderNumber' => urlencode($_POST['orderNumber']), 'amount' => urlencode($_POST['amount']) )); // Registering a single-stage payment $response = $client->__call('registerOrder', $data); // Alternatively, register a two-stage payment: // $response = $client->__call('registerOrderPreAuth', $data); if ($response->errorCode != 0) { echo 'Error #' . $response->errorCode . ': ' . $response->errorMessage; } } ?> ``` ### Response #### Success Response (from `registerOrder` or `registerOrderPreAuth`) - **orderId** (string) - The order number generated by the payment system. - **formUrl** (string) - The URL of the payment form to redirect the client to. #### Error Response - **errorCode** (integer) - An error code indicating the type of error. - **errorMessage** (string) - A description of the error. ### Error Codes - `0`: Request processed without system errors. - `1`: Order with this number is already registered; Invalid order number. - `3`: Unknown (forbidden) currency. - `4`: Missing required request parameter. - `5`: Request parameter value error. - `7`: System error. ``` -------------------------------- ### API Integration Code Examples Source: https://alfabank.ru/sme/payservice/internet-acquiring/docs/connection-options/api/code-example_rp-menuopen=undefined Provides code examples for integrating with the payment gateway using various programming languages. ```APIDOC ## API Integration Code Examples ### Description Provides code examples for integrating with the payment gateway using various programming languages, with a specific example for PHP. ### Method GET ### Endpoint /websites/alfabank_ru_sme_payservice_internet-acquiring_connection-options_api ### Parameters #### Query Parameters - **section** (string) - Optional - Specifies the section of the documentation to retrieve. ### Request Example ``` GET /websites/alfabank_ru_sme_payservice_internet-acquiring_connection-options_api?section=php_integration_example ``` ### Response #### Success Response (200) - **code_example** (string) - A code snippet demonstrating integration with the payment gateway. #### Response Example ```json { "code_example": "" } ``` ``` -------------------------------- ### Code Examples for Gateway Integration Source: https://alfabank.ru/sme/payservice/internet-acquiring/docs/connection-options/api/index This section offers code examples in PHP for integrating with the payment gateway using both Web-Service and REST interfaces. ```APIDOC ## Code Examples for Gateway Integration ### Description Provides PHP code examples for integrating with the payment gateway via Web-Services and REST. ### Method N/A (Code examples) ### Endpoint N/A (Code examples) ### Parameters N/A ### Request Example ```php // Example for Web-Service Integration // ... code ... // Example for REST Integration // ... code ... ``` ### Response N/A ``` -------------------------------- ### Complete Order Payment Response Example (JSON) Source: https://alfabank.ru/sme/payservice/internet-acquiring/docs/connection-options/api/rest_rp-menuopen=1 This is an example of a response when completing a pre-authorized order payment using the deposit.do REST API. ```JSON { "errorCode»: 0 } ``` -------------------------------- ### Register Pre-Auth Response Example Source: https://alfabank.ru/sme/payservice/internet-acquiring/docs/connection-options/api/rest_rp-menuopen=undefined Example JSON response after a successful pre-authorization registration. It contains the unique order ID generated by the payment system and the URL for the payment form. ```json { "orderId": "61351fbd-ac25-484f-b930-4d0ce4101ab7", "formUrl": "https://alfa.rbsuat.com/payment/merchants/test/mobile_payment_ru.html?mdOrder=61351fbd-ac25-484f-b930-4d0ce4101ab7" } ``` -------------------------------- ### Example POST Request for Order Status Source: https://alfabank.ru/sme/payservice/internet-acquiring/docs/connection-options/api/e-com_rp-menuopen=1 This code snippet demonstrates an example of a POST request to retrieve the order status. It includes parameters like order ID, language, and merchant order number. ```http orderId=b9054496-c65a-4975-9418-1051d101f1b9&language=ru&merchantOrderNumber=0784sse49d0s134567890 ``` -------------------------------- ### PHP API Integration Example for Payment Gateway Source: https://alfabank.ru/sme/payservice/internet-acquiring/docs/connection-options/api/code-example_rp-menuopen=undefined Example code in PHP demonstrating how to integrate with the payment gateway. This snippet typically handles sending payment requests and processing responses. ```php $orderId, 'amount' => $amount, 'currency' => $currency, // ... other required parameters ]; $options = [ 'http' => [ 'header' => "Authorization: Bearer " . $apiKey . "\r\n" . "Content-type: application/json\r\n", 'method' => 'POST', 'content' => json_encode($data), ], ]; $context = stream_context_create($options); $response = file_get_contents($apiEndpoint, false, $context); if ($response === FALSE) { // Handle error return ['success' => false, 'message' => 'Payment processing failed.']; } $responseData = json_decode($response, true); // Process the response from the gateway if (isset($responseData['status']) && $responseData['status'] === 'success') { return ['success' => true, 'transaction_id' => $responseData['transaction_id']]; } else { return ['success' => false, 'message' => $responseData['error_message'] ?? 'Unknown error.']; } } // Example usage: // $result = processPayment('ORDER123', 100.50, 'RUB'); // print_r($result); ?> ``` -------------------------------- ### Payment Request Example (JSON) Source: https://alfabank.ru/sme/payservice/internet-acquiring/docs/connection-options/api/rest_rp-menuopen=1 This is an example of a JSON request payload for initiating a payment. It includes essential fields like order details, customer information, amount, currency, and URLs for redirection. ```json { "username": "test", "password": "testPass", "orderNumber": "UAF-203974-DE", "language": "RU", "preAuth": false, "description": "Test description", "additionalParameters": { "firstParamName": "firstParamValue", "secondParamName": "secondParamValue" }, "ip": "127.0.0.1", "amount": "230000", "currencyCode": 643, "failUrl": "https://test.ru", "returnUrl": "https://test_return.ru" } ``` -------------------------------- ### Initial Payment Scenario Source: https://alfabank.ru/sme/payservice/internet-acquiring/docs/connection-options/api/integration-schemes-r_rp-menuopen=1 This section details the step-by-step process of a customer making an initial payment using a bank card via the payment gateway. ```APIDOC ## Initial Payment Scenario ### Description This describes the flow for a customer completing an initial payment using a bank card on a store's resource, involving interaction with the payment gateway. ### Method N/A (Describes a process flow) ### Endpoint N/A (Describes a process flow) ### Parameters N/A ### Request Example N/A ### Response N/A ## Order Registration Request (REST) ### Description Initiates an order registration with the payment gateway, providing necessary details for processing a payment. ### Method POST ### Endpoint /register-order (Hypothetical REST endpoint) ### Parameters #### Query Parameters N/A #### Path Parameters N/A #### Request Body - **clientId** (string) - Required - Unique identifier of the client. - **amount** (number) - Required - The amount to be debited. - **orderNumber** (string) - Required - The order number in the store's system. - **returnUrl** (string) - Required - The URL to redirect the client back to after payment. ### Request Example ```json { "clientId": "unique-client-id-123", "amount": 1500.50, "orderNumber": "STORE-ORDER-XYZ", "returnUrl": "https://your-store.com/payment-result" } ``` ### Response #### Success Response (200) - **orderId** (string) - Unique identifier of the order in the payment system. - **formUrl** (string) - URL to redirect the user to for the payment form. #### Response Example ```json { "orderId": "payment-gateway-order-id-789", "formUrl": "https://payment-gateway.com/pay?order=payment-gateway-order-id-789" } ``` ## Order Status Check Request (REST) ### Description Retrieves the status of an order from the payment gateway using the order's unique identifier. ### Method GET ### Endpoint /order-status/{orderId} (Hypothetical REST endpoint) ### Parameters #### Path Parameters - **orderId** (string) - Required - The unique identifier of the order in the payment system. #### Query Parameters N/A #### Request Body N/A ### Request Example N/A ### Response #### Success Response (200) - **orderStatus** (string) - The current status of the order (e.g., SUCCESS, FAILED, PENDING). - **bindingId** (string) - Unique identifier of the card binding (if applicable and successful). #### Response Example ```json { "orderStatus": "SUCCESS", "bindingId": "unique-binding-id-abc" } ``` ## Extended Order Status Check Request (REST) ### Description Retrieves extended details about an order's status from the payment gateway. ### Method GET ### Endpoint /order-status/extended/{orderId} (Hypothetical REST endpoint) ### Parameters #### Path Parameters - **orderId** (string) - Required - The unique identifier of the order in the payment system. #### Query Parameters N/A #### Request Body N/A ### Request Example N/A ### Response #### Success Response (200) - **orderStatus** (string) - The current status of the order. - **bindingId** (string) - Unique identifier of the card binding. - Additional extended status details (specific fields depend on implementation). #### Response Example ```json { "orderStatus": "SUCCESS", "bindingId": "unique-binding-id-abc", "details": { "transactionId": "txn-12345", "paymentMethod": "CARD" } } ``` ``` -------------------------------- ### API Request Example - POST Method Source: https://alfabank.ru/sme/payservice/internet-acquiring/docs/connection-options/api/e-com_rp-menuopen=1 This example demonstrates a POST request for the Alfabank SME Payservice API, showing how to structure parameters like order details, currency, and customer information. It includes both basic order parameters and complex nested structures for order bundle details. ```text POST amount = 24000 & currency = 643 & language = ru & orderNumber = 01 a287222222299 & returnUrl = https: //alfa.rbsuat.com/payment/merchants/ecom2/finish.html& jsonParams = { "name1": "value1" } & merchantLogin = merch_child & taxSystem = 0 & orderBundle = { "orderCreationDate": "2013-07-12T13:51:00", "customerDetails": { "email": "email@email.com", "phone": "79851231234", "contact": "Mega Tester", "deliveryInfo": { "deliveryType": "courier", "country": "RU", "city": "Moscow", "postAddress": "Земляной Вал 50А стр.2" } }, "cartItems": { "items": [{ "positionId": "1", "name": "Metzeler Enduro 3 Sahara", "itemDetails": { "itemDetailsParams": [{ "value": "Metzeler ", "name": "brand" }, { "value": "17inch", "name": "radius" } ] }, "quantity": { "value": 0.71, "measure": "штук" }, "itemAmount": 8000, "itemCurrency": "643", "itemCode": "NM-15", "discount": { "discountType": "percent", "discountValue": "5" }, "agentInterest": { "interestType": "agentPercent", "interestValue": "7" }, "tax": { "taxType": 1, "taxSum": 111 }, "itemPrice": 11267 }, { "positionId": "2", "name": "Universal Mirror Enduro", "itemDetails": { "itemDetailsParams": [{ "value": "Noname", "name": "brand" }, { "value": "12mm", "name": "diameter" } ] }, "quantity": { "value": 1.0, "measure": "штук" }, "itemAmount": 8000, "itemCurrency": "643", "itemCode": "NM-15", "discount": { "discountType": "percent", "discountValue": "5" }, "agentInterest": { "interestType": " agentPercent ", "interestValue": "7" }, "tax": { "taxType": 1, "taxSum": 111 }, "itemPrice": 8000 } ] } } } } ``` -------------------------------- ### Add Order Parameters - GET Request Example (REST) Source: https://alfabank.ru/sme/payservice/internet-acquiring/docs/connection-options/api/rest_rp-menuopen=1 This example demonstrates how to add additional parameters to an order using a GET request to the addParams.do endpoint. It includes the base URL and query parameters required for the request, such as language, orderId, userName, password, and the custom parameters. ```http https://alfa.rbsuat.com/payment/rest/addParams.do?language=ru&orderId=769b8dad-2318-4c01-bfc4-94532522fa68&password=password&userName=userName¶ms={"addParams1»:"value1»,"addParams2»:"value2"} ``` -------------------------------- ### AlfaBank API POST Request Example Source: https://alfabank.ru/sme/payservice/internet-acquiring/docs/connection-options/api/rest_rp-menuopen=1 Example of a POST request to the AlfaBank API, similar to the GET request but formatted for POST data submission. It includes parameters for filtering and pagination. ```URL Encoded Form Data language=ru&page=0&size=100&from=20141009160000&to=20141111000000&transactionStates=DEPOSITED, REVERSED&merchants=SevenEightNine&searchByCreatedDate=false ``` -------------------------------- ### Example POST Request for Internet Acquiring Source: https://alfabank.ru/sme/payservice/internet-acquiring/docs/connection-options/api/rest_rp-menuopen=undefined This example demonstrates a POST request for internet acquiring, showing the necessary parameters such as amount, currency, order number, return URL, and merchant login. It also includes optional parameters like language, jsonParams, expirationDate, and features. ```http POST amount=100¤cy=810&language=ru&orderNumber=87654321&returnUrl=http://yoursite.com&pageView=DESKTOP&jsonParams={"param1":"value1","param2":"value2"}&expirationDate=2014-09-08T14:14:14&merchantLogin=merch_child&features=AUTO_PAYMENT ``` -------------------------------- ### GET /getOrderStatus.do (Get Order Status) Source: https://alfabank.ru/sme/payservice/internet-acquiring/docs/connection-options/api/code-example Retrieves the status of a specific order from the payment gateway. This is typically called after the customer has interacted with the payment form. ```APIDOC ## GET /getOrderStatus.do ### Description Retrieves the status of a specific order from the payment gateway. This endpoint is useful for confirming payment completion or status after a customer interaction with the payment form. ### Method GET ### Endpoint /getOrderStatus.do ### Parameters #### Query Parameters - **userName** (string) - Required - Store's login. - **password** (string) - Required - Store's password. - **orderId** (string) - Required - The order number in the payment system. Must be unique within the system. ### Request Example ```http GET /getOrderStatus.do?userName=your_username&password=your_password&orderId=order_12345 ``` ### Response #### Success Response (200) - **ErrorCode** (string) - Error code for the request. '0' indicates success. - **OrderStatus** (string) - The status of the order in the payment system. May be absent if the order was not found. #### Error Codes - **0** - Request processed without system errors. - **2** - Order rejected due to payment details error. - **5** - Access denied; User must change their password; Order number not specified. - **6** - Unknown order number. - **7** - System error. #### Order Status Meanings - **0** - Order registered, but not paid. - **1** - Pre-authorized amount is held (for two-stage payments). - **2** - Full authorization of the order amount completed. - **3** - Authorization cancelled. - **4** - Refund transaction processed. - **5** - Authorization initiated via ACS of the issuing bank. - **6** - Authorization declined. #### Response Example (Success) ```json { "ErrorCode": "0", "OrderStatus": "2" } ``` #### Response Example (Order Not Found) ```json { "ErrorCode": "6", "OrderStatus": null } ``` ``` -------------------------------- ### Payment Request Parameters Example Source: https://alfabank.ru/sme/payservice/internet-acquiring/docs/connection-options/api/e-com_rp-menuopen=1 This snippet demonstrates the key-value pairs for a POST request to initiate a payment. It includes essential fields like amount, currency, language, order number, return URL, and JSON parameters for additional details. ```text amount = 24000 & currency = 643 & language = ru & orderNumber = 01 a287222222299 & returnUrl = https: //alfa.rbsuat.com/payment/merchants/ecom2/finish.html& jsonParams = { "name1": "value1" } & merchantLogin = merch_child & taxSystem = 0 & orderBundle = { ``` -------------------------------- ### Get Client Bindings Response Example (JSON) Source: https://alfabank.ru/sme/payservice/internet-acquiring/docs/connection-options/api/rest_rp-menuopen=undefined An example of a successful response when requesting a list of client bindings. It shows the structure of the JSON object, including the 'bindings' array with 'bindingId', 'maskedPan', and 'expiryDate', along with 'errorCode' and 'errorMessage'. ```JSON { "bindings": [{ "bindingId": "fd3afc57-c6d0-4e08-aaef-1b7cfeb093dc", "maskedPan": "4000 00** **** **02", "expiryDate": "201512" }], "errorCode": "0", "errorMessage": "Успешно" } ``` -------------------------------- ### API Integration Example (PHP) Source: https://alfabank.ru/sme/payservice/internet-acquiring/docs/connection-options/api/code-example_rp-menuopen=1 This section provides a practical code example in PHP demonstrating how to integrate with the Alfabanck SME Payservice Internet-Acquiring API. It covers the basic structure for making requests to the payment gateway. ```APIDOC ## GET /websites/alfabank_ru_sme_payservice_internet-acquiring_connection-options_api ### Description This endpoint provides information and options for connecting to the Alfabanck SME Payservice Internet-Acquiring API. It outlines the various methods and specifications required for integration. ### Method GET ### Endpoint /websites/alfabank_ru_sme_payservice_internet-acquiring_connection-options_api ### Parameters This endpoint does not have any specific path or query parameters for retrieving connection options. The information is generally available upon accessing the endpoint. ### Request Example This is a GET request, so no request body is typically sent. ### Response #### Success Response (200) - **connection_options** (object) - An object containing various details about available connection methods, API specifications, and integration guides. - **glossary** (object) - A glossary of terms used throughout the payment gateway documentation. - **integration_examples** (object) - Examples of code and integration patterns for connecting to the gateway. #### Response Example ```json { "connection_options": { "api_connection": { "title": "Подключение по API", "description": "Integration via REST API specifications.", "specs_url": "/specs/rest" }, "payment_page": { "title": "Платёжная страница", "description": "Using the hosted payment page." } }, "glossary": { "payment_gateway": "The core service that processes payments." }, "integration_examples": { "php_example": "Example code for PHP integration." } } ``` ## PHP Integration Example ### Description An example of how to integrate with the payment gateway using PHP. This example demonstrates a basic request structure. ### Method POST (typical for payment processing) ### Endpoint /process/payment (example endpoint, actual may vary) ### Parameters #### Request Body - **api_key** (string) - Required - Your unique API key for authentication. - **transaction_id** (string) - Required - A unique identifier for the transaction. - **amount** (float) - Required - The amount to be charged. - **currency** (string) - Required - The currency of the transaction (e.g., 'RUB'). - **description** (string) - Optional - A description for the transaction. ### Request Example ```php $apiKey, 'transaction_id' => $transactionId, 'amount' => $amount, 'currency' => $currency, 'description' => $description ]; $options = [ 'http' => [ 'header' => "Content-type: application/json\r\n", 'method' => 'POST', 'content' => json_encode($data), ], ]; $context = stream_context_create($options); $result = file_get_contents('https://your-payment-gateway.com/api/v1/charge', false, $context); if ($result === FALSE) { // Handle error echo "Error making payment."; } else { $response = json_decode($result, true); // Process response print_r($response); } ?> ``` ### Response #### Success Response (200) - **status** (string) - The status of the transaction (e.g., 'success', 'pending'). - **transaction_id** (string) - The gateway's transaction ID. - **payment_url** (string) - If redirection is required, the URL for payment. #### Response Example ```json { "status": "success", "transaction_id": "GW_TXN_ABC123XYZ", "payment_url": null } ``` ``` -------------------------------- ### PHP: Get Order Status from Payment Gateway (SOAP) Source: https://alfabank.ru/sme/payservice/internet-acquiring/docs/connection-options/api/code-example Retrieves the status of a payment order using the SOAP API. It requires an order ID and returns the error code and order status from the payment gateway. This snippet handles GET requests with an 'orderId' parameter. ```php else if ($_SERVER['REQUEST_METHOD'] == 'GET' && isset($_GET['orderId'])) { $client = new Gateway(WSDL); $data = array('orderParams' => array('orderId' => $_GET['orderId'])); /** * ЗАПРОС СОСТОЯНИЯ ЗАКАЗА * getOrderStatus * ... (detailed comments omitted for brevity) ... */ $response = $client->__call('getOrderStatus', $data); // Вывод кода ошибки и статус заказа echo ' Error code: '. $response->errorCode . '