Sha256: dbab79854b2e978ee071d61acbb965285d0fa357678d51f7840c0e3a6cd17798
Contents?: true
Size: 1.07 KB
Versions: 2
Compression:
Stored size: 1.07 KB
Contents
require 'mercadopago' require 'app_configuration' class MercadoPagoRailsHelper APPROVED = :approved PENDING = :pending IN_PROCESS = :in_process REJECTED = :rejected REFUNDED = :refunded CANCELLED = :cancelled IN_MEDIATION = :in_mediation class << self @@mp = MercadoPago.new(AppConfiguration.for(:mercadopago).client_id, AppConfiguration.for(:mercadopago).client_secret) def mp @@mp end def set_handlers(status_handlers = {}) validate_presence(status_handlers) @contexts = status_handlers.dup end def get_context(response, obj) status = response['response']['collection']['status'].to_sym @contexts[status].new(response, obj) end private def validate_presence(status_handlers) if status_handlers[APPROVED].nil? || status_handlers[PENDING].nil? || status_handlers[IN_PROCESS].nil? || status_handlers[REJECTED].nil? || status_handlers[REFUNDED].nil? || status_handlers[CANCELLED].nil? || status_handlers[IN_MEDIATION].nil? raise "MissingStatusHandler" end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
mercado_pago_rails-0.1.3 | lib/mercado_pago_rails/mercado_pago_rails_helper.rb |
mercado_pago_rails-0.1.2 | lib/mercado_pago_rails/mercado_pago_rails_helper.rb |