Class: Vpago::PaywayV2::PreAuthCanceler

Inherits:
PreAuthCompleter show all
Defined in:
lib/vpago/payway_v2/pre_auth_canceler.rb

Instance Method Summary collapse

Methods inherited from PreAuthCompleter

#call, #cancelled?, #complete_url, #completed?, #json_response, #merchant_auth_encryption, #save_response, #success?

Methods inherited from Base

#amount, #api_key, #continue_success_url, #email, #first_name, #hash_hmac, #host, #initialize, #last_name, #merchant_id, #order_jwt_token, #payment_option, #payout, #phone, #public_key, #req_time, #return_deeplink, #return_deeplink_url, #return_params, #return_url, #transaction_fee, #transaction_fee_fix, #transaction_fee_percentage, #transaction_id, #type, #view_type

Constructor Details

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

Instance Method Details

#cancel_urlObject



38
39
40
# File 'lib/vpago/payway_v2/pre_auth_canceler.rb', line 38

def cancel_url
  "#{host}#{ENV.fetch('PAYWAY_V2_PRE_AUTH_CANCEL_PATH')}"
end

#hash_dataObject

override



25
26
27
28
# File 'lib/vpago/payway_v2/pre_auth_canceler.rb', line 25

def hash_data
  data = "#{merchant_id}#{merchant_auth_encryption}#{req_time}"
  Base64.strict_encode64(OpenSSL::HMAC.digest(OpenSSL::Digest.new('sha512'), api_key, data))
end

#merchant_authObject

override



31
32
33
34
35
36
# File 'lib/vpago/payway_v2/pre_auth_canceler.rb', line 31

def merchant_auth
  {
    'mc_id' => merchant_id,
    'tran_id' => transaction_id
  }.to_json
end

#pre_auth_responseObject

override



7
8
9
10
11
12
13
# File 'lib/vpago/payway_v2/pre_auth_canceler.rb', line 7

def pre_auth_response
  conn = Faraday::Connection.new do |faraday|
    faraday.request :url_encoded
  end

  conn.post(cancel_url, request_data)
end

#request_dataObject



15
16
17
18
19
20
21
22
# File 'lib/vpago/payway_v2/pre_auth_canceler.rb', line 15

def request_data
  {
    request_time: req_time,
    merchant_id: merchant_id,
    merchant_auth: merchant_auth_encryption,
    hash: hash_data
  }
end