About Webmoney library

This library should help to make requests to WebMoney Transfer www.wmtransfer.com XML-interfaces: www.wmtransfer.com/eng/developers/interfaces/index.shtml

Gem have built-in native wmsigner.

Compatible with ruby: 1.8.7, 1.9.2 Reqirements: Nokogiri >= 1.4.1 built with libxml2 >= 2.7 (IMPORTANT!)

Author

Alexander Oryol ([email protected])

License

MIT License

Request types

Completed:

  • create_invoice - x1

  • create_transaction - x2

  • outgoing_invoices - x4

  • send_message - x6

  • find_wm - x8

  • get_passport - x11

  • i_trust - x15

  • trust_me - x15

  • bussines_level

  • login

Incompleted (help need!):

  • operation_history - x3

  • finish_protect - x5

  • check_sign - x7

  • balance - x9

  • incoming_invoices - x10

  • reject_protection - x13

  • transaction_moneyback - x14

  • trust_save - x15

  • create_purse - x16

  • create_contract - x17

  • transaction_get - x18

Please, see relative documentation and parameters on wiki:

wiki.wmtransfer.com/wiki/list/XML-Interfaces

wiki.webmoney.ru/wiki/list/XML-%D0%B8%D0%BD%D1%82%D0%B5%D1%80%D1%84%D0%B5%D0%B9%D1%81%D1%8B (in russian)

or official sites:

www.wmtransfer.com/eng/developers/interfaces/xml/index.shtml

www.webmoney.ru/rus/developers/interfaces/xml/index.shtml (in russian)

Examples

Setup

class MyWM

include Webmoney

end

@wm = MyWM.new(:wmid => ‘123456789012’, :password => ‘my_pass’, :key => ‘gQABAIR6…2cC8FZTyKyjBM=’)

wmid = ‘111222333444’

Light

cert = OpenSSL::X509::Certificate.new(File.read(“webmoney.cert”)) key = OpenSSL::PKey::RSA.new(File.read(“webmoney.key”), “password”) mywm = MyWM.new(:wmid => ‘123456789012’, :cert => cert, :key => key)

Passport (X11)

Get attestat data: passport = Webmoney::Passport.new(wmid) passport.attestat # { # hash

#   :attestat => 110, # == FORMAL attestat, as example
#   :created_at => Wed Feb 25 21:54:01 +0300 2004 # Time object
#   :cid => "103453"
#   and etc.
# }

passport.wmids # All wmids attached to the attestat passport.userinfo # => ‘Russia’ # Userinfo fields in string context passport.userinfo.checked # => true # with checked/locked attribute passport.directory # Base dictionary

Bussines level

bl = @wm.request(:bussines_level, :wmid => wmid) # => 15

Sending message

… for one message: @wm.request(:send_message, :wmid => wmid, :subj => ‘Subject’, :text => ‘Body of <b>message</b>’)

… for many messages (with queue): @wm.send_message(:wmid => wmid, :subj => ‘Subject’, :text => ‘Body of <b>message</b>’) do |msg, result|

File.open("logfile", "w") do |file|
  case result
  when Hash
    file.puts "Message #{msg.inspect} sended in:#{result[:date]} with id:#{result[:id]}"
  else
    file.puts "Error sent message #{msg.inspect}: #{result.message}"
  end
end

end

Purses and WMIDs

@wm.wmid_exist?(‘123456789012’) # => true

purse = Purse.new(‘Z123456789012’) purse.wmid # => ‘123456789012’ purse.belong_to?(‘123456789012’) # => true

Example: Create invoice and check it’s state

@wm = MyWM.new(:wmid => ‘123456789012’, :password => ‘my_pass’, :key => ‘gQABAIR6…2cC8FZTyKyjBM=’)

# Create invoice @invoice = @wm.request(:create_invoice,

:orderid => 5,
:amount => 10,
:customerwmid => CUSTOMER_WMID,
:storepurse => STORE_PURSE,
:desc => "Test invoice",
:address => "Delivery Address"

)

# Check state res = @wm.request(:outgoing_invoices,

:purse => STORE_PURSE,
:wminvid => @invoice[:id],
:orderid => @invoice[:orderid],
:customerwmid => CUSTOMER_WMID,
:datestart => @invoice[:created_at],
:datefinish => @invoice[:created_at]

) if res.should == 0 && !res.empty?

invoice = res[:invoices].first
case invoice[:state]
  when 0 then # Not Paid
  when 1 then # Paid with protection
  when 2 then # Payment complete
  when 3 then # Rejected
end

end

Also, see spec/* for examples.