Class: Vpago::Acleda::Base

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

Direct Known Subclasses

Checkout, DeeplinkCheckout, TransactionStatus

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/acleda/base.rb', line 6

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

Instance Method Details

#acleda_company_nameObject



66
67
68
# File 'lib/vpago/acleda/base.rb', line 66

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

#acleda_payment_cardObject



70
71
72
# File 'lib/vpago/acleda/base.rb', line 70

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

#action_urlObject



106
107
108
# File 'lib/vpago/acleda/base.rb', line 106

def action_url
  "#{host}/#{merchant_name}/paymentPage.jsp"
end

#app_checkoutObject



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

def app_checkout
  app_checkout? ? '1' : '0'
end

#app_checkout?Boolean

Returns:

  • (Boolean)


19
20
21
22
23
# File 'lib/vpago/acleda/base.rb', line 19

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

  @options[:app_checkout]
end

#error_urlObject



42
43
44
45
46
47
48
49
50
51
52
# File 'lib/vpago/acleda/base.rb', line 42

def error_url
  preferred_error_url = @payment.payment_method.preferred_error_url
  return nil if preferred_error_url.blank?

  query_string = {
    app_checkout:,
    order_number:
  }.to_query

  "#{preferred_error_url}?#{query_string}"
end

#expiry_timeObject



94
95
96
# File 'lib/vpago/acleda/base.rb', line 94

def expiry_time
  @payment.payment_method.preferences[:payment_expiry_time_in_mn]
end

#hostObject



25
26
27
# File 'lib/vpago/acleda/base.rb', line 25

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

#login_idObject



74
75
76
# File 'lib/vpago/acleda/base.rb', line 74

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

#merchant_idObject



82
83
84
# File 'lib/vpago/acleda/base.rb', line 82

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

#merchant_nameObject



86
87
88
# File 'lib/vpago/acleda/base.rb', line 86

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

#order_numberObject



102
103
104
# File 'lib/vpago/acleda/base.rb', line 102

def order_number
  @payment.order.number
end

#other_urlObject



54
55
56
57
58
59
60
61
62
63
64
# File 'lib/vpago/acleda/base.rb', line 54

def other_url
  preferred_other_url = @payment.payment_method.preferred_other_url
  return nil if preferred_other_url.blank?

  query_string = {
    app_checkout:,
    order_number:
  }.to_query

  "#{preferred_other_url}?#{query_string}"
end

#passwordObject



78
79
80
# File 'lib/vpago/acleda/base.rb', line 78

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

#payment_numberObject



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

def payment_number
  @payment.number
end

#purchase_dateObject



98
99
100
# File 'lib/vpago/acleda/base.rb', line 98

def purchase_date
  @payment.created_at.strftime('%d-%m-%Y')
end

#signatureObject



90
91
92
# File 'lib/vpago/acleda/base.rb', line 90

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

#success_urlObject



29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/vpago/acleda/base.rb', line 29

def success_url
  preferred_success_url = @payment.payment_method.preferred_success_url
  return nil if preferred_success_url.blank?

  query_string = {
    app_checkout:,
    order_number:,
    order_channel: @payment.order.channel
  }.to_query

  "#{preferred_success_url}?#{query_string}"
end