Sha256: 7cd4198a54ef4a6c9a986ff79c1e34cfbade7225320d7b8d9175c7895779d912
Contents?: true
Size: 1.1 KB
Versions: 14
Compression:
Stored size: 1.1 KB
Contents
module Mundipagg class Gateway < ActiveMerchant::Billing::Gateway def initialize(options={}) requires! options, :merchant_key super end def purchase(amount, object) call amount, object, :create_order end def refund(amount, object) call amount, object, :manage_order end private def call(amount, object, method) payload = apply_merchant_key object.payload(amount) result = client.send(method, payload) response = object.class::Response.new(result.body) params = { body: result.body } if response.success? message = "Ok" options = {} else message = response.error.message options = { error_code: response.error.code } end ActiveMerchant::Billing::Response.new response.success?, message, params, options end def apply_merchant_key(body) payload = body.to_a payload.insert(-2, [ :merchant_key, options[:merchant_key] ]) payload.each_with_object({}) { |(k, v), h| h[k] = v } end def client @client ||= ::Mundipagg::Client.new end end end
Version data entries
14 entries across 14 versions & 1 rubygems