Class: Vpago::WingSdk::Base

Inherits:
Object
  • Object
show all
Includes:
PaymentAmountCalculator
Defined in:
lib/vpago/wing_sdk/base.rb

Direct Known Subclasses

Checkout, TransactionStatusChecker

Instance Method Summary collapse

Methods included from PaymentAmountCalculator

#amount, #amount_with_fee, #transaction_fee, #transaction_fee_fix, #transaction_fee_percentage

Constructor Details

#initialize(payment, options = {}) ⇒ Base

Returns a new instance of Base.



6
7
8
9
# File 'lib/vpago/wing_sdk/base.rb', line 6

def initialize(payment, options = {})
  @options = options
  @payment = payment
end

Instance Method Details

#action_urlObject



53
54
55
# File 'lib/vpago/wing_sdk/base.rb', line 53

def action_url
  host
end

#app_checkoutObject



39
40
41
# File 'lib/vpago/wing_sdk/base.rb', line 39

def app_checkout
  app_checkout? ? 'yes' : 'no'
end

#app_checkout?Boolean

Returns:

  • (Boolean)


43
44
45
46
47
# File 'lib/vpago/wing_sdk/base.rb', line 43

def app_checkout?
  return false if @options[:app_checkout].blank?

  @options[:app_checkout]
end

#biller_codeObject



19
20
21
# File 'lib/vpago/wing_sdk/base.rb', line 19

def biller_code
  @payment.payment_method.preferences[:biller_code]
end

#hostObject



49
50
51
# File 'lib/vpago/wing_sdk/base.rb', line 49

def host
  @payment.payment_method.preferences[:host]
end

#merchant_nameObject



31
32
33
# File 'lib/vpago/wing_sdk/base.rb', line 31

def merchant_name
  @payment.payment_method.preferences[:merchant_name] || 'VTenh'
end

#payment_numberObject



11
12
13
# File 'lib/vpago/wing_sdk/base.rb', line 11

def payment_number
  @payment.number
end

#rest_api_keyObject



27
28
29
# File 'lib/vpago/wing_sdk/base.rb', line 27

def rest_api_key
  @payment.payment_method.preferences[:rest_api_key]
end

#return_urlObject



35
36
37
# File 'lib/vpago/wing_sdk/base.rb', line 35

def return_url
  "#{ENV.fetch('DEFAULT_URL_HOST', nil)}/webhook/wings/#{payment_number}/return?app_checkout=#{app_checkout}"
end

#sandboxObject



15
16
17
# File 'lib/vpago/wing_sdk/base.rb', line 15

def sandbox
  @payment.payment_method.preferences[:sandbox] ? '1' : '0'
end

#usernameObject



23
24
25
# File 'lib/vpago/wing_sdk/base.rb', line 23

def username
  @payment.payment_method.preferences[:username]
end