Class: Paynow::Gateway
- Inherits:
-
Object
- Object
- Paynow::Gateway
- Defined in:
- lib/paynow/gateway.rb
Overview
Resonsible for building a payment from request and response
Instance Attribute Summary collapse
-
#params ⇒ Object
readonly
Returns the value of attribute params.
Class Method Summary collapse
Instance Method Summary collapse
- #create_payment ⇒ Object
-
#initialize(params) ⇒ Gateway
constructor
A new instance of Gateway.
Constructor Details
#initialize(params) ⇒ Gateway
Returns a new instance of Gateway.
12 13 14 |
# File 'lib/paynow/gateway.rb', line 12 def initialize(params) @params = params.transform_keys(&:to_sym) end |
Instance Attribute Details
#params ⇒ Object (readonly)
Returns the value of attribute params.
6 7 8 |
# File 'lib/paynow/gateway.rb', line 6 def params @params end |
Class Method Details
.create_payment(*args) ⇒ Object
8 9 10 |
# File 'lib/paynow/gateway.rb', line 8 def self.create_payment(*args) new(*args).create_payment end |
Instance Method Details
#create_payment ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/paynow/gateway.rb', line 16 def create_payment logger.info("[PAYNOW] CREATE PAYMENT external_id=#{params[:external_id]}") response = api_client.create_payment(params) parsed_response_body = JSON.parse(response.body) payment.new( request_attributes.merge( response: response, payment_id: parsed_response_body['paymentId'], status: parsed_response_body['status'], redirect_url: parsed_response_body['redirectUrl'] ) ) end |