class GovukPayApiClient::CreatePayment

Attributes

fee[RW]
return_url[RW]

Public Class Methods

new(fee, return_url) click to toggle source
# File lib/govuk_pay_api_client/create_payment.rb, line 6
def initialize(fee, return_url)
  raise RequiresFeeObject if fee.blank?
  raise RequiresReturnUrl if return_url.blank?
  @fee = fee
  @return_url = return_url
end

Public Instance Methods

call() click to toggle source
# File lib/govuk_pay_api_client/create_payment.rb, line 13
def call
  post
  parsed_response
end

Private Instance Methods

endpoint() click to toggle source
# File lib/govuk_pay_api_client/create_payment.rb, line 20
def endpoint
  '/payments'
end
parsed_response() click to toggle source
# File lib/govuk_pay_api_client/create_payment.rb, line 24
def parsed_response
  OpenStruct.new(
    next_url: response_body.fetch(:_links).fetch(:next_url).fetch(:href),
    payment_id: response_body.fetch(:payment_id)
  )
end
request_body() click to toggle source
# File lib/govuk_pay_api_client/create_payment.rb, line 31
def request_body
  {
    return_url: return_url,
    description: fee.description,
    reference: fee.govpay_reference,
    amount: fee.amount
  }
end