Class: GetnetApi::PaymentCancel

Inherits:
Base
  • Object
show all
Includes:
ActiveModel::Validations
Defined in:
lib/getnet_api/payment_cancel.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

build_request, default_headers, get_token_de_bearer, valid_bearer

Constructor Details

#initialize(campos = {}) ⇒ PaymentCancel

Returns a new instance of PaymentCancel.



18
19
20
21
22
23
24
# 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

Instance Attribute Details

#cancel_amountObject

cancel_amount interger Required Valor do pagamento em centavos



11
12
13
# File 'lib/getnet_api/payment_cancel.rb', line 11

def cancel_amount
  @cancel_amount
end

#payment_idObject

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



6
7
8
# File 'lib/getnet_api/payment_cancel.rb', line 6

def payment_id
  @payment_id
end

Class Method Details

.create(payment_cancel) ⇒ Object

a = GetnetApi::PaymentCancel.create cancelamento_pagamento



35
36
37
38
39
40
41
# 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

Instance Method Details

#to_requestObject

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



27
28
29
30
31
32
# 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