Class: DPay::Transaction
- Inherits:
-
Object
- Object
- DPay::Transaction
- Defined in:
- lib/dpay/payment/transaction.rb,
sig/dpay/payment/transaction.rbs
Instance Attribute Summary collapse
-
#available_refund_amount ⇒ Money
readonly
Returns the value of attribute available_refund_amount.
-
#creation_date ⇒ String?
readonly
Returns the value of attribute creation_date.
-
#gateway_id ⇒ String?
readonly
Returns the value of attribute gateway_id.
-
#id ⇒ String
readonly
Returns the value of attribute id.
-
#payer ⇒ Hash[String, untyped]
readonly
Returns the value of attribute payer.
-
#payment_date ⇒ String?
readonly
Returns the value of attribute payment_date.
-
#payment_method ⇒ String?
readonly
Returns the value of attribute payment_method.
-
#raw ⇒ Hash[String, untyped]
readonly
Returns the value of attribute raw.
-
#refunded_amount ⇒ Money
readonly
Returns the value of attribute refunded_amount.
-
#refunds ⇒ Array[TransactionRefund]
readonly
Returns the value of attribute refunds.
-
#status ⇒ String
readonly
Returns the value of attribute status.
-
#value ⇒ Money
readonly
Returns the value of attribute value.
Class Method Summary collapse
Instance Method Summary collapse
- #direct? ⇒ Boolean
- #fully_refunded? ⇒ Boolean
-
#initialize(data) ⇒ Transaction
constructor
A new instance of Transaction.
- #paid? ⇒ Boolean
- #refunded? ⇒ Boolean
- #settled? ⇒ Boolean
Constructor Details
#initialize(data) ⇒ Transaction
Returns a new instance of Transaction.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/dpay/payment/transaction.rb', line 12 def initialize(data) @raw = data tx = data["transaction"].is_a?(Hash) ? data["transaction"] : {} @id = Internal::Coerce.string(tx["id"]) || "" @value = Internal::Coerce.money(tx["value"]) @status = Internal::Coerce.string(tx["status"]) || "" @payment_method = Internal::Coerce.string(tx["payment_method"]) @creation_date = Internal::Coerce.string(tx["creation_date"]) @payment_date = tx["payment_date"].is_a?(String) ? tx["payment_date"] : nil @settled = Internal::Coerce.boolean(tx["settled"]) @refunded = Internal::Coerce.boolean(tx["refunded"]) @refunded_amount = Internal::Coerce.money(tx["refunded_amount"]) @available_refund_amount = Internal::Coerce.money(tx["available_refund_amount"]) @fully_refunded = Internal::Coerce.boolean(tx["fully_refunded"]) @direct = Internal::Coerce.boolean(tx["direct"]) @gateway_id = tx["gateway_id"].is_a?(String) ? tx["gateway_id"] : nil @payer = data["payer"].is_a?(Hash) ? data["payer"] : {} @refunds = Internal::Coerce.list(data["refunds"]).map { |refund| TransactionRefund.from_api(refund) } freeze end |
Instance Attribute Details
#available_refund_amount ⇒ Money (readonly)
Returns the value of attribute available_refund_amount.
5 6 7 |
# File 'lib/dpay/payment/transaction.rb', line 5 def available_refund_amount @available_refund_amount end |
#creation_date ⇒ String? (readonly)
Returns the value of attribute creation_date.
5 6 7 |
# File 'lib/dpay/payment/transaction.rb', line 5 def creation_date @creation_date end |
#gateway_id ⇒ String? (readonly)
Returns the value of attribute gateway_id.
5 6 7 |
# File 'lib/dpay/payment/transaction.rb', line 5 def gateway_id @gateway_id end |
#id ⇒ String (readonly)
Returns the value of attribute id.
5 6 7 |
# File 'lib/dpay/payment/transaction.rb', line 5 def id @id end |
#payer ⇒ Hash[String, untyped] (readonly)
Returns the value of attribute payer.
5 6 7 |
# File 'lib/dpay/payment/transaction.rb', line 5 def payer @payer end |
#payment_date ⇒ String? (readonly)
Returns the value of attribute payment_date.
5 6 7 |
# File 'lib/dpay/payment/transaction.rb', line 5 def payment_date @payment_date end |
#payment_method ⇒ String? (readonly)
Returns the value of attribute payment_method.
5 6 7 |
# File 'lib/dpay/payment/transaction.rb', line 5 def payment_method @payment_method end |
#raw ⇒ Hash[String, untyped] (readonly)
Returns the value of attribute raw.
5 6 7 |
# File 'lib/dpay/payment/transaction.rb', line 5 def raw @raw end |
#refunded_amount ⇒ Money (readonly)
Returns the value of attribute refunded_amount.
5 6 7 |
# File 'lib/dpay/payment/transaction.rb', line 5 def refunded_amount @refunded_amount end |
#refunds ⇒ Array[TransactionRefund] (readonly)
Returns the value of attribute refunds.
5 6 7 |
# File 'lib/dpay/payment/transaction.rb', line 5 def refunds @refunds end |
#status ⇒ String (readonly)
Returns the value of attribute status.
5 6 7 |
# File 'lib/dpay/payment/transaction.rb', line 5 def status @status end |
#value ⇒ Money (readonly)
Returns the value of attribute value.
5 6 7 |
# File 'lib/dpay/payment/transaction.rb', line 5 def value @value end |
Class Method Details
.from_api(data) ⇒ Transaction
8 9 10 |
# File 'lib/dpay/payment/transaction.rb', line 8 def self.from_api(data) new(data) end |
Instance Method Details
#direct? ⇒ Boolean
50 51 52 |
# File 'lib/dpay/payment/transaction.rb', line 50 def direct? @direct end |
#fully_refunded? ⇒ Boolean
46 47 48 |
# File 'lib/dpay/payment/transaction.rb', line 46 def fully_refunded? @fully_refunded end |
#paid? ⇒ Boolean
34 35 36 |
# File 'lib/dpay/payment/transaction.rb', line 34 def paid? @status == TransactionStatus::PAID || @status == TransactionStatus::CAPTURED end |
#refunded? ⇒ Boolean
42 43 44 |
# File 'lib/dpay/payment/transaction.rb', line 42 def refunded? @refunded end |
#settled? ⇒ Boolean
38 39 40 |
# File 'lib/dpay/payment/transaction.rb', line 38 def settled? @settled end |