class Pagseguro::Charge::PaymentMethod

Payment data

@attr [String] payment_method States the payment method used in the charge. For now, we only support credit cards (“credit_card”) and boleto (“boleto”) @attr [Object] card The Credit Card object @attr [Integer] amount Gross amount of the charge, in cents. @attr [Integer] installments The number of monthly installments the card will be charged. This must be an one or two-digit integer between 1 and 12. @attr [Boolean] capture Represents if the charge must be created and captured. For now, ‘TRUE’ is the only supported value.

Attributes

boleto[RW]
capture[RW]
capture_before[RW]
card[RW]
installments[RW]
type[RW]

Public Class Methods

fill_from_json(data) click to toggle source
# 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
new(type = Pagseguro::Charge::ChargeRequest::TYPE_CREDITCARD) click to toggle source
# File lib/pagseguro/charge/payment_method.rb, line 20
def initialize(type = Pagseguro::Charge::ChargeRequest::TYPE_CREDITCARD)
  @type = type
end

Public Instance Methods

as_json(options={}) click to toggle source
# File lib/pagseguro/charge/payment_method.rb, line 45
def as_json(options={})
  {
    type: @type,
    installments: @installments,
    capture: @capture,
    capture_before: @capture_before,
    card: @card,
    boleto: @boleto,
  }
end
to_json(*options) click to toggle source
# File lib/pagseguro/charge/payment_method.rb, line 24
def to_json(*options)
  hash = as_json(*options)
  hash.reject! {|k,v| v.nil?}
  hash.to_json(*options)
end