Class: Afterpay::Payment
- Inherits:
-
Object
- Object
- Afterpay::Payment
- Defined in:
- lib/afterpay/payment.rb
Overview
They Payment object
Instance Attribute Summary collapse
-
#created ⇒ Object
Returns the value of attribute created.
-
#error ⇒ Object
Returns the value of attribute error.
-
#id ⇒ Object
Returns the value of attribute id.
-
#order ⇒ Object
Returns the value of attribute order.
-
#status ⇒ Object
Returns the value of attribute status.
-
#total ⇒ Object
Returns the value of attribute total.
Class Method Summary collapse
-
.execute(token:, reference:) ⇒ Payment
Executes the Payment.
Instance Method Summary collapse
-
#initialize(attributes) ⇒ Payment
constructor
Initialize Payment from response.
- #success? ⇒ Boolean
Constructor Details
#initialize(attributes) ⇒ Payment
Initialize Payment from response
25 26 27 28 29 30 31 32 |
# File 'lib/afterpay/payment.rb', line 25 def initialize(attributes) @id = attributes[:id] @status = attributes[:status] @created = attributes[:created] @total = Utils::Money.from_response(attributes[:total]) @order = Order.from_response(attributes[:orderDetails]) @error = Error.new(attributes) if attributes[:errorId] end |
Instance Attribute Details
#created ⇒ Object
Returns the value of attribute created.
22 23 24 |
# File 'lib/afterpay/payment.rb', line 22 def created @created end |
#error ⇒ Object
Returns the value of attribute error.
22 23 24 |
# File 'lib/afterpay/payment.rb', line 22 def error @error end |
#id ⇒ Object
Returns the value of attribute id.
22 23 24 |
# File 'lib/afterpay/payment.rb', line 22 def id @id end |
#order ⇒ Object
Returns the value of attribute order.
22 23 24 |
# File 'lib/afterpay/payment.rb', line 22 def order @order end |
#status ⇒ Object
Returns the value of attribute status.
22 23 24 |
# File 'lib/afterpay/payment.rb', line 22 def status @status end |
#total ⇒ Object
Returns the value of attribute total.
22 23 24 |
# File 'lib/afterpay/payment.rb', line 22 def total @total end |
Class Method Details
.execute(token:, reference:) ⇒ Payment
Executes the Payment
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/afterpay/payment.rb', line 11 def self.execute(token:, reference:) request = Afterpay.client.post("/v1/payments/capture") do |req| req.body = { token: token, merchantRefernce: reference } end new(request.body) end |
Instance Method Details
#success? ⇒ Boolean
34 35 36 |
# File 'lib/afterpay/payment.rb', line 34 def success? @status == "APPROVED" end |