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::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
37
38
39
|
# File 'lib/iyzipay/iyzipay_resource.rb', line 37
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
|
# 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}"
end
end
|
23
24
25
|
# File 'lib/iyzipay/iyzipay_resource.rb', line 23
def
(nil, false)
end
|
#json_decode(response, raw_result) ⇒ Object
32
33
34
35
|
# File 'lib/iyzipay/iyzipay_resource.rb', line 32
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
27
28
29
30
|
# File 'lib/iyzipay/iyzipay_resource.rb', line 27
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
45
46
47
48
49
50
51
|
# File 'lib/iyzipay/iyzipay_resource.rb', line 45
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
53
54
55
56
57
|
# File 'lib/iyzipay/iyzipay_resource.rb', line 53
def to_pki_string(request)
PkiBuilder.new.append(:locale, request[:locale]).
append(:conversationId, request[:conversationId]).
get_request_string
end
|