class PaymentsApi::Responses::PaymentResult
Constants
- FIELDS
- SUCCESS_STATUS
Public Class Methods
new(response)
click to toggle source
Instantiate a payment result
@note Not all properties returned by the API will be mapped to instance
attributes in this class, but most common are included
@param response [Hash] The API response for the operation, currently
create a payment, or get details of an existing payment by ID
@return [PaymentsApi::Responses::PaymentResult] instance
@see govukpay-api-browser.cloudapps.digital/#tocscreatepaymentresult @see govukpay-api-browser.cloudapps.digital/#tocsgetpaymentresult
# File lib/payments_api/responses/payment_result.rb, line 39 def initialize(response) FIELDS.each do |field| instance_variable_set(:"@#{field}", response.fetch(field, nil)) end end
Public Instance Methods
finished?()
click to toggle source
# File lib/payments_api/responses/payment_result.rb, line 54 def finished? !!state.dig('finished') end
payment_url()
click to toggle source
URL where to redirect the user to capture their payment details
# File lib/payments_api/responses/payment_result.rb, line 46 def payment_url _links.dig('next_url', 'href') end
status()
click to toggle source
# File lib/payments_api/responses/payment_result.rb, line 50 def status state.dig('status') end
success?()
click to toggle source
# File lib/payments_api/responses/payment_result.rb, line 58 def success? status.eql?(SUCCESS_STATUS) end