class GetnetApi::Payment
Attributes
amount[RW]
amount integer Required Valor da compra em centavos.
currency[RW]
currency string 3 characters Identificação da moeda (Consultar código em “www.currency-iso.org/en/home/tables/table-a1.html”).
customer[RW]
Objeto do tipo GetnetApi::Customer
order[RW]
Objeto do tipo GetnetApi::Order
Public Class Methods
create(payment, obj, type)
click to toggle source
a = GetnetApi::Payment.create
pagamento, boleto, :boleto
# File lib/getnet_api/payment.rb, line 93 def self.create(payment, obj, type) hash = payment.to_request(obj, type) response = self.build_request self.endpoint(type), "post", hash return JSON.parse(response.read_body) end
new(campos = {})
click to toggle source
Nova instancia da classe Cliente @param [Hash] campos
# File lib/getnet_api/payment.rb, line 65 def initialize(campos = {}) campos.each do |campo, valor| if GetnetApi::Payment.public_instance_methods.include? "#{campo}=".to_sym send "#{campo}=", valor end end end
Private Class Methods
endpoint(type)
click to toggle source
# File lib/getnet_api/payment.rb, line 104 def self.endpoint type if type == :boleto return "payments/boleto" elsif :credit return "payments/credit" end end
Public Instance Methods
to_request(obj, type)
click to toggle source
Montar o Hash de dados do usuario no padrão utilizado pela Getnet
# File lib/getnet_api/payment.rb, line 74 def to_request obj, type payment = { seller_id: GetnetApi.seller_id.to_s, amount: self.amount.to_i, currency: self.currency.to_s, order: self.order.to_request, customer: self.customer.to_request(:payment), } if type == :boleto payment.merge!({"boleto" => obj.to_request,}) elsif :credit payment.merge!({"credit" => obj.to_request,}) end return payment end