Skip to content

Commit

Permalink
Merge pull request #85 from internetee/unexpected-token-in-callback
Browse files Browse the repository at this point in the history
turn off token request in oneoff params
  • Loading branch information
vohmar authored Oct 31, 2023
2 parents aa18769 + 9ada8b8 commit 6734147
Showing 1 changed file with 11 additions and 16 deletions.
27 changes: 11 additions & 16 deletions app/services/oneoff.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,14 @@ def self.call(invoice_number:, customer_url:, reference_number:, bulk: false, bu
bulk_invoices: bulk_invoices).call
end

# rubocop:disable Metrics/MethodLength
def call
if @invoice.nil?
if invoice_number.nil?
errors = 'Internal error: called invoice withour number. Please contact to administrator'
else
errors = "Invoice with #{invoice_number} not found in internal system"
end
errors = if invoice_number.nil?
'Internal error: called invoice withour number. Please contact to administrator'
else
"Invoice with #{invoice_number} not found in internal system"
end

return wrap(result: false, instance: nil, errors: errors)
end
Expand All @@ -54,28 +55,22 @@ def base_request
post(direction: 'everypay', path: uri, params: body)
end

# rubocop:disable Metrics/AbcSize
def body
bulk_description = "Ref:#{@invoice.invoice_number}, #{bulk_invoices.join(', ')}"

{
'api_username' => GlobalVariable::API_USERNAME,
'account_name' => GlobalVariable::ACCOUNT_NAME,
'amount' => @invoice.transaction_amount.to_f,
'order_reference' => "#{ bulk ? bulk_description : @invoice.invoice_number }",
'token_agreement' => 'unscheduled',
'order_reference' => bulk ? bulk_description.to_s : @invoice.invoice_number.to_s,
# 'token_agreement' => 'unscheduled',
'request_token' => false,
'nonce' => "#{rand(10 ** 30).to_s.rjust(30,'0')}",
'timestamp' => "#{Time.zone.now.to_formatted_s(:iso8601)}",
# 'email' => Setting.registry_email,
'customer_url' => customer_url,
'preferred_country' => 'EE',
# 'billing_city' => Setting.registry_city,
# 'billing_country' => Setting.registry_country_code,
# 'billing_line1' => Setting.registry_street,
# 'billing_postcode' => Setting.registry_zip,
# 'billing_state' => Setting.registry_state,
'locale' => 'en',
'request_token' => true,
'structured_reference' => reference_number.to_s
}
end
end
end

0 comments on commit 6734147

Please sign in to comment.