class Afterpay::Payment
They Payment
object
Attributes
created[RW]
error[RW]
id[RW]
order[RW]
status[RW]
total[RW]
Public Class Methods
execute(token:, reference:)
click to toggle source
Executes the Payment
@param token [String] the Order
token @param reference [String] the reference for payment @return [Payment] the Payment
object
# 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
new(attributes)
click to toggle source
Initialize Payment
from response
# 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
Public Instance Methods
success?()
click to toggle source
# File lib/afterpay/payment.rb, line 34 def success? @status == "APPROVED" end