Class: Tosspayments2::Rails::CallbackVerifier

Inherits:
Object
  • Object
show all
Defined in:
lib/tosspayments2/rails/callback_verifier.rb

Instance Method Summary collapse

Instance Method Details

#match_amount?(order_id:, amount:, &block) ⇒ Boolean

Returns:

  • (Boolean)

Raises:

  • (ArgumentError)


6
7
8
9
10
11
12
13
14
15
16
# File 'lib/tosspayments2/rails/callback_verifier.rb', line 6

def match_amount?(order_id:, amount:, &block)
  raise ArgumentError, 'block required' unless block

  expected = block.call(order_id)
  unless expected.to_i == amount.to_i
    raise ::Tosspayments2::Rails::VerificationError,
          "Amount mismatch expected=#{expected} got=#{amount}"
  end

  true
end