class GetnetApi::PaymentCancel

Attributes

cancel_amount[RW]

cancel_amount interger Required Valor do pagamento em centavos

payment_id[RW]

payment_id string <= 36 characters Required ID do pagamento via cartão de crédito

Public Class Methods

create(payment_cancel) click to toggle source

a = GetnetApi::PaymentCancel.create cancelamento_pagamento

# File lib/getnet_api/payment_cancel.rb, line 35
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
new(campos={}) click to toggle source
# File lib/getnet_api/payment_cancel.rb, line 18
def initialize campos={}
  campos.each do |campo, valor|
    if GetnetApi::PaymentCancel.public_instance_methods.include? "#{campo}=".to_sym
      send "#{campo}=", valor
    end
  end
end

Private Class Methods

endpoint(payment_id) click to toggle source
# File lib/getnet_api/payment_cancel.rb, line 44
def self.endpoint payment_id
  "payments/credit/#{payment_id}/cancel"
end

Public Instance Methods

to_request() click to toggle source

Montar o Hash de dados do usuario no padrão utilizado pela Getnet

# File lib/getnet_api/payment_cancel.rb, line 27
def to_request
  pay_cancel = {
    payment_id: self.payment_id,
    cancel_amount: self.cancel_amount,
  }
end