class PagSeguro::Transaction

Constants

FIFTEEN_MINUTES_IN_SECONDS
ONE_DAY_IN_SECONDS

Attributes

cancellation_source[RW]

The cancellation source.

code[RW]

The transaction code.

created_at[RW]

When the payment request was created.

creditor_fees[R]

The charged fees.

discount_amount[RW]

The discount amount.

errors[R]

Set the transaction errors.

escrow_end_date[RW]

The escrow end date.

extra_amount[RW]

Set the extra amount applied to the transaction's total. It's considered as an extra charge when positive, or a discount if negative.

gross_amount[RW]

The gross amount.

installments[RW]

The installment count.

net_amount[RW]

The net amount.

payment_method[R]

The payment method.

reference[RW]

The reference code identifies the order you placed on the payment request. It's used by the store and can be something like the order id.

sender[R]

The payer information (who is sending money).

shipping[R]

The shipping information.

status[R]

The transaction status.

type_id[RW]

The transaction type.

updated_at[RW]

The last notification's update.

Public Class Methods

find_abandoned(options = {}, page = 0) click to toggle source

Get abandoned transactions. Return a PagSeguro::SearchByDate instance

Options:

# starts_at: the starting date. Defaults to the last 24-hours. # ends_at: the ending date. Defaults to 15 minutes ago. Attention: you have to set it this to Time.now - 15 minutes, otherwise the “finalDate must be lower than allowed limit” error will be returned. # page: the current page. # per_page: the result limit.

# File lib/pagseguro/transaction.rb, line 122
def self.find_abandoned(options = {}, page = 0)
  options = {
    starts_at: Time.now - ONE_DAY_IN_SECONDS,
    ends_at: Time.now - FIFTEEN_MINUTES_IN_SECONDS,
    per_page: 50
  }.merge(options)

  SearchAbandoned.new("transactions/abandoned", options, page)
end
find_by_code(code, options = {}) click to toggle source

Find a transaction by its transactionCode Return a PagSeguro::Transaction instance

# File lib/pagseguro/transaction.rb, line 72
def self.find_by_code(code, options = {})
  load_from_response send_request("transactions/#{code}", options)
end
find_by_date(options = {}, page = 0) click to toggle source

Search transactions within a date range. Return a PagSeguro::SearchByDate instance

Options:

# starts_at: the starting date. Defaults to the last 24-hours. # ends_at: the ending date. # page: the current page. # per_page: the result limit.

# File lib/pagseguro/transaction.rb, line 92
def self.find_by_date(options = {}, page = 0)
  options = {
    starts_at: Time.now - ONE_DAY_IN_SECONDS,
    ends_at: Time.now,
    per_page: 50
  }.merge(options)
  SearchByDate.new("transactions", options, page)
end
find_by_notification_code(code, options = {}) click to toggle source

Find a transaction by its notificationCode. Return a PagSeguro::Transaction instance.

# File lib/pagseguro/transaction.rb, line 78
def self.find_by_notification_code(code, options = {})
  load_from_response send_request("transactions/notifications/#{code}", options)
end
find_by_reference(reference, options = {}) click to toggle source

Search a transaction by its reference code Return a PagSeguro::SearchByReference instance

Options:

# reference: the transaction reference code

# File lib/pagseguro/transaction.rb, line 108
def self.find_by_reference(reference, options = {})
  SearchByReference.new("transactions", { reference: reference }.merge(options))
end

Private Class Methods

api_version() click to toggle source
# File lib/pagseguro/transaction.rb, line 193
def self.api_version
  'v3'
end
send_request(path, options = {}) click to toggle source

Send a get request to v3 API version, with the path given

# File lib/pagseguro/transaction.rb, line 211
def self.send_request(path, options = {})
  Request.get(path, api_version, options)
end

Public Instance Methods

creditor_fees=(creditor_fees) click to toggle source

Normalize creditor fees object

# File lib/pagseguro/transaction.rb, line 133
def creditor_fees=(creditor_fees)
  @creditor_fees = ensure_type(CreditorFee, creditor_fees)
end
items() click to toggle source

Hold the transaction's items.

# File lib/pagseguro/transaction.rb, line 158
def items
  @items ||= Items.new
end
items=(_items) click to toggle source

Normalize the items list.

# File lib/pagseguro/transaction.rb, line 163
def items=(_items)
  _items.each {|item| items << item }
end
payment_method=(payment_method) click to toggle source

Normalize the payment method.

# File lib/pagseguro/transaction.rb, line 168
def payment_method=(payment_method)
  @payment_method = ensure_type(PaymentMethod, payment_method)
end
payment_releases() click to toggle source

Hold the transaction's payments

# File lib/pagseguro/transaction.rb, line 148
def payment_releases
  @payment_releases ||= PaymentReleases.new
end
payment_releases=(_payments) click to toggle source

Normalize the transaction's payments list

# File lib/pagseguro/transaction.rb, line 153
def payment_releases=(_payments)
  _payments.each { |payment| payment_releases << payment }
end
sender=(sender) click to toggle source

Normalize the sender object.

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

Normalize the shipping object.

# File lib/pagseguro/transaction.rb, line 143
def shipping=(shipping)
  @shipping = ensure_type(Shipping, shipping)
end
status=(status) click to toggle source

Normalize the payment status.

# File lib/pagseguro/transaction.rb, line 173
def status=(status)
  @status = ensure_type(PaymentStatus, status)
end
update_attributes(attrs) click to toggle source

Update all attributes

# File lib/pagseguro/transaction.rb, line 183
def update_attributes(attrs)
  attrs.each { |name, value| send("#{name}=", value) }
end

Private Instance Methods

after_initialize() click to toggle source
# File lib/pagseguro/transaction.rb, line 197
def after_initialize
  @errors = Errors.new
end