Sha256: 738c0cc34f2c9a56e3c8aa6f5ee4ac7582f8da9e831b3107ea7cbd1ae170bc78
Contents?: true
Size: 1.07 KB
Versions: 1
Compression:
Stored size: 1.07 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" else message = response.error.message params.merge! error_code: response.error.code end ActiveMerchant::Billing::Response.new response.success?, message, params 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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
better-mundipagg-0.1.1 | lib/mundipagg/gateway.rb |