Class: Privatbank::P24::PaymentStatus
- Inherits:
-
Object
- Object
- Privatbank::P24::PaymentStatus
- Includes:
- HTTParty
- Defined in:
- lib/privatbank/p24/payment_status.rb
Instance Method Summary collapse
-
#initialize(payment_id, ref, options = {}) ⇒ PaymentStatus
constructor
A new instance of PaymentStatus.
- #outgoing_xml ⇒ Object
- #request ⇒ Object
- #request_xml_data ⇒ Object
- #signature ⇒ Object
Constructor Details
#initialize(payment_id, ref, options = {}) ⇒ PaymentStatus
Returns a new instance of PaymentStatus.
14 15 16 17 18 19 |
# File 'lib/privatbank/p24/payment_status.rb', line 14 def initialize payment_id, ref, ={} @payment_id = payment_id @ref = ref @merchant_id = [:merchant_id] @merchant_password = [:merchant_password] end |
Instance Method Details
#outgoing_xml ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/privatbank/p24/payment_status.rb', line 27 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: 'id', value: @payment_id) p.prop(name: 'ref', value: @ref) end end end builder.target! end |
#request ⇒ Object
21 22 23 24 25 |
# File 'lib/privatbank/p24/payment_status.rb', line 21 def request response = self.class.post('/p24api/check_pay', body: outgoing_xml) return 'error' if response.fetch('error', nil) response['response']['data'] end |
#request_xml_data ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/privatbank/p24/payment_status.rb', line 48 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: 'id', value: @payment_id) p.prop(name: 'ref', value: @ref) end builder.target! end |
#signature ⇒ Object
60 61 62 |
# File 'lib/privatbank/p24/payment_status.rb', line 60 def signature Privatbank::Signature.generate(request_xml_data, @merchant_password) end |