Class: Pagseguro::Charge::PaymentMethod
- Inherits:
-
Object
- Object
- Pagseguro::Charge::PaymentMethod
- Defined in:
- lib/pagseguro/charge/payment_method.rb
Overview
Payment data
Instance Attribute Summary collapse
-
#amount ⇒ Integer
Gross amount of the charge, in cents.
-
#boleto ⇒ Object
Returns the value of attribute boleto.
-
#capture ⇒ Boolean
Represents if the charge must be created and captured.
-
#capture_before ⇒ Object
Returns the value of attribute capture_before.
-
#card ⇒ Object
The Credit Card object.
-
#installments ⇒ Integer
The number of monthly installments the card will be charged.
-
#payment_method ⇒ String
States the payment method used in the charge.
-
#type ⇒ Object
Returns the value of attribute type.
Class Method Summary collapse
Instance Method Summary collapse
- #as_json(options = {}) ⇒ Object
-
#initialize(type = Pagseguro::Charge::ChargeRequest::TYPE_CREDITCARD) ⇒ PaymentMethod
constructor
A new instance of PaymentMethod.
- #to_json(*options) ⇒ Object
Constructor Details
#initialize(type = Pagseguro::Charge::ChargeRequest::TYPE_CREDITCARD) ⇒ PaymentMethod
Returns a new instance of PaymentMethod.
20 21 22 |
# File 'lib/pagseguro/charge/payment_method.rb', line 20 def initialize(type = Pagseguro::Charge::ChargeRequest::TYPE_CREDITCARD) @type = type end |
Instance Attribute Details
#amount ⇒ Integer
Gross amount of the charge, in cents.
10 11 12 |
# File 'lib/pagseguro/charge/payment_method.rb', line 10 def amount @amount end |
#boleto ⇒ Object
Returns the value of attribute boleto.
12 13 14 |
# File 'lib/pagseguro/charge/payment_method.rb', line 12 def boleto @boleto end |
#capture ⇒ Boolean
Represents if the charge must be created and captured. For now, ‘TRUE’ is the only supported value.
10 11 12 |
# File 'lib/pagseguro/charge/payment_method.rb', line 10 def capture @capture end |
#capture_before ⇒ Object
Returns the value of attribute capture_before.
12 13 14 |
# File 'lib/pagseguro/charge/payment_method.rb', line 12 def capture_before @capture_before end |
#card ⇒ Object
The Credit Card object
10 11 12 |
# File 'lib/pagseguro/charge/payment_method.rb', line 10 def card @card end |
#installments ⇒ Integer
The number of monthly installments the card will be charged. This must be an one or two-digit integer between 1 and 12.
10 11 12 |
# File 'lib/pagseguro/charge/payment_method.rb', line 10 def installments @installments end |
#payment_method ⇒ String
States the payment method used in the charge. For now, we only support credit cards (“credit_card”) and boleto (“boleto”)
10 11 12 |
# File 'lib/pagseguro/charge/payment_method.rb', line 10 def payment_method @payment_method end |
#type ⇒ Object
Returns the value of attribute type.
12 13 14 |
# File 'lib/pagseguro/charge/payment_method.rb', line 12 def type @type end |
Class Method Details
.fill_from_json(data) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/pagseguro/charge/payment_method.rb', line 30 def self.fill_from_json(data) return if data.nil? payment_method = new payment_method.type = data["type"] payment_method.card = CreditCard.fill_from_json(data["card"]) payment_method.boleto = Boleto.fill_from_json(data["boleto"]) payment_method.installments = data["installments"] payment_method.capture = data["capture"] payment_method.capture_before = data["capture_before"] payment_method end |
Instance Method Details
#as_json(options = {}) ⇒ Object
45 46 47 48 49 50 51 52 53 54 |
# File 'lib/pagseguro/charge/payment_method.rb', line 45 def as_json(={}) { type: @type, installments: @installments, capture: @capture, capture_before: @capture_before, card: @card, boleto: @boleto, } end |
#to_json(*options) ⇒ Object
24 25 26 27 28 |
# File 'lib/pagseguro/charge/payment_method.rb', line 24 def to_json(*) hash = as_json(*) hash.reject! {|k,v| v.nil?} hash.to_json(*) end |