Payment Automation Integration Guide

Learn how to automate your payments with ease and organize a convenient payout project to aid the cases when rendering large volume of payments on a regular, scheduled or one-time basis.

Table of contents:

§1. General Information

In this guide we will review practical examples, while general OKPAY automation features are described in the Programming Interfaces section of the Comprehensive Manual.

OKPAY provides great functionality for payments automation billing – i.e. sending payments from your OKPAY account balance to other users and parties. You are also able to use available transfer options to create a convenient payout service and send funds to other parties.

Note: Payouts, as well as API instruments, are available only to a verified OKPAY client who selected a Corporate account type. Read more in the General Reference Guide for Merchants.

Here are some of the Payments Automation features:

  • Enable automatic payouts and transfers for your business via API.
  • Send mass payments to users within OKPAY system.
  • Specify who will pay the transfer fee.
  • Supported payout/transfer methods include payment cards, bank wires, various payment systems and cryptocurrencies.
  • Check transaction status and account balance at any moment.

§2. API Setup

API tools are available to verified OKPAY corporate clients. Before proceeding with further integration and API tools usage please create API Keys for your OKPAY wallet. Detailed information can be found in API Setup section of the Comprehensive Manual.

§3. How to...

Please find below various examples of OKPAY automation implementation.

§3.1. Check Balance

Make sure your OKPAY account balance is sufficient before sending any payments. The Balance API function allows you to get the balance of all available currencies for a specified wallet.

Detail information can be found on the Balance Function page.

§3.2. Send Money

Once you have checked your wallet balance and the accounts of receivers you can be sure that the money will be sent without any issues. The SendMoney Function allows you to transfer money instantly with OKPAY e-currency to any other user by using the balance of your wallet. There are basically 3 main parameters that you need to specify for your payout, such us:

  • the receiver credentials (OKPAY Wallet ID, email address, phone number or any other contact info)
  • the currency of the transfer (one of the supported by OKPAY currencies)
  • the original amount of the transfer with two decimal places

Note: You can send money to any email address. If the client is not yet registered, he will get a notification email about the incoming transfer as well as the link to sign up for OKPAY and receive the money.

Once the transaction is completed you receive a TxnInfo structure, including transaction ID, date/time, status and other information.

§3.3. Manage Payments

OKPAY provides all necessary tools to prepare and manage already sent payments.

§3.3.1. Get Transaction Information

Once the payments have been sent, you are able to instantly obtain information on the transfer, return values contain TxnInfo structure.

§3.3.2. Get Transaction History

If you need to view the transaction history of the specific wallet via API, you can use the Transactions Function.

Depending on your requirements, transaction history can be generated in a specific manner, for example, to find payments of the particular user, set the parameters of search interval, transaction, etc.

§3.4. Payouts and Transfers

API for transferring funds with OKPAY is a very useful instrument that allows users not only withdraw funds from their OKPAY account but also use the available transfer methods for the payout project or send money to other parties.

§3.4.1. Make Transfer to a Card

Currently, OKPAY supports credit and debit cards payout in various currencies. Current list of supported options can be found on the Money Transfers page.

While using this option you need to specify the card credentials and payment details. Upon completing the transaction a TxnInfo structure is returned.

§3.4.2. Make Transfer to a Payment System

Apart from Payment Card transfer functionality, you can also transfer funds from the OKPAY account or send money to another user via supported payment systems (for example Qiwi, W1 etc.). Current list of supported options can be found on the Money Transfers page.

In this case, you need to specify the payment system which will be used to send the funds (the payment system should be supported by OKPAY transfer API), account credentials, amount and the currency.

Upon completing the transaction a TxnInfo structure is returned.

§3.4.3. Make Transfer to a Cryptocurrency

OKPAY also supports transfers to popular cryptocurrencies (bitcoin, etc.). Current list of supported options can be found on the Money Transfers page.

Specify the cryptocurrency type that will be used for transfer as well as payment details.

§4. Code Samples in Various Programming Languages

For your reference, several examples of OKPAY API usage are provided in popular programming languages.

