Tuesday, October 26, 2021
HomeCurrency ConversionPerl API to WebMoney

Perl API to WebMoney

NAME

Enterprise::WebMoney – Perl API to WebMoney

SYNOPSIS

  use Enterprise::WebMoney;

  my $wm = Enterprise::WebMoney->new(
    p12_file => '/path/to/key.p12',
    p12_pass => 'secret',
  );

  my $inv = $wm->bill(
    reqn => 10,
    orderid => 1,
    customerwmid => '000000000000',
    storepurse => 'Z000000000000',
    quantity => 100,
    desc => 'Camel',
    handle => 'Supply handle',
    expiration => 3,
  ) or die $wm->errstr;

  my $invs = $wm->get_out_invoices(
    reqn => 11,
    purse => 'Z000000000000',
    datestart => '20080101 00:00:00',
    datefinish => '20090101 00:00:00',
  ) or die $wm->errstr;

  my $ops = $wm->get_operations(
    reqn => 12,
    purse => 'Z000000000000',
    datestart => '20080101 00:00:00',
    datefinish => '20090101 00:00:00',
  ) or die $wm->errstr;

  $wm->reject_protect(
    reqn => 13,
    wmtranid => '123123123',
  ) or die $wm->errstr;

  $wm->finish_protect(
    reqn => 14,
    wmtranid => '123123123',
    pcode => 'secret',
  ) or die $wm->errstr;

  my $invs = $wm->get_in_invoices(
    reqn => 15,
    wmid => '000000000000',
    datestart => '20080101 00:00:00',
    datefinish => '20090101 00:00:00',
  ) or die $wm->errstr;

  my $purses = $wm->get_balance(
    reqn => 16,
    wmid => '000000000000',
  ) or die $wm->errstr;

  $wm->switch(
    reqn => 17,
    tranid => 2,
    pursesrc => 'Z000000000000',
    pursedest => 'Z000000000000',
    quantity => 100,
    desc => 'Camel',
  ) or die $wm->errstr;

  $wm->message(
    reqn => 18,
    receiverwmid => '000000000000',
    msgsubj => 'Foo',
    msgtext => 'Bar',
  ) or die $wm->errstr;

  $wm->money_back(
    reqn => 19,
    inwmtranid => '123123123',
    quantity => 100,
  ) or die $wm->errstr;

DESCRIPTION

Enterprise::WebMoney supplies easy API to the WebMoney switch system. It requires the SSL non-public key and certificates out of your WM Keeper Mild account (PKCS12 file). WM Keeper Traditional keys usually are not supported but.

The principle options of the library are:

  • Create outgoing bill (X1)

  • Switch cash (X2)

  • Get the record of operations (X3)

  • Verify bill standing (X4)

  • Enter safety code (X5)

  • Ship a message through WM mail (X6)

  • Verify purses steadiness (X9)

  • Get incoming invoices record (X10)

  • Reject protected fee (X13)

  • Return cash with out fee (X14)

INTERFACE

Each perform within the library corresponds to the one WebMoney interface. Operate arguments are translated to corresponding request fields.

An instance:

  $wm->get_operations(
    reqn => 1,
    purse => 'R000000000000',
    datestart => '20081001 00:00:00',
    datefinish => '20090101 00:00:00',
  );

This name is translated to the XML request:

  <w3s.request>
    <reqn>1</reqn>
    <getoperations>
      <purse>R000000000000</purse>
      <datestart>20081001 00:00:00</datestart>
      <datefinish>20090101 00:00:00</datefinish>
    </getoperations>
  </w3s.request>

Interfaces returning single XML aspect correspond to features returning reference to hash. Interfaces returning record of XML parts correspond to features returning reference to array of hashes. Attributes and subelements of XML response are translated into hash fields.

An instance:

  <?xml model="1.0"?>
  <w3s.response>
    <reqn>1</reqn>
    <operations cnt="8" cntA="8">
      <operation id="150977211" ts="150977211">
        <pursesrc>R000000000000</pursesrc>
        <pursedest>R000000000000</pursedest>
        <quantity>18000.00</quantity>
        <comiss>0.00</comiss>
        <opertype>0</opertype>
        <wminvid>0</wminvid>
        <orderid>0</orderid>
        <tranid>0</tranid>
        <interval>0</interval>
        <desc>Camel</desc>
        <datecrt>20081103 08:26:20</datecrt>
        <dateupd>20081103 08:26:20</dateupd>
        <corrwm>000000000000</corrwm>
        <relaxation>18000.00</relaxation>
      </operation>
      <operation id="150977212" ts="150977212">
        <pursesrc>R000000000000</pursesrc>
        <pursedest>R000000000000</pursedest>
        <quantity>18000.00</quantity>
        <comiss>0.00</comiss>
        <opertype>0</opertype>
        <wminvid>0</wminvid>
        <orderid>0</orderid>
        <tranid>0</tranid>
        <interval>0</interval>
        <desc>Camel 2</desc>
        <datecrt>20081103 08:26:25</datecrt>
        <dateupd>20081103 08:26:25</dateupd>
        <corrwm>000000000000</corrwm>
        <relaxation>36000.00</relaxation>
      </operation>
    </operations>
  </w3s.response>

