Class: Paynow::Client
- Inherits:
-
Object
- Object
- Paynow::Client
- Defined in:
- lib/paynow/client.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
Class Method Summary collapse
Instance Method Summary collapse
- #create_payment ⇒ Object
-
#initialize(body) ⇒ Client
constructor
A new instance of Client.
Constructor Details
#initialize(body) ⇒ Client
Returns a new instance of Client.
11 12 13 |
# File 'lib/paynow/client.rb', line 11 def initialize(body) @body = body end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
5 6 7 |
# File 'lib/paynow/client.rb', line 5 def body @body end |
Class Method Details
.create_payment(body) ⇒ Object
7 8 9 |
# File 'lib/paynow/client.rb', line 7 def self.create_payment(body) new(body).create_payment end |
Instance Method Details
#create_payment ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/paynow/client.rb', line 15 def create_payment puts(raw_payment) logger.info("[PAYNOW] STARTED POST #{uri}") response = Net::HTTP.post(uri, payment_data,headers) decoded_response = URI.decode_www_form(response.read_body).to_h.transform_keys(&:to_sym) if response.code =~ /^[4-5]/ logger.error("[PAYNOW] ERROR GET #{uri} status=#{response.code} message=#{decoded_response.error}") else logger.info("[PAYNOW] COMPLETED GET #{uri} status=#{response.code} response=#{decoded_response}") end payment.new( raw_payment.merge( poll_url: decoded_response[:pollurl], paynow_redirect_url: decoded_response[:browserurl], status: decoded_response[:status] ) ) end |