Class: Iyzipay::IyzipayResource
- Inherits:
-
Object
- Object
- Iyzipay::IyzipayResource
show all
- Defined in:
- lib/iyzipay/iyzipay_resource.rb
Direct Known Subclasses
Model::ApiTest, Model::Approval, Model::BasicBkm, Model::BasicBkmInitialize, Model::BasicPayment, Model::BasicPaymentPostAuth, Model::BasicPaymentPreAuth, Model::BasicThreedsInitialize, Model::BasicThreedsInitializePreAuth, Model::BasicThreedsPayment, Model::BinNumber, Model::Bkm, Model::BkmInitialize, Model::BouncedBankTransferList, Model::Cancel, Model::Card, Model::CardList, Model::CheckoutForm, Model::CheckoutFormInitialize, Model::CheckoutFormInitializePreAuth, Model::CrossBookingFromSubMerchant, Model::CrossBookingToSubMerchant, Model::Disapproval, Model::InstallmentInfo, Model::Payment, Model::PaymentPostAuth, Model::PaymentPreAuth, Model::PayoutCompletedTransactionList, Model::PeccoInitialize, Model::PeccoPayment, Model::Refund, Model::RefundChargedFromMerchant, Model::SubMerchant, Model::ThreedsInitialize, Model::ThreedsInitializePreAuth, Model::ThreedsPayment
Constant Summary
collapse
'Authorization'
- RANDOM_HEADER_NAME =
'x-iyzi-rnd'
'IYZWS %s:%s'
- RANDOM_STRING_SIZE =
8
- RANDOM_CHARS =
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'
Instance Method Summary
collapse
Instance Method Details
#calculate_hash(pki_string, random_header_value, options) ⇒ Object
38
39
40
|
# File 'lib/iyzipay/iyzipay_resource.rb', line 38
def calculate_hash(pki_string, random_header_value, options)
Digest::SHA1.base64digest("#{options.api_key}#{random_header_value}#{options.secret_key}#{pki_string}")
end
|
10
11
12
13
14
15
16
17
18
19
20
21
22
|
# File 'lib/iyzipay/iyzipay_resource.rb', line 10
def (pki_string = nil, options = nil, authorize_request = true)
= {:accept => 'application/json',
:'content-type' => 'application/json'}
if authorize_request
random_header_value = random_string(RANDOM_STRING_SIZE)
[:'Authorization'] = "#{prepare_authorization_string(pki_string, random_header_value, options)}"
[:'x-iyzi-rnd'] = "#{random_header_value}"
[:'x-iyzi-client-version'] = 'iyzipay-ruby-1.0.45'
end
end
|
24
25
26
|
# File 'lib/iyzipay/iyzipay_resource.rb', line 24
def
(nil, false)
end
|
#json_decode(response, raw_result) ⇒ Object
33
34
35
36
|
# File 'lib/iyzipay/iyzipay_resource.rb', line 33
def json_decode(response, raw_result)
json_result = JSON::parse(raw_result)
response.from_json(json_result)
end
|
#prepare_authorization_string(pki_string, random_header_value, options) ⇒ Object
28
29
30
31
|
# File 'lib/iyzipay/iyzipay_resource.rb', line 28
def prepare_authorization_string(pki_string, random_header_value, options)
hash_digest = calculate_hash(pki_string, random_header_value, options)
(options.api_key, hash_digest)
end
|
#random_string(string_length) ⇒ Object
46
47
48
49
50
51
52
|
# File 'lib/iyzipay/iyzipay_resource.rb', line 46
def random_string(string_length)
random_string = ''
string_length.times do
random_string << RANDOM_CHARS.split('').sample
end
random_string
end
|
#to_pki_string(request) ⇒ Object
54
55
56
57
58
|
# File 'lib/iyzipay/iyzipay_resource.rb', line 54
def to_pki_string(request)
PkiBuilder.new.append(:locale, request[:locale]).
append(:conversationId, request[:conversationId]).
get_request_string
end
|