Class: PaymobRuby::PaymentToken

Inherits:
ApplicationService show all
Defined in:
lib/paymob_ruby/api/payment_token.rb

Instance Method Summary collapse

Methods inherited from ApplicationService

call, #failure, #success

Instance Method Details

#call(user:, amount:, integration_id:, commission_fees: 0) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/paymob_ruby/api/payment_token.rb', line 3

def call(user:, amount:, integration_id:, commission_fees: 0)
  @login_token     = PaymobRuby::Login.call.payload
  @user            = user
  @amount          = amount.round
  @integration_id  = integration_id
  @commission_fees = commission_fees

  user_valid?
  sanity_checks!

  # Paymob order id
  @order_id = order_response["id"]

  success({ payment_token: payment_key_response["token"], order_id: @order_id })
end