class Privatbank::P24::SendMoneyPB
Public Class Methods
new(receiver, payment_id, amount, currency, details, options)
click to toggle source
# File lib/privatbank/p24/send_money_pb.rb, line 14 def initialize receiver, payment_id, amount, currency, details, options @receiver = receiver @payment_id = payment_id @amount = amount @details = details @currency = currency @merchant_id = options[:merchant_id] @merchant_password = options[:merchant_password] end
Public Instance Methods
outgoing_xml()
click to toggle source
# File lib/privatbank/p24/send_money_pb.rb, line 30 def outgoing_xml builder = Builder::XmlMarkup.new builder.instruct! builder.request(version: '1.0') do |req| req.merchant do |merch| merch.id(@merchant_id) merch.signature(signature) end req.data do |d| d.oper('cmt') d.wait(0) d.test(0) d.payment(id: @payment_id) do |p| p.prop(name: 'b_card_or_acc', value: @receiver) p.prop(name: 'amt', value: @amount) p.prop(name: 'ccy', value: @currency) p.prop(name: 'details', value: @details) end end end builder.target! end
request()
click to toggle source
# File lib/privatbank/p24/send_money_pb.rb, line 24 def request response = self.class.post('/p24api/pay_pb', body: outgoing_xml) return 'error' if response.fetch('error', nil) response['response']['data'] end
request_xml_data()
click to toggle source
# File lib/privatbank/p24/send_money_pb.rb, line 53 def request_xml_data builder = Builder::XmlMarkup.new builder.oper('cmt') builder.wait(0) builder.test(0) builder.payment(id: @payment_id) do |p| p.prop(name: 'b_card_or_acc', value: @receiver) p.prop(name: 'amt', value: @amount) p.prop(name: 'ccy', value: @currency) p.prop(name: 'details', value: @details) end builder.target! end
signature()
click to toggle source
# File lib/privatbank/p24/send_money_pb.rb, line 67 def signature Privatbank::Signature.generate(request_xml_data, @merchant_password) end