### Example Response for Subscription Update Source: https://developers.cloudpayments.ru/en This is an example of the response after successfully updating a subscription. It returns the updated subscription model. ```json { "Model":{ "Id":"sc_8cf8a9338fb8ebf7202b08d09c938", "AccountId":"user@example.com", "Description":"Rate №5", "Email":"user@example.com", "Amount":1200, "CurrencyCode":0, "Currency":"RUB", "RequireConfirmation":false, "StartDate":"\/Date(1407343589537)\/", "StartDateIso":"2014-08-09T11:49:41", "IntervalCode":1, "Interval":"Month", "Period":1, "MaxPeriods":null, "StatusCode":0, "Status":"Active", "SuccessfulTransactionsNumber":0, "FailedTransactionsNumber":0, "LastTransactionDate":null, "LastTransactionDateIso":null, "NextTransactionDate":"\/Date(1407343589537)\/" "NextTransactionDateIso":"2014-08-09T11:49:41" }, "Success":true } ``` -------------------------------- ### Example Response for Subscriptions Search Source: https://developers.cloudpayments.ru/en This is an example of the response structure when searching for subscriptions. It includes details for each subscription found. ```json { "Model": [ { "Id": "sc_4bae8f5823bb8cdc966ccd1590a3b", "AccountId": "user@example.com", "Description": "Subscription on some service", "Email": "user@example.com", "Amount": 1.02, "CurrencyCode": 0, "Currency": "RUB", "RequireConfirmation": false, "StartDate": "/Date(1473665268000)/", "StartDateIso": "2016-09-12T15:27:48", "IntervalCode": 1, "Interval": "Month", "Period": 1, "MaxPeriods": null, "CultureName": "ru", "StatusCode": 0, "Status": "Active", "SuccessfulTransactionsNumber": 0, "FailedTransactionsNumber": 0, "LastTransactionDate": null, "LastTransactionDateIso": null, "NextTransactionDate": "/Date(1473665268000)/", "NextTransactionDateIso": "2016-09-12T15:27:48" }, { "Id": "sc_b4bdedba0e2bdf279be2e0bab9c99", "AccountId": "user@example.com", "Description": "Subscription on some service #2", "Email": "user@example.com", "Amount": 3.04, "CurrencyCode": 0, "Currency": "RUB", "RequireConfirmation": false, "StartDate": "/Date(1473665268000)/", "StartDateIso": "2016-09-12T15:27:48", "IntervalCode": 0, "Interval": "Week", "Period": 2, "MaxPeriods": null, "CultureName": "ru", "StatusCode": 0, "Status": "Active", "SuccessfulTransactionsNumber": 0, "FailedTransactionsNumber": 0, "LastTransactionDate": null, "LastTransactionDateIso": null, "NextTransactionDate": "/Date(1473665268000)/", "NextTransactionDateIso": "2016-09-12T15:27:48" } ], "Success": true, "Message": null } ``` -------------------------------- ### Payment Find Response Example Source: https://developers.cloudpayments.ru/en Example response when a payment is not found. ```json {"Success":false,"Message":"Not found"} ``` -------------------------------- ### Get Transaction Details Response Example Source: https://developers.cloudpayments.ru/en This is a sample response when retrieving transaction details. It includes comprehensive information about the transaction, payer, and card used. ```json { "Model": { "TransactionId": 504, "Amount": 10.00000, "Currency": "RUB", "CurrencyCode": 0, "InvoiceId": "1234567", "AccountId": "user_x", "Email": null, "Description": "Order №1234567 in shop example.com", "JsonData": null, "CreatedDate": "\/Date(1401718880000)\/", "CreatedDateIso":"2014-08-09T11:49:41", //all the dates are in UTC format "AuthDate": "\/Date(1401733880523)\/", "AuthDateIso":"2014-08-09T11:49:42", "ConfirmDate": "\/Date(1401733880523)\/", "ConfirmDateIso":"2014-08-09T11:49:42", "PayoutDate": "\/Date(1401733880523)\/", "PayoutDateIso":"2014-08-09T11:49:42", "PayoutAmount": 99.61, "TestMode": true, "IpAddress": "195.91.194.13", "IpCountry": "RU", "IpCity": "Уфа", "IpRegion": "Республика Башкортостан", "IpDistrict": "Приволжский федеральный округ", "IpLatitude": 54.7355, "IpLongitude": 55.991982, "CardFirstSix": "411111", "CardLastFour": "1111", "CardExpDate": "05/19", "CardType": "Visa", "CardTypeCode": 0, "Issuer": "Sberbank of Russia", "IssuerBankCountry": "RU", "Status": "Completed", "StatusCode": 3, "Reason": "Approved", "ReasonCode": 0, "CardHolderMessage":"Оплата успешно проведена", //message for payer "Name": "CARDHOLDER NAME" }, "Success": true, "Message": null } ``` -------------------------------- ### Transaction List Response Example Source: https://developers.cloudpayments.ru/en Example response for a list of transactions on a given day, including details like TransactionId, Amount, Currency, and payment status. ```json { "Model": [ { "TransactionId": 504, "Amount": 10.00000, "Currency": "RUB", "CurrencyCode": 0, "InvoiceId": "1234567", "AccountId": "user_x", "Email": null, "Description": "Payment at example.com", "JsonData": null, "CreatedDate": "\/Date(1401718880000)\/", "CreatedDateIso":"2014-08-09T11:49:41", "AuthDate": "\/Date(1401733880523)\/", "AuthDateIso":"2014-08-09T11:49:42", "ConfirmDate": "\/Date(1401733880523)\/", "ConfirmDateIso":"2014-08-09T11:49:42", "PayoutDate": "\/Date(1401733880523)\/", "PayoutDateIso":"2014-08-09T11:49:42", "PayoutAmount": 99.61, "TestMode": true, "IpAddress": "195.91.194.13", "IpCountry": "RU", "IpCity": "Уфа", "IpRegion": "Республика Башкортостан", "IpDistrict": "Приволжский федеральный округ", "IpLatitude": 54.7355, "IpLongitude": 55.991982, "CardFirstSix": "411111", "CardLastFour": "1111", "CardExpDate": "05\/19", "CardType": "Visa", "CardTypeCode": 0, "Issuer": "Sberbank of Russia", "IssuerBankCountry": "RU", "Status": "Completed", "StatusCode": 3, "Reason": "Approved", "ReasonCode": 0, "CardHolderMessage":"Оплата успешно проведена", "Name": "CARDHOLDER NAME" } ], "Success": true } ``` -------------------------------- ### Transaction Processing Examples Source: https://developers.cloudpayments.ru/en Examples of successful and declined transaction responses from the CloudPayments API. ```APIDOC ## Transaction Response Examples ### Declined Transaction Example: ```json { "Model": { "IpAddress": "195.91.194.13", "IpCountry": "RU", "IpCity": "Ufa", "IpRegion": "Республика Башкортостан", "IpDistrict": "Приволжский федеральный округ", "IpLatitude": 54.7355, "IpLongitude": 55.991982, "CardFirstSix": "411111", "CardLastFour": "1111", "CardExpDate": "05/19", "CardType": "Visa", "CardTypeCode": 0, "Issuer": "Sberbank of Russia", "IssuerBankCountry": "RU", "Status": "Declined", "StatusCode": 5, "Reason": "InsufficientFunds", "ReasonCode": 5051, "CardHolderMessage":"Not enough funds on the card", "Name": "CARDHOLDER NAME" }, "Success": false, "Message": null } ``` ### Successful Transaction Example: ```json { "Model": { "TransactionId": 504, "Amount": 10.00000, "Currency": "RUB", "CurrencyCode": 0, "InvoiceId": "1234567", "AccountId": "user_x", "Email": null, "Description": "Оrder №1234567 in shop example.com", "JsonData": null, "CreatedDate": "\/Date(1401718880000)\/", "CreatedDateIso":"2014-08-09T11:49:41", "AuthDate": "\/Date(1401733880523)\/", "AuthDateIso":"2014-08-09T11:49:42", "ConfirmDate": "\/Date(1401733880523)\/", "ConfirmDateIso":"2014-08-09T11:49:42", "AuthCode": "123456", "TestMode": true, "IpAddress": "195.91.194.13", "IpCountry": "RU", "IpCity": "Ufa", "IpRegion": "Республика Башкортостан", "IpDistrict": "Приволжский федеральный округ", "IpLatitude": 54.7355, "IpLongitude": 55.991982, "CardFirstSix": "411111", "CardLastFour": "1111", "CardExpDate": "05/19", "CardType": "Visa", "CardTypeCode": 0, "Issuer": "Sberbank of Russia", "IssuerBankCountry": "RU", "Status": "Completed", "StatusCode": 3, "Reason": "Approved", "ReasonCode": 0, "CardHolderMessage":"Payment successfully completed", "Name": "CARDHOLDER NAME", "Token": "a4e67841-abb0-42de-a364-d1d8f9f4b3c0" }, "Success": true, "Message": null } ``` ``` -------------------------------- ### Get Transaction Details Request Example Source: https://developers.cloudpayments.ru/en Send a request with the TransactionId to retrieve specific details about a past transaction. ```json {"TransactionId":504} ``` -------------------------------- ### Create Invoice Response Source: https://developers.cloudpayments.ru/en Example response upon successful invoice creation. Contains invoice ID, number, amount, currency, and the payment URL. ```json { "Model":{ "Id":"f2K8LV6reGE9WBFn", "Number":61, "Amount":10.0, "Currency":"RUB", "CurrencyCode":0, "Email":"client@test.local", "Description":"Payment at website example.com", "RequireConfirmation":true, "Url":"https://orders.cloudpayments.ru/d/f2K8LV6reGE9WBFn" }, "Success":true } ``` -------------------------------- ### Initialize Widget with English Localization Source: https://developers.cloudpayments.ru/en Instantiate the CloudPayments widget and set the desired language for localization. This example sets the language to US English. ```javascript var widget = new cp.CloudPayments({language: "en-US"}); ``` -------------------------------- ### Payment by Token Request Example Source: https://developers.cloudpayments.ru/en Use this JSON structure to initiate a payment using a previously obtained token. Ensure all required fields like Amount, Currency, and Token are correctly populated. ```json { "Amount":10, "Currency":"RUB", "InvoiceId":"1234567", "Description":"Order №1234567 in shop example.com", "AccountId":"user_x", "Token":"a4e67841-abb0-42de-a364-d1d8f9f4b3c0" } ``` -------------------------------- ### Implement Installment Payments Source: https://developers.cloudpayments.ru/en Use this code to enable installment payments. It allows users to pay a portion upfront and the rest over several months. Ensure the 'accountId' is set for subscription functionality. ```javascript this.paySample5 = function () { var widget = new cp.CloudPayments(); var amount = 12000; //by default 12,000 rubles at once var data = {}; var payLater = $('#select-sample-5-later').is(':checked'); //check if (payLater) { //enabling the subscription data.cloudPayments = { recurrent: { interval: 'Month', period: 1, amount: 1000, maxPeriods: 6 } //6 months for 1000 rubles starting the next month }; amount = 6000; //The amount of the first payment is 6000 rubles. } widget.charge({ // options publicId: 'test_api_00000000000000000000002', //id from Back Office description: 'Payment ...', //purpose amount: amount, currency: 'RUB', accountId: 'user@example.com', //Payer's ID (required for subscription) data: data }, function (options) { // success //action upon successful payment }, function (reason, options) { // fail //action upon unsuccessful payment }); }; $('#checkout-sample-5').click(paySample5); ``` -------------------------------- ### Response Example: Transaction Rejected Source: https://developers.cloudpayments.ru/en This example shows a response when a transaction is rejected. The 'Model' object includes transaction details and a 'ReasonCode' field which contains the specific error code for the rejection. ```json { "Model": { "TransactionId": 504, "Amount": 10.00000, "Currency": "RUB", "CurrencyCode": 0, "PaymentAmount": 10.00000, "PaymentCurrency": "RUB", "PaymentCurrencyCode": 0, "InvoiceId": "1234567", "AccountId": "user_x", "Email": null, "Description": "Order №1234567 in shop example.com", "JsonData": null, "CreatedDate": "\/Date(1401718880000)\/", "CreatedDateIso":"2014-08-09T11:49:41", //all dates in UTC format "TestMode": true } } ``` -------------------------------- ### View Pay Notification Settings Response Source: https://developers.cloudpayments.ru/en Example response when viewing notification settings for the 'Pay' event type. Shows if notifications are enabled and their configuration. ```json { "Model": { "IsEnabled": true, "Address": "http://example.com", "HttpMethod": "GET", "Encoding": "UTF8", "Format": "CloudPayments" }, "Success": true, "Message": null } ``` -------------------------------- ### Get Subscription Details Response Source: https://developers.cloudpayments.ru/en This JSON response provides the current status and details of a requested subscription. It mirrors the structure of the creation response. ```json { "Model":{ "Id":"sc_8cf8a9338fb8ebf7202b08d09c938", "AccountId":"user@example.com", "Description":"Monthly subscription on some service at example.com", "Email":"user@example.com", "Amount":1.02, "CurrencyCode":0, "Currency":"RUB", "RequireConfirmation":false, "StartDate":"\/Date(1407343589537)\/", "StartDateIso":"2014-08-09T11:49:41", "IntervalCode":1, "Interval":"Month", "Period":1, "MaxPeriods":null, "StatusCode":0, "Status":"Active", "SuccessfulTransactionsNumber":0, "FailedTransactionsNumber":0, "LastTransactionDate":null, "LastTransactionDateIso":null, "NextTransactionDate":"\/Date(1407343589537)\/" "NextTransactionDateIso":"2014-08-09T11:49:41" }, "Success":true } ``` -------------------------------- ### Payout by Token Request Example Source: https://developers.cloudpayments.ru/en Use this JSON payload to initiate a payout using a previously obtained card token. Ensure all required fields like Token, Amount, AccountId, and Currency are correctly populated. ```json { "Token":"a4e67841-abb0-42de-a364-d1d8f9f4b3c0", "Amount":1, "AccountId":"user@example.com", "Currency":"RUB", "Payer": //The set of fields is the same for the Receiver parameter. { "FirstName":"Test", "LastName":"Test", "MiddleName":"Test", "Birth":"1955-02-24", "Address":"test address", "Street":"Lenins", "City":"MO", "Country":"RU", "Phone":"123", "Postcode":"345" } } ``` -------------------------------- ### Payout by Cryptogram Request Example Source: https://developers.cloudpayments.ru/en This JSON object demonstrates the required parameters for initiating a payout using a card cryptogram. Ensure all required fields like Name, CardCryptogramPacket, Amount, AccountId, and Currency are correctly populated. ```json { "Name":"CARDHOLDER NAME", "CardCryptogramPacket":"01492500008719030128SMfLeYdKp5dSQVIiO5l6ZCJiPdel4uDjdFTTz1UnXY+3QaZcNOW8lmXg0H670MclS4lI+qLkujKF4pR5Ri+T/E04Ufq3t5ntMUVLuZ998DLm+OVHV7FxIGR7snckpg47A73v7/y88Q5dxxvVZtDVi0qCcJAiZrgKLyLCqypnMfhjsgCEPF6d4OMzkgNQiynZvKysI2q+xc9cL0+CMmQTUPytnxX52k9qLNZ55cnE8kuLvqSK+TOG7Fz03moGcVvbb9XTg1oTDL4pl9rgkG3XvvTJOwol3JDxL1i6x+VpaRxpLJg0Zd9/9xRJOBMGmwAxo8/xyvGuAj85sxLJL6fA==", "Amount":1, "AccountId":"user@example.com", "Currency":"RUB" "InvoiceId":"1234567", "Payer": //The set of fields is the same for the Receiver parameter. { "FirstName":"Test", "LastName":"Test", "MiddleName":"Test", "Birth":"1955-02-24", "Address":"test address", "Street":"Lenins", "City":"MO", "Country":"RU", "Phone":"123", "Postcode":"345" } } ``` -------------------------------- ### Response Example: Transaction Rejected Source: https://developers.cloudpayments.ru/en This response signifies that the transaction was declined. The 'Model' object contains detailed information, including 'Reason' and 'ReasonCode' for the rejection. ```json { "Model": { "TransactionId": 504, "Amount": 10.00000, "Currency": "RUB", "CurrencyCode": 0, "InvoiceId": "1234567", "AccountId": "user_x", "Email": null, "Description": "Order №1234567 in shop example.com", "JsonData": null, "CreatedDate": "\/Date(1401718880000)\/", "CreatedDateIso":"2014-08-09T11:49:41", "TestMode": true, "IpAddress": "195.91.194.13", "IpCountry": "RU", "IpCity": "Ufa", "IpRegion": "Республика Башкортостан", "IpDistrict": "Приволжский федеральный округ", "IpLatitude": 54.7355, "IpLongitude": 55.991982, "CardFirstSix": "411111", "CardLastFour": "1111", "CardType": "Visa", "CardTypeCode": 0, "Issuer": "Sberbank of Russia", "IssuerBankCountry": "RU", "Status": "Declined", "StatusCode": 5, "Reason": "InsufficientFunds", "ReasonCode": 5051, "CardHolderMessage":"Недостаточно средств на карте", "Name": "CARDHOLDER NAME" }, "Success": false, "Message": null } ``` -------------------------------- ### Payment by Cryptogram Request Example Source: https://developers.cloudpayments.ru/en Use this JSON payload to initiate a payment using a card cryptogram. Ensure all required fields like Amount, Currency, and CardCryptogramPacket are correctly populated. The Payer object can be included for additional transaction details. ```json { "Amount":10, "Currency":"RUB", "InvoiceId":"1234567", "Description":"Order №1234567 in shop example.com", "AccountId":"user_x", "Name":"CARDHOLDER NAME", // CardCryptogramPacket Required parameter "CardCryptogramPacket":"01492500008719030128SMfLeYdKp5dSQVIiO5l6ZCJiPdel4uDjdFTTz1UnXY+3QaZcNOW8lmXg0H670MclS4lI+qLkujKF4pR5Ri+T/E04Ufq3t5ntMUVLuZ998DLm+OVHV7FxIGR7snckpg47A73v7/y88Q5dxxvVZtDVi0qCcJAiZrgKLyLCqypnMfhjsgCEPF6d4OMzkgNQiynZvKysI2q+xc9cL0+CMmQTUPytnxX52k9qLNZ55cnE8kuLvqSK+TOG7Fz03moGcVvbb9XTg1oTDL4pl9rgkG3XvvTJOwol3JDxL1i6x+VpaRxpLJg0Zd9/9xRJOBMGmwAxo8/xyvGuAj85sxLJL6fA==", "Payer": { "FirstName":"Test", "LastName":"Test", "MiddleName":"Test", "Birth":"1955-02-24", "Address":"test address", "Street":"Lenins", "City":"MO", "Country":"RU", "Phone":"123", "Postcode":"345" } } ``` -------------------------------- ### 3-D Secure Authentication Form Example Source: https://developers.cloudpayments.ru/en This HTML form is used to redirect a payer for 3-D Secure authentication. It requires the AcsUrl, PaReq, and MD parameters from the server's response. ```html
``` -------------------------------- ### Response Example: 3-D Secure Authentication Required Source: https://developers.cloudpayments.ru/en This response indicates that 3-D Secure authentication is required for the transaction. The 'Model' object contains 'PaReq' and 'AcsUrl' necessary to redirect the user for authentication. ```json { "Model": { "TransactionId": 504, "PaReq": "eJxVUdtugkAQ/RXDe9mLgo0Z1nhpU9PQasWmPhLYAKksuEChfn13uVR9mGTO7MzZM2dg3qSn0Q+X\nRZIJxyAmNkZcBFmYiMgxDt7zw6MxZ+DFkvP1ngeV5AxcXhR+xEdJ6BhpEZnEYLBdfPAzg56JKSKT\nAhqgGpFB7IuSgR+cl5s3NqFTG2NAPYSUy82aETqeWPYUUAdB+ClnwSmrwtz/TbkoC0BtDYKsEqX8\nZfZkDGgAUMkTi8synyFU17V5N2nKCpBuAHRVs610VijCJgmZu17UXTxhFWP34l7evYPlegsHkO6A\n0C85o5hMsI3piNIZHc+IBaitg59qJYzgdrUOQK7/WNy+3FZAeSqV5cMqAwLe5JlQwpny8T8HdFW8\netFuBqUyahV+Hjf27vWCaSx22fe+KY6kXKZfJLK1x22TZkyUS8QiHaUGgDQN6s+H+tOq7O7kf8hd\nt30=", "AcsUrl": "https://test.paymentgate.ru/acs/auth/start.do" }, "Success": false, "Message": null } ``` -------------------------------- ### Accepted Transaction Response Example Source: https://developers.cloudpayments.ru/en This JSON structure represents a successfully accepted transaction. It includes detailed information about the transaction, card, and IP address, along with timestamps. ```json { "Model": { "TransactionId": 504, "Amount": 10.00000, "Currency": "RUB", "CurrencyCode": 0, "InvoiceId": "1234567", "AccountId": "user_x", "Email": null, "Description": "Оrder №1234567 in shop example.com", "JsonData": null, "CreatedDate": "\/Date(1401718880000)\/", "CreatedDateIso":"2014-08-09T11:49:41", "AuthDate": "\/Date(1401733880523)\/", "AuthDateIso":"2014-08-09T11:49:42", "ConfirmDate": "\/Date(1401733880523)\/", "ConfirmDateIso":"2014-08-09T11:49:42", "AuthCode": "123456", "TestMode": true, "IpAddress": "195.91.194.13", "IpCountry": "RU", "IpCity": "Ufa", "IpRegion": "Республика Башкортостан", "IpDistrict": "Приволжский федеральный округ", "IpLatitude": 54.7355, "IpLongitude": 55.991982, "CardFirstSix": "411111", "CardLastFour": "1111", "CardExpDate": "05/19", "CardType": "Visa", "CardTypeCode": 0, "Issuer": "Sberbank of Russia", "IssuerBankCountry": "RU", "Status": "Completed", "StatusCode": 3, "Reason": "Approved", "ReasonCode": 0, "CardHolderMessage":"Payment successfully completed", "Name": "CARDHOLDER NAME", "Token": "a4e67841-abb0-42de-a364-d1d8f9f4b3c0" }, "Success": true, "Message": null } ``` -------------------------------- ### Set Up Recurrent Payments with CloudPayments Widget Source: https://developers.cloudpayments.ru/en Use this code to initiate a payment that also sets up a recurring subscription. Ensure 'accountId' is provided for subscription creation. The 'data.cloudPayments.recurrent' object configures the subscription details. ```javascript this.pay = function () { var widget = new cp.CloudPayments(); var receipt = { Items: [ { label: 'Product #2', price: 300.00, quantity: 3.00, amount: 900.00, vat: 20, method: 0, object: 0, } ], taxationSystem: 0, email: 'user@example.com', phone: '', isBso: false, amounts: { electronic: 900.00, advancePayment: 0.00, credit: 0.00, provision: 0.00 } }; var data = {}; data.cloudPayments = { CustomerReceipt: receipt, recurrent: { interval: 'Month', period: 1, customerReceipt: receipt } }; widget.charge({ publicId: 'test_api_00000000000000000000001', description: 'Subscription on monthly access to https://example.com', amount: 1000, currency: 'RUB', invoiceId: '1234567', accountId: 'user@example.com', data: data }, function (options) { //action upon successful payment }, function (reason, options) { //action upon unsuccessful payment }); }; ``` -------------------------------- ### Response Example: Incorrect Request Source: https://developers.cloudpayments.ru/en This is an example of an incorrect request response. The 'Success' field is false, and the 'Message' field provides details about the error, such as a missing required parameter. ```json {"Success":false,"Message":"Amount is required"} ``` -------------------------------- ### Refund Payment Response Source: https://developers.cloudpayments.ru/en This is an example of a successful response after processing a refund. ```json { "Model": { "TransactionId": 568 }, "Success": true, "Message": null } ``` -------------------------------- ### 3-D Secure Authentication Source: https://developers.cloudpayments.ru/en Instructions and examples for completing 3-D Secure authentication by redirecting the payer to the ACS URL. ```APIDOC ## 3-D Secure Processing To complete 3-D Secure authentication, you need to divert a payer to the address specified in the **AcsUrl** parameter of the server's response with the following parameters: * **MD** — TransactionId parameter from server response * **PaReq** — same parameter from server response * **TermUrl** — the address on your site for returning the payer once authentication is successful ### Form Example: ```html ``` To complete the payment, use the following **Post3ds method**. ### Method URL: https://api.cloudpayments.ru/payments/cards/post3ds ### Parameters: Parameter | Type | Use | Description ---|---|---|--- TransactionId | Int | Required | MD parameter value PaRes | String | Required | PaRes value The server will return either information about successful transaction or declined in response to correctly created request. ``` -------------------------------- ### POST /subscriptions/create Source: https://developers.cloudpayments.ru/en Creates a new subscription for recurrent payments. ```APIDOC ## POST /subscriptions/create ### Description The method to create subscriptions on recurrent payments. ### Method POST ### Endpoint https://api.cloudpayments.ru/subscriptions/create ### Parameters #### Request Body - **Token** (String) - Required - Card tokens issued by the system after the first payment - **AccountId** (String) - Required - Payer's ID - **Description** (String) - Required - Payment description/purpose - **Email** (String) - Required - Payer's E-mail - **Amount** (Numeric) - Required - Payment amount - **Currency** (String) - Required - Currency: RUB/USD/EUR/GBP - **RequireConfirmation** (Bool) - Required - If true — payments will work by DMS - **StartDate** (DateTime) - Required - Date time of the first subscription payment in UTC timezone - **Interval** (String) - Required - Possible values: Day, Week, Month - **Period** (Int) - Required - Works in combination with the Interval, 1 Month means once per month, 2 Week means once per two weeks - **MaxPeriods** (Int) - Optional - Maximum quantity of subscription payments - **CustomerReceipt** (String) - Optional - For content of an online-receipt changing. ### Request Example ```json { "token":"477BBA133C182267FE5F086924ABDC5DB71F77BFC27F01F2843F2CDC69D89F05", "accountId":"user@example.com", "description":"Monthly subscription on some service at example.com", "email":"user@example.com", "amount":1.02, "currency":"RUB", "requireConfirmation":false, "startDate":"2014-08-06T16:46:29.5377246Z", "interval":"Month", "period":1 } ``` ### Response #### Success Response (200) - **Model** (Object) - Contains subscription details. - **Id** (String) - Subscription ID - **AccountId** (String) - Payer's ID - **Description** (String) - Payment description - **Email** (String) - Payer's E-mail - **Amount** (Numeric) - Payment amount - **Currency** (String) - Currency code - **RequireConfirmation** (Bool) - True if DMS is enabled - **StartDate** (DateTime) - Start date of the subscription - **Interval** (String) - Subscription interval (Day, Week, Month) - **Period** (Int) - Subscription period - **MaxPeriods** (Int) - Maximum number of payments - **Status** (String) - Current status of the subscription (e.g., Active) - **SuccessfulTransactionsNumber** (Int) - Number of successful transactions - **FailedTransactionsNumber** (Int) - Number of failed transactions - **LastTransactionDateIso** (DateTime) - Date of the last transaction - **NextTransactionDateIso** (DateTime) - Date of the next transaction - **Success** (Bool) - Indicates if the operation was successful. #### Response Example ```json { "Model":{ "Id":"sc_8cf8a9338fb8ebf7202b08d09c938", "AccountId":"user@example.com", "Description":"Monthly subscription on some service at example.com", "Email":"user@example.com", "Amount":1.02, "Currency":"RUB", "RequireConfirmation":false, "StartDate":"\/Date(1407343589537)\/", "StartDateIso":"2014-08-09T11:49:41", "Interval":"Month", "Period":1, "MaxPeriods":null, "Status":"Active", "SuccessfulTransactionsNumber":0, "FailedTransactionsNumber":0, "LastTransactionDate":null, "LastTransactionDateIso":null, "NextTransactionDate":"\/Date(1407343589537)\/", "NextTransactionDateIso":"2014-08-09T11:49:41" }, "Success":true } ``` ``` -------------------------------- ### Get Subscription Details Request Source: https://developers.cloudpayments.ru/en Send a request with the subscription ID to retrieve information about a specific recurring payment subscription. ```json {"Id":"sc_8cf8a9338fb8ebf7202b08d09c938"} ``` -------------------------------- ### JavaScript: Recurrent Payments for ISPs Source: https://developers.cloudpayments.ru/en Use this snippet to enable monthly subscription top-ups for Internet providers. It requires an account ID and an amount, and can be configured for automatic monthly charges. ```javascript this.paySample3 = function () { var widget = new cp.CloudPayments(); var data = {}; var auto = $('#recurrent-sample-3').is(':checked'); //checking if (auto) { //enabling the subscription var date = new Date(); //current date date.setMonth(date.getMonth() + 1); //next month date.setDate(date.getDate() - 1); //minus one day var recurrent = { interval: 'Month', period: 1, startDate: date }; //once a month starting from the next month minus one day data.cloudPayments = { recurrent: recurrent } } var amount = parseFloat($('#amount-sample-3').val()); var accountId = $('#account-sample-3').val(); widget.charge({ // options publicId: 'test_api_00000000000000000000002', //id from Back Office description: 'Top up the account number ' + accountId, //purpose/justification amount: amount, currency: 'RUB', accountId: accountId, //Payer's ID (required for subscription) data: data }, function (options) { // success //action upon successful payment }, function (reason, options) { // fail //action upon unsuccessful payment }); }; $('#checkout-sample-3').click(paySample3); ``` -------------------------------- ### Create Subscription Response Source: https://developers.cloudpayments.ru/en The system returns this JSON structure upon successful subscription creation, containing the new subscription's ID and details. ```json { "Model":{ "Id":"sc_8cf8a9338fb8ebf7202b08d09c938", "AccountId":"user@example.com", "Description":"Monthly subscription on some service at example.com" "Email":"user@example.com", "Amount":1.02, "CurrencyCode":0, "Currency":"RUB", "RequireConfirmation":false, "StartDate":"\/Date(1407343589537)\/", "StartDateIso":"2014-08-09T11:49:41", "IntervalCode":1, "Interval":"Month", "Period":1, "MaxPeriods":null, "StatusCode":0, "Status":"Active", "SuccessfulTransactionsNumber":0, "FailedTransactionsNumber":0, "LastTransactionDate":null, "LastTransactionDateIso":null, "NextTransactionDate":"\/Date(1407343589537)\/" "NextTransactionDateIso":"2014-08-09T11:49:41" }, "Success":true } ``` -------------------------------- ### Response Example: Incorrect Request Source: https://developers.cloudpayments.ru/en This response indicates an issue with the request parameters, such as a missing required field. The 'Message' field will provide details on the error. ```json {"Success":false,"Message":"Amount is required"} ``` -------------------------------- ### Declined Transaction Response Example Source: https://developers.cloudpayments.ru/en This JSON structure represents a declined transaction, detailing reasons such as insufficient funds. It includes card and IP information. ```json { "Model": { "IpAddress": "195.91.194.13", "IpCountry": "RU", "IpCity": "Ufa", "IpRegion": "Республика Башкортостан", "IpDistrict": "Приволжский федеральный округ", "IpLatitude": 54.7355, "IpLongitude": 55.991982, "CardFirstSix": "411111", "CardLastFour": "1111", "CardExpDate": "05/19", "CardType": "Visa", "CardTypeCode": 0, "Issuer": "Sberbank of Russia", "IssuerBankCountry": "RU", "Status": "Declined", "StatusCode": 5, "Reason": "InsufficientFunds", "ReasonCode": 5051, "CardHolderMessage":"Not enough funds on the card", "Name": "CARDHOLDER NAME" }, "Success": false, "Message": null } ```