This can be a response to Operations request. Technique get_operations will convert it to the next construction:

  [                                       
    {
      'id' => '150977211',
      'ts' => '150977211',
      'pursesrc' => 'R000000000000',
      'pursedest' => 'R000000000000',
      'amount' => '18000.00',
      'comiss' => '0.00',
      'opertype' => '0',
      'wminvid' => '0'
      'orderid' => '0',
      'tranid' => '0',
      'period' => '0',
      'desc' => 'Camel',
      'datecrt' => '20081103 08:26:20',
      'dateupd' => '20081103 08:26:20',
      'corrwm' => '000000000000',
      'rest' => '18000.00',
    },
    {
      'id' => '150977212',
      'ts' => '150977212',
      'pursesrc' => 'R000000000000',
      'pursedest' => 'R000000000000',
      'amount' => '18000.00',
      'comiss' => '0.00',
      'opertype' => '0',
      'wminvid' => '0'
      'orderid' => '0',
      'tranid' => '0',
      'period' => '0',
      'desc' => 'Camel 2',
      'datecrt' => '20081103 08:26:25',
      'dateupd' => '20081103 08:26:25',
      'corrwm' => '000000000000',
      'rest' => '36000.00',
    }
  ];

Each request has a reqn – request quantity. It should be larger than the earlier cash switch reqn.

All dates are laid out in YYYYMMDD HH:MM:SS format.

See also  The World Exchange

On failure features return undef. Error code and outline can be found through $wm->errcode and $wm->errstr accordingly.

METHODS

Constructor

  my $wm = Enterprise::WebMoney->new(
    p12_file => '/path/to/key.p12',     # Path to PKCS12 WebMoney file (obligatory)
    p12_pass => 'secret',               # Encryption password for p12_file (obligatory if encrypted)
    ca_file => '/path/to/CA.crt',       # WebMoney certification authority file (optionally available)
    timeout => 30,                      # Request timeout in seconds (optionally available, default 20)
  );

get_operations – historical past of transactions for the given purse (Interface X3)

  my $ops = $wm->get_operations(
    reqn => 1,
    purse => 'Z000000000000',           # Purse to question (obligatory)
    datestart => '20080101 00:00:00',   # Interval starting (obligatory)
    datefinish => '20080201 00:00:00',  # Interval finish (obligatory)
    wmtranid => 123123123,              # Transaction ID (within the WebMoney system, optionally available)
    tranid => 123,                      # Transaction ID (in your system, optionally available)
    wminvid => 345345345,               # Bill ID (within the WebMoney system, optionally available)
    orderid => 345,                     # Order ID (bill in your system, optionally available)
  );

On error returns undef. On success returns reference to array of transactions. Every transaction is a hash:

  • id – a singular variety of an transaction within the WebMoney system

  • ts – a service variety of an transaction within the WebMoney system

  • tranid – Switch quantity set by the sender; an integer; it needs to be distinctive for every trasaction (the identical tranid shouldn’t be used for 2 transactions)

  • pursesrc – Sender’s purse quantity

  • pursedest – Recipient’s purse quantity

  • quantity – cash quantity

  • comiss – Payment charged

  • opertype – 0 – easy (accomplished), 4 – protected (not accomplished), 12 – protected (refunded)

  • interval – Safety interval in days (0 means no safety)

  • wminvid – Bill quantity (within the WebMoney system) of the transaction (0 means with out bill)

  • orderid – Serial bill quantity set by the shop (0 means with out bill)

  • desc – Description of services or products

  • datecrt – Date and time of transaction

  • dateupd – Date and time of transaction standing change

  • corrwm – Correspondent WMID

  • relaxation – Relaxation after transaction

