Class: PagSeguro::Transaction
- Inherits:
-
Object
- Object
- PagSeguro::Transaction
show all
- Extended by:
- Forwardable
- Defined in:
- lib/pagseguro/transaction.rb,
lib/pagseguro/transaction/item.rb,
lib/pagseguro/transaction/items.rb,
lib/pagseguro/transaction/phone.rb,
lib/pagseguro/transaction/sender.rb,
lib/pagseguro/transaction/address.rb,
lib/pagseguro/transaction/shipping.rb,
lib/pagseguro/transaction/creditor_fees.rb,
lib/pagseguro/transaction/payment_method.rb
Defined Under Namespace
Classes: Address, CreditorFees, Item, Items, PaymentMethod, Phone, Sender, Shipping
Constant Summary
collapse
- PAYMENT_STATUS =
{ '1' => :awaiting_payment, '2' => :pending, '3' => :paid,
'4' => :available, '5' => :in_dispute, '6' => :refunded, '7' => :canceled,
'8' => :chargeback, '9' => :plea }
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(response) ⇒ Transaction
Returns a new instance of Transaction.
13
14
15
|
# File 'lib/pagseguro/transaction.rb', line 13
def initialize(response)
@response = response
end
|
Instance Attribute Details
#response ⇒ Object
Returns the value of attribute response.
4
5
6
|
# File 'lib/pagseguro/transaction.rb', line 4
def response
@response
end
|
Instance Method Details
#cancellation_source ⇒ Object
45
46
47
|
# File 'lib/pagseguro/transaction.rb', line 45
def cancellation_source
transaction['cancellationSource']
end
|
#code ⇒ Object
25
26
27
|
# File 'lib/pagseguro/transaction.rb', line 25
def code
transaction['code']
end
|
#date ⇒ Object
17
18
19
|
# File 'lib/pagseguro/transaction.rb', line 17
def date
transaction['date']
end
|
#discount_amount ⇒ Object
61
62
63
|
# File 'lib/pagseguro/transaction.rb', line 61
def discount_amount
transaction['discountAmount']
end
|
#errors ⇒ Object
97
98
99
100
101
|
# File 'lib/pagseguro/transaction.rb', line 97
def errors
response['errors'] ||= {'error' => []}
[response['errors']['error']].flatten
end
|
#escrow_end_date ⇒ Object
65
66
67
|
# File 'lib/pagseguro/transaction.rb', line 65
def escrow_end_date
transaction['escrowEndDate']
end
|
73
74
75
|
# File 'lib/pagseguro/transaction.rb', line 73
def
transaction['extraAmount']
end
|
#fee_amount ⇒ Object
103
104
105
|
# File 'lib/pagseguro/transaction.rb', line 103
def fee_amount
transaction['feeAmount'] || creditor_fees.fee_amount
end
|
#gross_amount ⇒ Object
57
58
59
|
# File 'lib/pagseguro/transaction.rb', line 57
def gross_amount
transaction['grossAmount']
end
|
#installment_count ⇒ Object
77
78
79
|
# File 'lib/pagseguro/transaction.rb', line 77
def installment_count
transaction['installmentCount']
end
|
#items ⇒ Object
81
82
83
|
# File 'lib/pagseguro/transaction.rb', line 81
def items
Items.new(transaction['paymentMethod'], transaction['itemCount'])
end
|
#last_event_date ⇒ Object
21
22
23
|
# File 'lib/pagseguro/transaction.rb', line 21
def last_event_date
transaction['lastEventDate']
end
|
#net_amount ⇒ Object
69
70
71
|
# File 'lib/pagseguro/transaction.rb', line 69
def net_amount
transaction['netAmount']
end
|
#payment_link ⇒ Object
53
54
55
|
# File 'lib/pagseguro/transaction.rb', line 53
def payment_link
transaction['paymentLink']
end
|
#payment_method ⇒ Object
49
50
51
|
# File 'lib/pagseguro/transaction.rb', line 49
def payment_method
PaymentMethod.new(transaction['paymentMethod'])
end
|
#reference ⇒ Object
29
30
31
|
# File 'lib/pagseguro/transaction.rb', line 29
def reference
transaction['reference']
end
|
#sender ⇒ Object
85
86
87
|
# File 'lib/pagseguro/transaction.rb', line 85
def sender
Sender.new(transaction['sender']) if transaction['sender']
end
|
#shipping ⇒ Object
89
90
91
|
# File 'lib/pagseguro/transaction.rb', line 89
def shipping
Shipping.new(transaction['shipping'])
end
|
#status ⇒ Object
37
38
39
|
# File 'lib/pagseguro/transaction.rb', line 37
def status
transaction['status']
end
|
#status_name ⇒ Object
41
42
43
|
# File 'lib/pagseguro/transaction.rb', line 41
def status_name
PAYMENT_STATUS[status]
end
|
#type ⇒ Object
33
34
35
|
# File 'lib/pagseguro/transaction.rb', line 33
def type
transaction['type']
end
|
#valid? ⇒ Boolean
93
94
95
|
# File 'lib/pagseguro/transaction.rb', line 93
def valid?
!transaction.blank?
end
|