smartpay 0.2.12 → 0.2.16

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 86ae2589b7f59311ec99f52daf9396460008814a346545f13cd038205841ed66
4
- data.tar.gz: adc26ad630d2f5286dbf1aeee347a0532ee9eee650c3688286ee4559efcfed75
3
+ metadata.gz: a42e702ac2b0fc1237d6e5aff589bd3cf454aa7bcbddd5ba3843983d0e8e1324
4
+ data.tar.gz: 91a4fdfff9be9e03499605f1899d6cc1f3bdb047303d4500a155cbe528443a2a
5
5
  SHA512:
6
- metadata.gz: a4efcc6b9891f3ea262e9b7721166ec5aa737e8e5b29f9e73ca7df22bff67981948e46477dc052afb6d246ebb5115b330e88729c5ca034ee017907a64c988a33
7
- data.tar.gz: 3075c8c2cfe44f17c9feb649c36b3e845f0bd7d442146b775eff495fbb6f3333466d88cff2f23b44254ece606d7178b39b5a5371d0839fe328f735e0392f35f6
6
+ metadata.gz: 91bcb22eabb064bd0e21ec6c8c08fbd3f339a697e1131ceda8d5c98fb1bce7ccb08470b72399b7bb89964bd63d5cdadc75d40bc114703a5258dab99c76302076
7
+ data.tar.gz: 7aee3ae59b6af7a79f821b73dea25cd4f7865357a61a4ff5bff06fe1cd10329b0de4aca2ce0c2998488d24a517af859404d183d56bf7d6f0b4836cd0ad7c227d
@@ -1,8 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  Smartpay.configure do |config|
4
- config.api_url = 'https://api.smartpay.co/smartpayments'
5
- config.checkout_url = 'https://checkout.smartpay.co'
6
4
  config.public_key = 'pk_test_'
7
5
  config.secret_key = 'sk_test_'
8
6
  end
@@ -6,7 +6,8 @@ module Smartpay
6
6
  class Client
7
7
  class << self
8
8
  def post(path, payload = {})
9
- response = RestClient::Request.execute(method: :post, url: api_url(path), headers: headers, timeout: timeout, payload: payload.to_json)
9
+ request_payload = default_payload.merge(payload)
10
+ response = RestClient::Request.execute(method: :post, url: api_url(path), headers: headers, timeout: timeout, payload: request_payload.to_json)
10
11
  JSON.parse(response.body, symbolize_names: true)
11
12
  end
12
13
 
@@ -31,6 +32,13 @@ module Smartpay
31
32
  def secret_key
32
33
  Smartpay.configuration.secret_key
33
34
  end
35
+
36
+ def default_payload
37
+ {
38
+ 'dev-lang': :ruby,
39
+ 'sdk-version': Smartpay::VERSION
40
+ }.freeze
41
+ end
34
42
  end
35
43
  end
36
44
  end
@@ -11,7 +11,11 @@ module Smartpay
11
11
 
12
12
  def initialize
13
13
  @post_timeout = DEFAULT_TIMEOUT_SETTING
14
- @api_url = DEFAULT_API_URL
14
+ @api_url = if in_development_mode?
15
+ ENV['SMARTPAY_API_PREFIX'] || DEFAULT_API_URL
16
+ else
17
+ DEFAULT_API_URL
18
+ end
15
19
  @checkout_url = DEFAULT_CHECKOUT_URL
16
20
  end
17
21
 
@@ -20,11 +24,23 @@ module Smartpay
20
24
  end
21
25
 
22
26
  def api_url
23
- @api_url || DEFAULT_API_URL
27
+ if in_development_mode?
28
+ @api_url || ENV['SMARTPAY_API_PREFIX'] || DEFAULT_API_URL
29
+ else
30
+ @api_url || DEFAULT_API_URL
31
+ end
24
32
  end
25
33
 
26
34
  def checkout_url
27
35
  @checkout_url || DEFAULT_CHECKOUT_URL
28
36
  end
37
+
38
+ private
39
+
40
+ def in_development_mode?
41
+ if ENV['SMARTPAY_API_PREFIX'].is_a?(String)
42
+ ENV['SMARTPAY_API_PREFIX'].include?('api.smartpay')
43
+ end
44
+ end
29
45
  end
30
46
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Smartpay
4
- VERSION = "0.2.12"
4
+ VERSION = "0.2.16"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smartpay
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.12
4
+ version: 0.2.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Smartpay
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-10-27 00:00:00.000000000 Z
11
+ date: 2021-10-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client