Class: PagSeguro::Transaction
- Inherits:
-
Object
- Object
- PagSeguro::Transaction
- Defined in:
- lib/pagseguro/transaction.rb,
lib/pagseguro/transaction/response.rb,
lib/pagseguro/transaction/collection.rb,
lib/pagseguro/transaction/serializer.rb
Defined Under Namespace
Classes: Collection, Response, Serializer
Constant Summary collapse
- ONE_DAY_IN_SECONDS =
86400
- FIFTEEN_MINUTES_IN_SECONDS =
900
Instance Attribute Summary collapse
-
#cancellation_source ⇒ Object
The cancellation source.
-
#code ⇒ Object
The transaction code.
-
#created_at ⇒ Object
When the payment request was created.
-
#creditor_fees ⇒ Object
The charged fees.
-
#discount_amount ⇒ Object
The discount amount.
-
#errors ⇒ Object
readonly
Set errors.
-
#escrow_end_date ⇒ Object
The escrow end date.
-
#extra_amount ⇒ Object
Set the extra amount applied to the transaction’s total.
-
#gross_amount ⇒ Object
The gross amount.
-
#installments ⇒ Object
The installment count.
-
#net_amount ⇒ Object
The net amount.
-
#payment_link ⇒ Object
The boleto payment url.
-
#payment_method ⇒ Object
The payment method.
-
#reference ⇒ Object
The reference code identifies the order you placed on the payment request.
-
#sender ⇒ Object
The payer information (who is sending money).
-
#shipping ⇒ Object
The shipping information.
-
#status ⇒ Object
The transaction status.
-
#type_id ⇒ Object
The transaction type.
-
#updated_at ⇒ Object
The last notification’s update.
Attributes included from Extensions::Credentiable
Class Method Summary collapse
-
.find_abandoned(options = {}, page = 0) ⇒ Object
Get abandoned transactions.
-
.find_by_code(code, options = {}) ⇒ Object
Find a transaction by its transactionCode Return a PagSeguro::Transaction instance.
-
.find_by_date(options = {}, page = 0) ⇒ Object
Search transactions within a date range.
-
.find_by_notification_code(code, options = {}) ⇒ Object
Find a transaction by its notificationCode.
-
.find_by_reference(reference, options = {}) ⇒ Object
Search a transaction by its reference code Return a PagSeguro::SearchByReference instance.
-
.load_from_xml(xml) ⇒ Object
Serialize the XML object.
Instance Method Summary collapse
-
#items ⇒ Object
Hold the transaction’s items.
-
#items=(_items) ⇒ Object
Normalize the items list.
-
#payment_releases ⇒ Object
Hold the transaction’s payments.
-
#payment_releases=(_payments) ⇒ Object
Normalize the transaction’s payments list.
-
#update_attributes(attrs) ⇒ Object
Update all attributes.
Methods included from Extensions::EnsureType
Methods included from Extensions::MassAssignment
Instance Attribute Details
#cancellation_source ⇒ Object
The cancellation source.
62 63 64 |
# File 'lib/pagseguro/transaction.rb', line 62 def cancellation_source @cancellation_source end |
#code ⇒ Object
The transaction code.
14 15 16 |
# File 'lib/pagseguro/transaction.rb', line 14 def code @code end |
#created_at ⇒ Object
When the payment request was created.
11 12 13 |
# File 'lib/pagseguro/transaction.rb', line 11 def created_at @created_at end |
#creditor_fees ⇒ Object
The charged fees.
42 43 44 |
# File 'lib/pagseguro/transaction.rb', line 42 def creditor_fees @creditor_fees end |
#discount_amount ⇒ Object
The discount amount.
39 40 41 |
# File 'lib/pagseguro/transaction.rb', line 39 def discount_amount @discount_amount end |
#errors ⇒ Object (readonly)
Set errors.
68 69 70 |
# File 'lib/pagseguro/transaction.rb', line 68 def errors @errors end |
#escrow_end_date ⇒ Object
The escrow end date.
65 66 67 |
# File 'lib/pagseguro/transaction.rb', line 65 def escrow_end_date @escrow_end_date end |
#extra_amount ⇒ Object
Set the extra amount applied to the transaction’s total. It’s considered as an extra charge when positive, or a discount if negative.
50 51 52 |
# File 'lib/pagseguro/transaction.rb', line 50 def extra_amount @extra_amount end |
#gross_amount ⇒ Object
The gross amount.
36 37 38 |
# File 'lib/pagseguro/transaction.rb', line 36 def gross_amount @gross_amount end |
#installments ⇒ Object
The installment count.
53 54 55 |
# File 'lib/pagseguro/transaction.rb', line 53 def installments @installments end |
#net_amount ⇒ Object
The net amount.
45 46 47 |
# File 'lib/pagseguro/transaction.rb', line 45 def net_amount @net_amount end |
#payment_link ⇒ Object
The boleto payment url.
33 34 35 |
# File 'lib/pagseguro/transaction.rb', line 33 def payment_link @payment_link end |
#payment_method ⇒ Object
The payment method.
30 31 32 |
# File 'lib/pagseguro/transaction.rb', line 30 def payment_method @payment_method end |
#reference ⇒ Object
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.
18 19 20 |
# File 'lib/pagseguro/transaction.rb', line 18 def reference @reference end |
#sender ⇒ Object
The payer information (who is sending money).
56 57 58 |
# File 'lib/pagseguro/transaction.rb', line 56 def sender @sender end |
#shipping ⇒ Object
The shipping information.
59 60 61 |
# File 'lib/pagseguro/transaction.rb', line 59 def shipping @shipping end |
#status ⇒ Object
The transaction status.
27 28 29 |
# File 'lib/pagseguro/transaction.rb', line 27 def status @status end |
#type_id ⇒ Object
The transaction type.
21 22 23 |
# File 'lib/pagseguro/transaction.rb', line 21 def type_id @type_id end |
#updated_at ⇒ Object
The last notification’s update.
24 25 26 |
# File 'lib/pagseguro/transaction.rb', line 24 def updated_at @updated_at end |
Class Method Details
.find_abandoned(options = {}, page = 0) ⇒ Object
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.
122 123 124 125 126 127 128 129 130 |
# File 'lib/pagseguro/transaction.rb', line 122 def self.find_abandoned( = {}, page = 0) = { starts_at: Time.now - ONE_DAY_IN_SECONDS, ends_at: Time.now - FIFTEEN_MINUTES_IN_SECONDS, per_page: 50 }.merge() SearchAbandoned.new("transactions/abandoned", , page) end |
.find_by_code(code, options = {}) ⇒ Object
Find a transaction by its transactionCode Return a PagSeguro::Transaction instance
72 73 74 |
# File 'lib/pagseguro/transaction.rb', line 72 def self.find_by_code(code, = {}) load_from_response send_request("transactions/#{code}", ) end |
.find_by_date(options = {}, page = 0) ⇒ Object
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.
92 93 94 95 96 97 98 99 |
# File 'lib/pagseguro/transaction.rb', line 92 def self.find_by_date( = {}, page = 0) = { starts_at: Time.now - ONE_DAY_IN_SECONDS, ends_at: Time.now, per_page: 50 }.merge() SearchByDate.new("transactions", , page) end |
.find_by_notification_code(code, options = {}) ⇒ Object
Find a transaction by its notificationCode. Return a PagSeguro::Transaction instance.
78 79 80 |
# File 'lib/pagseguro/transaction.rb', line 78 def self.find_by_notification_code(code, = {}) load_from_response send_request("transactions/notifications/#{code}", ) end |
.find_by_reference(reference, options = {}) ⇒ Object
Search a transaction by its reference code Return a PagSeguro::SearchByReference instance
Options:
# reference
: the transaction reference code
108 109 110 |
# File 'lib/pagseguro/transaction.rb', line 108 def self.find_by_reference(reference, = {}) SearchByReference.new("transactions", { reference: reference }.merge()) end |
.load_from_xml(xml) ⇒ Object
Serialize the XML object.
188 189 190 |
# File 'lib/pagseguro/transaction.rb', line 188 def self.load_from_xml(xml) # :nodoc: new Serializer.new(xml).serialize end |
Instance Method Details
#items ⇒ Object
Hold the transaction’s items.
158 159 160 |
# File 'lib/pagseguro/transaction.rb', line 158 def items @items ||= Items.new end |
#items=(_items) ⇒ Object
Normalize the items list.
163 164 165 |
# File 'lib/pagseguro/transaction.rb', line 163 def items=(_items) _items.each {|item| items << item } end |
#payment_releases ⇒ Object
Hold the transaction’s payments
148 149 150 |
# File 'lib/pagseguro/transaction.rb', line 148 def payment_releases @payment_releases ||= PaymentReleases.new end |
#payment_releases=(_payments) ⇒ Object
Normalize the transaction’s payments list
153 154 155 |
# File 'lib/pagseguro/transaction.rb', line 153 def payment_releases=(_payments) _payments.each { |payment| payment_releases << payment } end |
#update_attributes(attrs) ⇒ Object
Update all attributes
183 184 185 |
# File 'lib/pagseguro/transaction.rb', line 183 def update_attributes(attrs) attrs.each { |name, value| send("#{name}=", value) } end |