bill – create outgoing bill (Interface X1)

  my $inv = $wm->bill(
    reqn => 1,
    orderid => 1,                       # Bill serial quantity. Needs to be set by the shop. An integer (obligatory)
    customerwmid => '000000000000',     # Buyer's WMID (obligatory)
    storepurse => 'Z000000000000',      # Variety of the purse the place funds might be despatched to (obligatory)
    quantity => 100,                      # Quantity that the shopper has to pay (obligatory)
    desc => 'Camel',                    # Description of services or products (max 255 characters; with out areas to start with and in the long run, obligatory)
    handle => 'Supply handle',      # Supply handle (max 255 characters; with out areas to start with and in the long run, optionally available)
    interval => 3,                        # Most interval of safety in days (An integer within the vary: 0 - 255; zero implies that no safety needs to be used, optionally available)
    expiration => 3,                    # Most legitimate interval in days (An integer within the vary: 0 - 255; zero implies that the legitimate interval just isn't outlined, optionally available)
  );

On error returns undef. On success returns reference to affirmation hash.

get_out_invoices – examine invoices standing (Interface X4)

  my $invs = $wm->get_out_invoices(
    reqn => 11,
    purse => 'Z000000000000',           # Variety of the purse the place the bill needs to be paid to (obligatory)
    datestart => '20080101 00:00:00',   # Minimal time and date of bill creation (obligatory)
    datefinish => '20090101 00:00:00',  # Most time and date of bill creation (obligatory)
    wminvid => 123123123,               # Bill quantity (within the WebMoney system, optionally available)
    orderid => 123,                     # Serial bill quantity set by the shop (optionally available)
  ) or die $wm->errstr;

On error returns undef. On success returns reference to array of invoices. Every bill is a hash:

  • id – a singular variety of a bill within the WebMoney system

  • ts – a service variety of a bill within the WebMoney system

  • orderid – Bill quantity set by the sender

  • customerwmid – Buyer’s WMID

  • storepurse – Variety of the purse the place funds might be despatched to

  • quantity – Quantity that the shopper is to pay

  • desc – Description of services or products

  • handle – Supply handle

  • interval – Most interval of safety in days

  • expiration – Most legitimate interval in days

  • state – 0 – unpaid, 1 – paid with safety, 2 – paid, 3 – rejected

  • datecrt – Date and time of the bill creation

  • dateupd – Date and time of the bill standing change

  • wmtranid – Transaction quantity within the WebMoney system, if the bill was paid

  • customerpurse – Payer purse, if the bill was paid

See also  Exchange Place Apartments, 1313 E. Main St., Richmond, VA

switch – switch cash (Interface X2)

  $wm->switch(
    reqn => 1,
    tranid => 2,                        # Transaction quantity set by the sender; an integer; it needs to be distinctive for every trasaction (the identical tranid shouldn't be used for 2 transactions, obligatory)
    pursesrc => 'Z000000000000',        # Sender's purse quantity (obligatory)
    pursedest => 'Z000000000000',       # Recipient's purse quantity (obligatory)
    quantity => 100,                      # Quantity. A floating-point quantity, for instance, 10.5; 9; 7.36 (obligatory)
    interval => 3,                        # Safety interval in days (An integer within the vary: 0 - 255; zero implies that no safety needs to be used, optionally available)
    pcode => 'secret',                  # Safety code (Within the vary 0 - 255 characters; with out areas to start with and in the long run, optionally available)
    desc => 'Camel',                    # Description of services or products (Within the vary 0 - 255 characters; with out areas to start with and in the long run, obligatory)
    wminvid => 123123123,               # Bill quantity (within the WebMoney system). 0 implies that switch is made with out bill (optionally available)
  ) or die $wm->errstr;

On error returns undef. On success returns reference to affirmation hash:

  • id – a singular variety of a transaction within the WebMoney System

  • ts – a service variety of a transaction within the WebMoney System

  • tranid – Serial transaction quantity set by the sender; an integer; it needs to be distinctive for every trasaction (the identical tranid shouldn’t be used for 2 transactions)

  • pursesrc – Sender’s purse quantity

  • pursedesc – Recipient’s purse quantity

  • quantity – Quantity

  • comiss – Payment charged

  • opertype – Switch kind: 0 – easy (accomplished), 4 – protected (incomplete)

  • interval – Safety interval in days

  • wminvid – Bill quantity (within the WebMoney system). 0 implies that switch is made with out bill

  • orderid – Serial bill quantity set by the shop. 0 implies that switch is made with out bill

  • desc – Description of services or products

  • datecrt – Date and time of transaction

  • dateupd – Date and time of transaction standing change

finish_protect – full code-protected transaction (Interface X5)

  $wm->finish_protect(
    reqn => 14,
    wmtranid => '123123123',            # Switch quantity within the WebMoney system (obligatory)
    pcode => 'secret',                  # Safety code. Within the vary 0 - 255 characters; with out areas to start with and in the long run (obligatory)
  ) or die $wm->errstr;

On error returns undef. On success returns reference to affirmation hash:

  • id – a singular variety of switch within the WebMoney system

  • td – a service variety of switch within the WebMoney system

  • opertype – 0 – easy (accomplished), 12 – protected (funds had been refunded)

  • dateupd – Date and time of transaction standing change

