Sha256: e1ee63398cc6ed5832776f5bc7d2994fbf13b7917861f39ee3c7bb8283d4c2a1

Contents?: true

Size: 837 Bytes

Versions: 4

Compression:

Stored size: 837 Bytes

Contents

require 'i18n'

class MercadoPagoCheckout

  def initialize(model)
    @model = model
  end

  def generate(success_url, pending_url, failure_url)
    { :external_reference => @model.external_reference,
      :items =>  get_items,
      :payer => get_payer,
      :back_urls => { pending: pending_url, success: success_url, failure: failure_url }
    }
  end

  private
    def get_items
      [{  :id => '',
          :title => "#{I18n.t('mercadopago.preference.title', brand: @model.title)}",
          :quantity => @model.quantity,
          :unit_price => @model.unit_price,
          :currency_id => @model.currency,
          :picture_url => @model.picture_url
      }]
    end

    def get_payer
      { :name => @model.payer_namer,
       :surname => @model.payer_surname,
       :email => @model.payer_email
      }
    end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
mercado_pago_rails-0.1.3 lib/mercado_pago_rails/mercado_pago_checkout.rb
mercado_pago_rails-0.1.2 lib/mercado_pago_rails/mercado_pago_checkout.rb
mercado_pago_rails-0.1.1 lib/mercado_pago_rails/mercado_pago_checkout.rb
mercado_pago_rails-0.1.0 lib/mercado_pago_rails/mercado_pago_checkout.rb