Class: Paynow::PaynowClient

Inherits:
Object
  • Object
show all
Defined in:
lib/paynow/paynow_client.rb

Overview

Net::HTTP wraper for consuming the Paynow API

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(body) ⇒ PaynowClient

Returns a new instance of PaynowClient.



14
15
16
# File 'lib/paynow/paynow_client.rb', line 14

def initialize(body)
  @body = body
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



8
9
10
# File 'lib/paynow/paynow_client.rb', line 8

def body
  @body
end

Class Method Details

.create_payment(body) ⇒ Object



10
11
12
# File 'lib/paynow/paynow_client.rb', line 10

def self.create_payment(body)
  new(body).create_payment
end

Instance Method Details

#create_paymentObject



18
19
20
21
22
# File 'lib/paynow/paynow_client.rb', line 18

def create_payment
  uri = URI("https://#{host}/v1/payments")

  Net::HTTP.post(uri, json_body, headers)
end