class Afterpay::Utils::Money

Public Class Methods

api_hash(money) click to toggle source

Converts <oney to API compatible hash format

# File lib/afterpay/utils/money.rb, line 18
def self.api_hash(money)
  {
    amount: money.dollars.to_f,
    currency: money.currency.iso_code
  }
end
from_response(response) click to toggle source

Converts Afterpay response to `Money` @return [Money]

# File lib/afterpay/utils/money.rb, line 8
def self.from_response(response)
  return nil if response.nil?

  ::Money.from_amount(
    response[:amount].to_f,
    response[:currency]
  )
end