smartpay 0.2.9 → 0.2.13

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: f4ad1df668d2bd7e5fd058fca13f0e77c6771fcaf21a9c4efca53ccc1648b4cc
4
- data.tar.gz: 1d3da6d89ecf92bc464f96ac80bff4fc2d71477d33a2f5806bec54943b548cac
3
+ metadata.gz: a93499d26437ed9bcbddd74143329b00aaed999b2bb7616522d9df800399b4e4
4
+ data.tar.gz: c57ef079d70823f37deec9861ea9296b2b91ca388eef6922532f6b9429be0d75
5
5
  SHA512:
6
- metadata.gz: 5e443965545a854944668db53c27461af096c775827b500a11cf50ccea801398fa457c192d0365ab7aa654d881318cd365b8814536142393e55a50d552fbd457
7
- data.tar.gz: 9a9664306337a7bc9960ca4606a3f35c110556d952a6d33beff736b2af742113856ec7ebf8a60dfc57abf4afa31173972673facb3ec47f7ad4211e440caebd1f
6
+ metadata.gz: f00cf5883edfae53b67da79a467dd2548c2c13c95ff86a471276151d2180e9e691471143b6f646e578a87933d94fc3e922a5552c9472164019ba9c811a5b44d4
7
+ data.tar.gz: 04b5476f14c7a0f5aeacf2f9f41718cf535537a73782e04d9446ec0b137da1329bf4e3e109c90d3b445ad33c917d4e9d2ad7ba73e0c20d7d4a87dbfecd58d079
data/lib/smartpay/api.rb CHANGED
@@ -5,7 +5,7 @@ module Smartpay
5
5
  class << self
6
6
  def create_checkout_session(payload)
7
7
  Responses::CheckoutSession.new(
8
- Client.post('/checkout/sessions', Requests::CheckoutSession.new(payload).as_hash)
8
+ Client.post('/checkout-sessions', Requests::CheckoutSession.new(payload).as_hash)
9
9
  )
10
10
  end
11
11
  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
@@ -2,11 +2,11 @@
2
2
 
3
3
  module Smartpay
4
4
  class Configuration
5
- attr_accessor :post_timeout
6
- attr_accessor :public_key, :secret_key, :api_url, :checkout_url
5
+ attr_accessor :public_key, :secret_key
6
+ attr_writer :post_timeout, :api_url, :checkout_url
7
7
 
8
8
  DEFAULT_TIMEOUT_SETTING = 30
9
- DEFAULT_API_URL = 'https://api.smartpay.co'
9
+ DEFAULT_API_URL = 'https://api.smartpay.co/v1'
10
10
  DEFAULT_CHECKOUT_URL = 'https://checkout.smartpay.co'
11
11
 
12
12
  def initialize
@@ -14,5 +14,17 @@ module Smartpay
14
14
  @api_url = DEFAULT_API_URL
15
15
  @checkout_url = DEFAULT_CHECKOUT_URL
16
16
  end
17
+
18
+ def post_timeout
19
+ @post_timeout || DEFAULT_TIMEOUT_SETTING
20
+ end
21
+
22
+ def api_url
23
+ @api_url || DEFAULT_API_URL
24
+ end
25
+
26
+ def checkout_url
27
+ @checkout_url || DEFAULT_CHECKOUT_URL
28
+ end
17
29
  end
18
30
  end
@@ -71,6 +71,7 @@ module Smartpay
71
71
 
72
72
  def normalize_shipping(shipping)
73
73
  return if shipping.nil?
74
+ shipping= shipping.transform_keys(&:to_sym)
74
75
  {
75
76
  address: shipping.dig(:address) || {
76
77
  line1: shipping.dig(:line1),
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Smartpay
4
- VERSION = "0.2.9"
4
+ VERSION = "0.2.13"
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.9
4
+ version: 0.2.13
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-26 00:00:00.000000000 Z
11
+ date: 2021-10-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client