Class: Vpago::PayoutProfiles::Payway::PayoutProfileRequestParamsBuilder

Inherits:
Object
  • Object
show all
Defined in:
app/services/vpago/payout_profiles/payway/payout_profile_request_params_builder.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(request_time, profile) ⇒ PayoutProfileRequestParamsBuilder

Returns a new instance of PayoutProfileRequestParamsBuilder.



7
8
9
10
# File 'app/services/vpago/payout_profiles/payway/payout_profile_request_params_builder.rb', line 7

def initialize(request_time, profile)
  @request_time = request_time
  @profile = profile
end

Instance Attribute Details

#profileObject (readonly)

Returns the value of attribute profile.



5
6
7
# File 'app/services/vpago/payout_profiles/payway/payout_profile_request_params_builder.rb', line 5

def profile
  @profile
end

#request_timeObject (readonly)

Returns the value of attribute request_time.



5
6
7
# File 'app/services/vpago/payout_profiles/payway/payout_profile_request_params_builder.rb', line 5

def request_time
  @request_time
end

Instance Method Details

#api_keyObject



12
# File 'app/services/vpago/payout_profiles/payway/payout_profile_request_params_builder.rb', line 12

def api_key = profile.preferred_api_key

#encoded_hashObject



41
42
43
44
45
# File 'app/services/vpago/payout_profiles/payway/payout_profile_request_params_builder.rb', line 41

def encoded_hash
  digest_name = OpenSSL::Digest.new('sha512')
  hash = OpenSSL::HMAC.digest(digest_name, api_key, hash_data)
  Base64.strict_encode64(hash)
end

#formatted_request_timeObject



18
19
20
# File 'app/services/vpago/payout_profiles/payway/payout_profile_request_params_builder.rb', line 18

def formatted_request_time
  request_time.strftime('%Y%m%d%H%M%S')
end

#hash_dataObject



37
38
39
# File 'app/services/vpago/payout_profiles/payway/payout_profile_request_params_builder.rb', line 37

def hash_data
  "#{formatted_request_time}#{merchant_auth}"
end

#merchant_authObject



30
31
32
33
34
35
# File 'app/services/vpago/payout_profiles/payway/payout_profile_request_params_builder.rb', line 30

def merchant_auth
  @merchant_auth ||= OpenSslEncrypter.new(
    content: merchant_auth_data,
    rsa_public_key: rsa_public_key
  ).call
end

#merchant_auth_dataObject



22
23
24
25
26
27
28
# File 'app/services/vpago/payout_profiles/payway/payout_profile_request_params_builder.rb', line 22

def merchant_auth_data
  {
    'mc_id' => merchant_id,
    'payee' => payee,
    'status' => status
  }.to_json
end

#merchant_idObject



14
# File 'app/services/vpago/payout_profiles/payway/payout_profile_request_params_builder.rb', line 14

def merchant_id = profile.preferred_merchant_id

#payeeObject



15
# File 'app/services/vpago/payout_profiles/payway/payout_profile_request_params_builder.rb', line 15

def payee = profile.preferred_payee

#request_paramsObject



47
48
49
50
51
52
53
54
# File 'app/services/vpago/payout_profiles/payway/payout_profile_request_params_builder.rb', line 47

def request_params
  {
    request_time: formatted_request_time,
    merchant_id: merchant_id,
    merchant_auth: merchant_auth,
    hash: encoded_hash
  }
end

#rsa_public_keyObject



13
# File 'app/services/vpago/payout_profiles/payway/payout_profile_request_params_builder.rb', line 13

def rsa_public_key = profile.preferred_rsa_public_key

#statusObject



16
# File 'app/services/vpago/payout_profiles/payway/payout_profile_request_params_builder.rb', line 16

def status = profile.active ? '1' : '0'