Class: PaymentMethod::PagSeguroMethod

Inherits:
PaymentMethod
  • Object
show all
Defined in:
app/models/spree/payment_method/pag_seguro_method.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#order_idObject

Returns the value of attribute order_id.



4
5
6
# File 'app/models/spree/payment_method/pag_seguro_method.rb', line 4

def order_id
  @order_id
end

Instance Method Details

#actionsObject



10
11
12
# File 'app/models/spree/payment_method/pag_seguro_method.rb', line 10

def actions
  %w{capture void}
end

#can_capture?(payment) ⇒ Boolean

Indicates whether its possible to capture the payment

Returns:

  • (Boolean)


15
16
17
# File 'app/models/spree/payment_method/pag_seguro_method.rb', line 15

def can_capture?(payment)
  ['checkout', 'pending'].include?(payment.state)
end

#can_void?(payment) ⇒ Boolean

Indicates whether its possible to void the payment.

Returns:

  • (Boolean)


20
21
22
# File 'app/models/spree/payment_method/pag_seguro_method.rb', line 20

def can_void?(payment)
  payment.state != 'void'
end

#capture(*args) ⇒ Object



24
25
26
# File 'app/models/spree/payment_method/pag_seguro_method.rb', line 24

def capture(*args)
  ActiveMerchant::Billing::Response.new(true, "", {}, {})
end

#code(payment) ⇒ Object



40
41
42
43
44
45
46
47
48
# File 'app/models/spree/payment_method/pag_seguro_method.rb', line 40

def code(payment)
  if payment.pag_seguro_payment.present?
    payment.pag_seguro_payment.code
  else
    pag_seguro_payment = Spree::PagSeguroPayment.new
    pag_seguro_payment.process!(payment)
    pag_seguro_payment.code
  end
end

#payment_source_classObject



32
33
34
# File 'app/models/spree/payment_method/pag_seguro_method.rb', line 32

def payment_source_class
  self.class
end

#source_required?Boolean

Returns:

  • (Boolean)


36
37
38
# File 'app/models/spree/payment_method/pag_seguro_method.rb', line 36

def source_required?
  false
end

#void(*args) ⇒ Object



28
29
30
# File 'app/models/spree/payment_method/pag_seguro_method.rb', line 28

def void(*args)
  ActiveMerchant::Billing::Response.new(true, "", {}, {})
end