reject_protect – reject code-protected transaction (Interface X13)

  $wm->reject_protect(
    reqn => 13,
    wmtranid => '123123123',            # Switch quantity within the WebMoney system (obligatory)
  ) or die $wm->errstr;

On error returns undef. On success returns reference to affirmation hash:

  • id – a singular variety of switch within the WebMoney system

  • td – a service variety of switch within the WebMoney system

  • opertype – 0 – easy (accomplished), 4 – protected (incomplete), 12 – protected (funds had been refunded)

  • dateupd – Date and time of transaction standing change

See also  Exchange Payeer To Visa – AdvCash

message – ship message to arbitrary WMID (Interface X6)

  $wm->message(
    reqn => 18,
    receiverwmid => '000000000000',     # Recipient's WMID, 12 digits (obligatory)
    msgsubj => 'Foo',                   # Topic, 0 - 255 characters with out areas to start with and in the long run (obligatory)
    msgtext => 'Bar',                   # Message physique, 0 - 1024 characters with out areas to start with and in the long run (obligatory)
  ) or die $wm->errstr;

On error returns undef. On success returns reference to affirmation hash.

steadiness – examine purses steadiness (Interface X9)

  my $purses = $wm->get_balance(
    reqn => 16,
    wmid => '000000000000',             # WMID, 12 digits (obligatory)
  ) or die $wm->errstr;

On error returns undef. On success returns reference to array of handbags. Every purse is a hash:

  • id – a singular inner variety of the purse

  • pursename – Purse quantity, A letter prefix + 12 digits

  • quantity – Purse steadiness

get_in_invoices – get incoming invoices record (Interface X10)

  my $invs = $wm->get_in_invoices(
    reqn => 15,
    wmid => '000000000000',             # WMID (obligatory)
    wminvid => 456456456,               # Bill quantity (within the WebMoney system), An integer >= 0 (optionally available)
    datestart => '20080101 00:00:00',   # Minimal time and date of bill creation (obligatory)
    datefinish => '20090101 00:00:00',  # Most time and date of bill creation (obligatory)
  ) or die $wm->errstr;

On error returns undef. On success returns reference to array of invoices. Every bill is a hash:

  • id – a singular variety of a bill within the WebMoney system

  • ts – a service variety of a bill within the WebMoney system

  • orderid – Bill quantity set by the sender

  • storewmid – Vendor’s WMID

  • storepurse – Variety of the purse the place funds might be despatched to

  • quantity – Quantity that the shopper is to pay

  • desc – Description of services or products

  • handle – Supply handle

  • interval – Most interval of safety in days

  • expiration – Most legitimate interval in days

  • state – 0 – unpaid, 1 – paid with safety, 2 – paid, 3 – rejected

  • datecrt – Date and time of the bill creation

  • dateupd – Date and time of the bill standing change

  • wmtranid – Transaction quantity within the WebMoney system, if the bill was paid

money_back – return cash with out fee (Interface X14)

  $wm->money_back(
    reqn => 19,
    inwmtranid => '123123123',          # Transaction ID (obligatory)
    quantity => 100,                      # Quantity of transaction (self-check). Should match the transaction being returned (obligatory)
  ) or die $wm->errstr;

On error returns undef. On success returns reference to affirmation hash.

SECURITY

  • The module is bundled with WebMoney CA certificates to validate id of the WebMoney server.

  • Be particularly cautious when utilizing certificates with cash switch permission on the manufacturing servers. Stolen certificates will be simply reimported to the browser and used to steal your cash. To forestall such threats register separate WMID and provides it permission to entry purses of the principle WMID in read-only mode. This may be arrange utilizing https://security.wmtransfer.com/

ENVIRONMENT

  • HTTPS_PROXY – proxy help, http://host_or_ip:port

  • HTTPS_PROXY_USERNAME and HTTPS_PROXY_PASSWORD – proxy primary auth

BUGS

The module just isn’t thread-safe.

SEE ALSO

WebMoney::WMSigner – signer module that indicators any knowledge utilizing specified WebMoney key file

http://www.webmoney.ru/eng/developers/interfaces/xml/index.shtml – WebMoney API specification

AUTHOR

Alexander Lourier, <aml@rulezz.ru>

COPYRIGHT AND LICENSE

Copyright (C) 2008 by Alexander Lourier

This library is free software program; you’ll be able to redistribute it and/or modify it below the identical phrases as Perl itself, both Perl model 5.10.0 or, at your choice, any later model of Perl 5 you will have obtainable.

RELATED ARTICLES

Most Popular

Recent Comments