Sample in PHP
             <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  	<title>OKPAY API PHP Test</title>
  	ini_set("display_errors", 1);
  	echo "<h1>OKPAY API PHP Test</h1>\r\n\r\n";
  		$secWord  = "secretword"; // wallet API password
  		$WalletID = "OKxxxxxxxxx"; // wallet ID
  		$datePart = gmdate("Ymd");
  		$timePart = gmdate("H");
  		$authString = $secWord.":".$datePart.":".$timePart;
  		echo "<p>AuthString: ".$authString."</p>";
  		$sha256 = bin2hex(hash('sha256', $authString, true));
  		$secToken = strtoupper($sha256);
  		echo "<p>Security Token: ".$secToken."</p>";
 		// Connecting to SOAP
 		$opts = array(
 				'user_agent' => 'PHPSoapClient'
 		$context = stream_context_create($opts);
 		$client = new SoapClient("",
 										'stream_context' => $context,
 										'cache_wsdl' => WSDL_CACHE_NONE)
  		echo "<pre>" . print_r($client->__getFunctions(), 1) . "</pre>";
  		echo "Get current server GMT Time (Get_Date_Time):<br />";
  		$webService = $client->Get_Date_Time();
  		$wsResult = $webService->Get_Date_TimeResult;
  		echo $wsResult ."<br />";
  		echo "Get Balance for EUR currency (Wallet_Get_Currency_Balance):<br />";
  		$obj->WalletID = $WalletID;
  		$obj->SecurityToken = $secToken;
  		$obj->Currency = "EUR";
  		$webService = $client->Wallet_Get_Currency_Balance($obj);
  		$wsResult = $webService->Wallet_Get_Currency_BalanceResult;
 		echo "Get All Balances for account (Wallet_Get_Balance):<br />";
  		$obj->WalletID = $WalletID;
  		$obj->SecurityToken = $secToken;
  		$webService = $client->Wallet_Get_Balance($obj);
  		$wsResult = $webService->Wallet_Get_BalanceResult;
 		echo "Money transfer EUR for (Send_Money):<br />";
  		$obj->WalletID = $WalletID;
  		$obj->SecurityToken = $secToken;
  		$obj->Currency = "EUR";
  		$obj->Receiver = "";
  		$obj->Amount = 0.01;
  		$obj->Comment = "PHP API Transfer";
  		$obj->IsReceiverPaysFees = FALSE;
  		$webService = $client->Send_Money($obj);
  		$wsResult = $webService->Send_MoneyResult;
 		echo "Get Transaction Info (Transaction_Get):<br />";
 		$obj->WalletID = $WalletID;
 		$obj->SecurityToken = $secToken;
 		$obj->TxnID = "123456789";
 		$webService = $client->Transaction_Get($obj);
 		$wsResult = $webService->Transaction_GetResult;
  	catch (Exception $e)
  		print  "Caught exception: ".  $e->getMessage(). "\n";
Sample in C#
             Add Service Reference to your C# project (
 class Program
   static void Main(string[] args)
    //API Access Information
    string codeword = "codeword";
    string walletID = "OKxxxxxxxxx";
    //Generating Security Token
    string securityToken = HashStringSHA256(codeword + DateTime.UtcNow.ToString(":yyyyMMdd:HH"));
    //Creating proxy client
    using (var proxy = new OkPayAPI.I_OkPayAPIClient())
     //Get server time
     //Get Balance
     foreach (var item in proxy.Wallet_Get_Balance(walletID, securityToken))
      Console.WriteLine(item.Currency + ": " + item.Amount.ToString("0.00"));
     //Get Transaction Info
     var TI = proxy.Transaction_Get(walletID, securityToken, 123456789);
     Console.WriteLine(TI.OperationName + " " + TI.Amount.ToString("0.00") + TI.Currency);
     //Send Money
     var OI = proxy.Send_Money(walletID, securityToken, "", "EUR", 0.02M, "My API Payment", true);
     Console.WriteLine("OperationID: " + OI.ToString());
   //Calculating Hash
   static string HashStringSHA256(string Value)
    System.Security.Cryptography.SHA256CryptoServiceProvider x = new System.Security.Cryptography.SHA256CryptoServiceProvider();
    byte[] data = System.Text.Encoding.ASCII.GetBytes(Value);
    data = x.ComputeHash(data);
    return BitConverter.ToString(data).Replace("-", "");
Sample in Visual Basic
Sample in Perl
Sample in Java/JSP
Sample in Python
             #!/usr/bin/env python
 # -*- encoding: utf-8 -*-
 from suds.client import Client
 from suds import WebFault
 import datetime
 from hashlib import sha256
 class OkPayAPI():
     def __init__(self, api_password=None, wallet_id=None):
         ''' Set up your API Access Information
         if api_password == None:
             self.api_password = "your details here"
             self.api_password = api_password
         if wallet_id == None:
             self.wallet_id = "your details here"
             self.wallet_id = wallet_id
         #Generate Security Token
         concatenated = api_password + datetime.datetime.utcnow().strftime(":%Y%m%d:%H")
         self.security_token = sha256(concatenated).hexdigest()
         #Create proxy client
         self.client = Client('')
     def get_date_time(self):
         ''' Get the server time in UTC.
             Params: None
             Returns: String value - Date (YYYY-MM-DD HH:mm:SS)
                     2010-12-31 10:33:44 '''
         return self.client.service.Get_Date_Time()
     def get_balance(self, currency=None):
         ''' Get the balance of all currency wallets or of a single currency.
             Params: currency is a three-letter code from the list at
                         if no currency is passed then all wallet balances are
             Returns: dictionary in the form {'balance': {'CUR': '0.0', ...}} '''
             if not currency == None:
                 response = self.client.service.Wallet_Get_Currency_Balance(
                             self.wallet_id, self.security_token,
                 balance = {response.Currency: response.Amount}
                 response = self.client.service.Wallet_Get_Balance(
                         self.wallet_id, self.security_token)
                 balance = {item.Currency: item.Amount for item in response.Balance}
             response = {'success': 1, 'balance': balance}
         except WebFault, e:
             response = {'success': 0, 'error': e}
         return response
OKPAY on Facebook
OKPAY on Livejournal
OKPAY on Twitter
OKPAY on Linkedin
OKPAY on Youtube