Class: JuspayCheckout::ExpressCheckout
- Inherits:
-
Object
- Object
- JuspayCheckout::ExpressCheckout
show all
- Defined in:
- lib/juspay_checkout/express_checkout.rb
Class Method Summary
collapse
Class Method Details
.credential_config ⇒ Object
30
31
32
|
# File 'lib/juspay_checkout/express_checkout.rb', line 30
def credential_config
$juspay_config = ::Rails.application.config_for(:juspay)
end
|
.request(partial_url, http_method, params = {}) ⇒ Object
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
# File 'lib/juspay_checkout/express_checkout.rb', line 4
def request(partial_url, http_method, params = {})
begin
if ::Rails.env == 'production'
base_url = 'https://api.juspay.in'
else
base_url = 'https://sandbox.juspay.in'
end
$juspay_config or credential_config
auth = {username: $juspay_config['api_key'], password: ''}
= {'Accept': 'application/json'}
if http_method == 'get'
response = HTTParty.get(base_url+partial_url, basic_auth: auth, headers: ).to_hash rescue nil
elsif http_method == 'post'
response = HTTParty.post(base_url+partial_url, body: params, basic_auth: auth, headers: ).to_hash rescue nil
end
response
rescue
nil
end
end
|