Class: Vpago::VattanacMiniApp::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/vpago/vattanac_mini_app/base.rb

Direct Known Subclasses

Checkout, RefundIssuer

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of Base.



4
5
6
7
# File 'lib/vpago/vattanac_mini_app/base.rb', line 4

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

Instance Method Details

#amountObject



22
23
24
# File 'lib/vpago/vattanac_mini_app/base.rb', line 22

def amount
  @payment.amount
end

#currencyObject



30
31
32
# File 'lib/vpago/vattanac_mini_app/base.rb', line 30

def currency
  'USD'
end

#encrypt_data(payload) ⇒ Object



18
19
20
# File 'lib/vpago/vattanac_mini_app/base.rb', line 18

def encrypt_data(payload)
  SpreeCmCommissioner::AesEncryptionService.encrypt(payload.to_json, aes_key)
end

#expired_atObject



38
39
40
# File 'lib/vpago/vattanac_mini_app/base.rb', line 38

def expired_at
  (Time.now + 30.minutes).to_i * 1000
end

#partner_codeObject



42
43
44
# File 'lib/vpago/vattanac_mini_app/base.rb', line 42

def partner_code
  @payment.payment_method.preferred_partner_code
end

#payloadObject



9
10
11
12
13
14
15
16
# File 'lib/vpago/vattanac_mini_app/base.rb', line 9

def payload
  {
    paymentId: payment_id,
    amount: amount,
    currency: currency || 'USD',
    expiredIn: expired_at
  }
end

#payment_idObject



26
27
28
# File 'lib/vpago/vattanac_mini_app/base.rb', line 26

def payment_id
  @payment.number
end

#refund_urlObject



46
47
48
# File 'lib/vpago/vattanac_mini_app/base.rb', line 46

def refund_url
  @payment.payment_method.preferred_refund_url
end

#transaction_idObject



34
35
36
# File 'lib/vpago/vattanac_mini_app/base.rb', line 34

def transaction_id
  @payment.number
end