Class: Iyzipay::IyzipayResourceV2
- Inherits:
-
IyzipayResource
- Object
- IyzipayResource
- Iyzipay::IyzipayResourceV2
- Defined in:
- lib/iyzipay/iyzipay_resource_v2.rb
Direct Known Subclasses
Model::V2::CheckoutForm, Model::V2::CheckoutFormInitialize, Model::V2::Plan, Model::V2::Product, Model::V2::Subscription, Model::V2::SubscriptionInitialize
Constant Summary collapse
- AUTHORIZATION_HEADER_STRING =
'IYZWSv2'
Constants inherited from IyzipayResource
Iyzipay::IyzipayResource::AUTHORIZATION_HEADER_NAME, Iyzipay::IyzipayResource::RANDOM_CHARS, Iyzipay::IyzipayResource::RANDOM_HEADER_NAME, Iyzipay::IyzipayResource::RANDOM_STRING_SIZE
Instance Method Summary collapse
- #calculate_hash(pki_string, random_header_value, options, uri) ⇒ Object
- #get_http_header(options, uri, pki_string = nil, authorize_request = true) ⇒ Object
- #prepare_authorization_string(pki_string, random_header_value, options, uri) ⇒ Object
Methods inherited from IyzipayResource
#format_header_string, #get_plain_http_header, #json_decode, #random_string, #to_pki_string
Instance Method Details
#calculate_hash(pki_string, random_header_value, options, uri) ⇒ Object
28 29 30 31 32 33 34 35 36 37 |
# File 'lib/iyzipay/iyzipay_resource_v2.rb', line 28 def calculate_hash(pki_string, random_header_value, , uri) data = "#{random_header_value}#{uri}#{pki_string}" signature = OpenSSL::HMAC.hexdigest('SHA256', .secret_key, data) = [ 'apiKey:' + .api_key, 'randomKey:' + random_header_value, 'signature:' + signature ] Base64.strict_encode64(.join('&')) end |
#get_http_header(options, uri, pki_string = nil, authorize_request = true) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/iyzipay/iyzipay_resource_v2.rb', line 7 def get_http_header(, uri, pki_string = nil, = true) header = { accept: 'application/json', 'content-type': 'application/json' } if random_header_value = random_string(RANDOM_STRING_SIZE) = (pki_string, random_header_value, , uri).to_s header[:Authorization] = header[:'x-iyzi-rnd'] = random_header_value.to_s header[:'x-iyzi-client-version'] = 'iyzipay-ruby-1.0.45' end header end |
#prepare_authorization_string(pki_string, random_header_value, options, uri) ⇒ Object
23 24 25 26 |
# File 'lib/iyzipay/iyzipay_resource_v2.rb', line 23 def (pki_string, random_header_value, , uri) hash_digest = calculate_hash(pki_string, random_header_value, , uri) "#{AUTHORIZATION_HEADER_STRING} #{hash_digest}" end |