class Pagseguro::Charge::ChargeRequest

Payment data

@attr [String] reference An arbitrary code provided for control, like an e-commerce order number @attr [String] payment_methods List of the different payment methods being using in a charge @attr [String] currency Three-letter ISO currency code, in uppercase. For now, only Brazilian Real is supported (“BRL”), must be 3 characters. @attr [String] description An arbitrary string attached to the object. Often useful for displaying to users, maximum 64 characters. @attr [String] metadata Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format.

Constants

TYPE_BOLETO
TYPE_CREDITCARD

Attributes

amount[RW]
description[RW]
id[RW]
payment_method[RW]
reference_id[RW]

Public Class Methods

fill_from_json(data) click to toggle source
# File lib/pagseguro/charge/charge_request.rb, line 35
def self.fill_from_json(data)
  return if data.nil?

  payment = new

  payment.id = data["id "]
  payment.reference_id = data["reference_id"]
  payment.payment_method = PaymentMethod.fill_from_json(data["payment_method"])
  payment.amount = Amount.fill_from_json(data["amount"])
  payment.description = data["description"]

  payment
end
new(args = {}) click to toggle source
# File lib/pagseguro/charge/charge_request.rb, line 21
def initialize(args = {})
  @id = args[:id]
  @reference_id = args[:reference_id]
  @payment_method = args[:payment_method]
  @amount = args[:amount]
  @description = args[:description]
end

Public Instance Methods

as_json(options={}) click to toggle source
# File lib/pagseguro/charge/charge_request.rb, line 50
def as_json(options={})
  {
    id: @id,
    reference_id: @reference_id,
    payment_method: @payment_method,
    description: @description,
    amount: @amount
  }
end
to_json(*options) click to toggle source
# File lib/pagseguro/charge/charge_request.rb, line 29
def to_json(*options)
  hash = as_json(*options)
  hash.reject! {|k,v| v.nil?}
  hash.to_json(*options)
end