class PagSeguro::Transaction
Constants
- FIFTEEN_MINUTES_IN_SECONDS
- ONE_DAY_IN_SECONDS
Attributes
The cancellation source.
The transaction code.
When the payment request was created.
The charged fees.
The discount amount.
Set the transaction errors.
The escrow end date.
Set the extra amount applied to the transaction's total. It's considered as an extra charge when positive, or a discount if negative.
The gross amount.
The installment count.
The net amount.
The boleto payment url.
The payment method.
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.
The payer information (who is sending money).
The shipping information.
The transaction status.
The transaction type.
The last notification's update.
Public Class Methods
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 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
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 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
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
# File lib/pagseguro/transaction.rb, line 193 def self.api_version 'v3' end
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
Normalize creditor fees object
# File lib/pagseguro/transaction.rb, line 133 def creditor_fees=(creditor_fees) @creditor_fees = ensure_type(CreditorFee, creditor_fees) end
Hold the transaction's items.
# File lib/pagseguro/transaction.rb, line 158 def items @items ||= Items.new end
Normalize the items list.
# File lib/pagseguro/transaction.rb, line 163 def items=(_items) _items.each {|item| items << item } end
Normalize the payment method.
# File lib/pagseguro/transaction.rb, line 168 def payment_method=(payment_method) @payment_method = ensure_type(PaymentMethod, payment_method) end
Hold the transaction's payments
# File lib/pagseguro/transaction.rb, line 148 def payment_releases @payment_releases ||= PaymentReleases.new end
Normalize the transaction's payments list
# File lib/pagseguro/transaction.rb, line 153 def payment_releases=(_payments) _payments.each { |payment| payment_releases << payment } end
Normalize the sender object.
# File lib/pagseguro/transaction.rb, line 138 def sender=(sender) @sender = ensure_type(Sender, sender) end
Normalize the shipping object.
# File lib/pagseguro/transaction.rb, line 143 def shipping=(shipping) @shipping = ensure_type(Shipping, shipping) end
Normalize the payment status.
# File lib/pagseguro/transaction.rb, line 173 def status=(status) @status = ensure_type(PaymentStatus, status) end
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
# File lib/pagseguro/transaction.rb, line 197 def after_initialize @errors = Errors.new end