Class: Vpago::Vattanac::Checkout

Inherits:
Base
  • Object
show all
Defined in:
lib/vpago/vattanac/checkout.rb

Constant Summary

Constants inherited from Base

Base::CONTENT_TYPE_JSON

Instance Method Summary collapse

Methods inherited from Base

#access_token, #access_token_url, #amount, #check_transaction_url, #currency, #default_headers, #generate_payment_url, #initialize, #merchant_id, #parse_json, #password, #payment_method, #payment_number, #payment_type, #username

Constructor Details

This class inherits a constructor from Vpago::Vattanac::Base

Instance Method Details

#createObject



16
17
18
19
20
21
22
23
24
# File 'lib/vpago/vattanac/checkout.rb', line 16

def create
  response_data = post(generate_payment_url, payload)['data']
  {
    web_url: response_data['webPaymentUrl'],
    deeplink_url: response_data['mobileDeepLink'],
    expires_at: response_data['expiredIn'],
    generated_at: response_data['generatedAt']
  }
end

#payloadObject



4
5
6
7
8
9
10
11
12
13
14
# File 'lib/vpago/vattanac/checkout.rb', line 4

def payload
  {
    transactionId: payment_number,
    requestId: "req-#{SecureRandom.hex(8)}",
    paymentType: payment_type,
    amount: amount,
    currency: currency,
    merchantId: merchant_id,
    returnUrl: @payment.processing_url
  }
end