class PagSeguro::TransactionRequest

Attributes

code[RW]

The transaction code returned from api.

created_at[RW]

The created at date returned from api

currency[RW]

Set the payment currency. Defaults to BRL.

discount_amount[RW]

The discount amount returned from api.

errors[W]
extra_amount[RW]

Set the extra amount to be applied to the transaction's total. This value can be used to add an extra charge to the transaction or provide a discount, if negative.

extra_params[RW]

The extra parameters for payment request.

gross_amount[RW]

The gross amount returned from api.

installment_count[RW]

The installments number returned from api.

net_amount[RW]

The net amount returned from api.

notification_url[RW]

Determines for which url PagSeguro will send the order related notifications codes. Optional. Any change happens in the transaction status, a new notification request will be send to this url. You can use that for update the related order.

payment_method[RW]

The payment method returned from api.

payment_mode[RW]

Set the payment mode.

primary_receiver[RW]

Set and get primary receiver email.

receivers[R]

Get the payment receivers.

reference[RW]

Set the reference code. Optional. You can use the reference code to store an identifier so you can associate the PagSeguro transaction to a transaction in your system. Tipically this is the order id.

sender[R]

Get the payment sender.

shipping[R]

Get the shipping info.

status[RW]

The transaction status returned from api.

type_id[RW]

The transaction type returned from api.

updated_at[RW]

The updated at date returned from api

Public Instance Methods

create() click to toggle source

Calls the PagSeguro web service and create this request for payment. Return boolean.

# File lib/pagseguro/transaction_request.rb, line 108
def create
  request = if receivers.empty?
              Request.post('transactions', api_version, params)
            else
              Request.post_xml('transactions/', nil, credentials, xml_params)
            end

  Response.new(request, self).serialize
end
errors() click to toggle source
# File lib/pagseguro/transaction_request.rb, line 87
def errors
  @errors ||= Errors.new
end
items() click to toggle source

Products/items in this payment request.

# File lib/pagseguro/transaction_request.rb, line 83
def items
  @items ||= Items.new
end
receivers=(receivers) click to toggle source

Set the receivers.

# File lib/pagseguro/transaction_request.rb, line 123
def receivers=(receivers)
  @receivers = receivers.map do |receiver|
                 ensure_type(Receiver, receiver)
               end
end
sender=(sender) click to toggle source

Set the payment sender.

# File lib/pagseguro/transaction_request.rb, line 97
def sender=(sender)
  @sender = ensure_type(Sender, sender)
end
shipping=(shipping) click to toggle source

Set the shipping info.

# File lib/pagseguro/transaction_request.rb, line 102
def shipping=(shipping)
  @shipping = ensure_type(Shipping, shipping)
end
update_attributes(attrs) click to toggle source
# File lib/pagseguro/transaction_request.rb, line 118
def update_attributes(attrs)
  attrs.map { |name, value| send("#{name}=", value) }
end

Private Instance Methods

api_version() click to toggle source
# File lib/pagseguro/transaction_request.rb, line 161
def api_version
  'v2'
end
before_initialize() click to toggle source
# File lib/pagseguro/transaction_request.rb, line 135
def before_initialize
  self.currency = "BRL"
  self.extra_params = []
  self.receivers = []
end
items=(items) click to toggle source

Used to set response items from api.

# File lib/pagseguro/transaction_request.rb, line 150
def items=(items)
  @items = Items.new
  items.map { |item| @items << item }
end
params() click to toggle source
# File lib/pagseguro/transaction_request.rb, line 141
def params
  RequestSerializer.new(self).to_params
end
payment_method=(payment_method) click to toggle source

Used to set the payment method from api.

# File lib/pagseguro/transaction_request.rb, line 156
def payment_method=(payment_method)
  @payment_method = ensure_type(PaymentMethod, payment_method)
end
xml_params() click to toggle source
# File lib/pagseguro/transaction_request.rb, line 145
def xml_params
  RequestSerializer.new(self).to_xml_params
end