Sha256: 5bd0fe0f5498a1f4b94fac47878949def5dcdda3c508b6e2951acb3ae961b7d1
Contents?: true
Size: 1.21 KB
Versions: 2
Compression:
Stored size: 1.21 KB
Contents
module GetnetApi class PaymentCancel < Base # payment_id # string <= 36 characters Required # ID do pagamento via cartão de crédito attr_accessor :payment_id # cancel_amount # interger Required # Valor do pagamento em centavos attr_accessor :cancel_amount # Validações do Rails 3 include ActiveModel::Validations validates :cancel_amount, length: { maximum: 10 } def initialize campos={} campos.each do |campo, valor| if GetnetApi::PaymentCancel.public_instance_methods.include? "#{campo}=".to_sym send "#{campo}=", valor end end end # Montar o Hash de dados do usuario no padrão utilizado pela Getnet def to_request pay_cancel = { payment_id: self.payment_id, cancel_amount: self.cancel_amount, } end # a = GetnetApi::PaymentCancel.create cancelamento_pagamento def self.create payment_cancel hash = payment_cancel.to_request response = self.build_request self.endpoint(hash[:payment_id]), "post", hash return JSON.parse(response.read_body) end private def self.endpoint payment_id "payments/credit/#{payment_id}/cancel" end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
getnet_api-1.0.3 | lib/getnet_api/payment_cancel.rb |
getnet_api-1.0.1 | lib/getnet_api/payment_cancel.rb |