Class: Flow::SimpleGateway
- Inherits:
-
Object
- Object
- Flow::SimpleGateway
- Defined in:
- lib/flow/simple_gateway.rb
Instance Method Summary collapse
-
#cc_authorization ⇒ Object
authorises credit card and prepares for capture.
-
#initialize(order) ⇒ SimpleGateway
constructor
A new instance of SimpleGateway.
Constructor Details
#initialize(order) ⇒ SimpleGateway
Returns a new instance of SimpleGateway.
10 11 12 |
# File 'lib/flow/simple_gateway.rb', line 10 def initialize(order) @order = order end |
Instance Method Details
#cc_authorization ⇒ Object
authorises credit card and prepares for capture
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/flow/simple_gateway.rb', line 15 def response = FlowcommerceSpree.client..post(FlowcommerceSpree::ORGANIZATION, ) = response.result.status.value status = == ::Io::Flow::V0::Models::AuthorizationStatus..value store = { key: response.key, amount: response.amount, currency: response.currency, authorization_id: response.id } @order.flow_data['authorization'] = store @order.update_column(:meta, @order..to_json) if self.class.clear_zero_amount_payments @order.payments.where(amount: 0, state: %w[invalid processing pending]).map(&:destroy) end ActiveMerchant::Billing::Response.new(status, , { response: response }, authorization: store) rescue Io::Flow::V0::HttpClient::ServerError => e error_response(e) end |