The installation of the necessary modules
You should use Net::SSLeay to send https requests to the system certification server from Perl written scripts. This module should be installed on Unix system. This module uses OpenSSL library to encode data to pass via https.
You can find the latest version of Net::SSLeay at http://www.cpan.org
OpenSSL can be downloaded from www.openssl.org
You should also have the WMSigner module to send https requests.
Creating requests to certification center
In order to work with your WM purse you should send an https request to the WebMoney Transfer certification center.
All https requests are very similar to each other with the only difference being the URL, its parameters and values returned. Let�s look at the following example:
# connecting necessary libraries
use FileHandle;
use IPC::Open2;
use Net::SSLeay;
# initialization of variable
my $OrderID = "1"; # Bill No.
my $PurseOfStores = "Z123456789012"; # Store's WM purse
my $LoginOfStores = "123456789012"; # Store's WM-ID
my $LoginOfCust = "234567890123"; # Customer's WM-ID
my $InvAddress = ""; # Ship to:
my $Amount = "1.34"; # Amount
my $Desc = "Truck"; # Product description
my $Period = "0"; # Protection code
my $Experation = "2"; # Valid period
# creating a monotone increasing number of the request
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = gmtime(time);
my $RequestN = sprintf("%04d%02d%02d%02d%02d%02d", $year+1900, $mon+1, $mday, $hour, $min, $sec);
# Creating a signature
my $PlanStr = "$OrderID$LoginOfCust$PurseOfStores$Amount".
"$Desc$InvAddress$Period$Experation$RequestN";
my $pid = open2(*Reader, *Writer, "./WMSigner");
Writer->autoflush();
print Writer "$PlanStr\004\r\n";
my $SignStr = <Reader>;
# Creating URL and https request
my $W3sUrl="/asp/Invoice.asp?SL=$LoginOfStores&SP=$PurseOfStores &CL=$LoginOfCust&IN=$OrderID&D=$Desc&AD=$InvAddress&A=$Amount &E=$Experation&P=$Period&RN=$RequestN&SS=$SignStr";
my ($page, $result, %headers) =
&Net::SSLeay::get_https("w3s.webmoney.ru", 443, $W3sUrl);
# Result output
print "Content-type: text/html\n\n";
print "Result: \n";
print $page;
Let�s take a detailed look at each block.
1. Connecting necessary libraries
The script uses FileHandle and IPC::Open2 to execute WMSigner, to pass a string to be signed to it and create a signature. Net::SSLeay is used to create a request to the certification server.
2. Initialization of variables
This stage sets necessary request parameters.
3. Creating a monotone increasing number of the request
RN=RequestN is a parameter required to invoke each interface. This parameter must be unique for each request. Its value must not be repeated. It must increase from one request to another. This parameter helps refrain from repetition of one and the same request. Current date and time should be used to form this parameter. In our example, the value is to seconds. Such precision is enough for most Operating systems.
4. Creating a signature
This stage creates a string for the signature and then, it calls the WMSigner module. WMSigner returns a value of the signature.
The IPC module makes its impossible to output data (for example, to print it) until the signature is created. Thus, it is necessary to create a signature before outputting data in the script code.
5. Creating URL and https request
The request's URL should be got and https request should be made using Net::SSLeay. It will fill in the $page variable that contains the server's response.
6. Result output
Our example returns the server's response. In the real application the response should be parsed.