checkout_sdk 0.1.4 → 0.2.0

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: 7591e018711ebd2cdb259c0e30f41d35ebb40fba79eca4417784c57311daa9fe
4
- data.tar.gz: d9e7b078f08c69b592936f17ebf96413deb572140d714da37963043b1b13c58b
3
+ metadata.gz: 1f336f8a32173480906f369d0007b45080387f90e81012b1ca3588648d7ac01d
4
+ data.tar.gz: 6d0d240dbe5b15ec742a7a705d37caa415cbff32e88d2cdf9f7d7cfd90192a1e
5
5
  SHA512:
6
- metadata.gz: b27186569eb0cf3d28280b07a91bca36d8e7320a0d8a0bd5b39cefc5870bfc0b03bf46d63754208a87b1bf2ef3bc454c88b5054a21710de8e609c692023ec810
7
- data.tar.gz: 6fab6f773252974e82e824311359c0997c321054164d3595846fad8bc558f3c4e16d6c2c3d8f92e635e97aa76acbc61c8780d616474c78ec0e714b01f1243279
6
+ metadata.gz: 732900d2a15bf580cc601dabfd0aec31ded3dc13544bf7c66ba9b2379d4d0a87a1674a592bcf169bcf42fc8d6a120d3ee9138c6a5d029edad9136d23e2b52d16
7
+ data.tar.gz: f2267a7bf7d4fa4e12ead080b9cbf30825a00f32b0b5ea0f07d331c2cdefcca613eef5f94a78bc77800e063ad8618144ecaafb26a5ae5f9b715bbe10257d6c8d
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- checkout_sdk (0.1.4)
4
+ checkout_sdk (0.2.0)
5
5
  excon (~> 0.66.0)
6
6
  multi_json (~> 1.0)
7
7
 
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # CheckoutSdk
2
2
 
3
- You are reading documentation for version: 0.1.4
3
+ You are reading documentation for version: 0.2.0
4
4
 
5
5
  ## Installation
6
6
 
@@ -32,6 +32,60 @@ end
32
32
 
33
33
  ## Usage
34
34
 
35
+ #### Source Type: `token`
36
+ A card token can be obtained using one of Checkout.com's JavaScript frontend solutions such as [Frames](https://docs.checkout.com/docs/frames "Frames") or any of the [mobile SDKs](https://docs.checkout.com/docs/sdks#section-mobile-sdk-libraries "Mobile SDKs")
37
+
38
+ ```ruby
39
+ payment_request_source = CheckoutSdk::PaymentRequestSource.new
40
+ payment_request_source.type = "token"
41
+ payment_request_source.token = "tok_..."
42
+ payment_request_source.amount = 2022
43
+ payment_request_source.currency = "GBP"
44
+
45
+ api_resource = CheckoutSdk::ApiResource.new
46
+
47
+ # Send API call
48
+ response = api_resource.request_payment(payment_request_source)
49
+
50
+ # response parsing
51
+ response.data # => {...}
52
+ response.body # => "..."
53
+ response.headers # => {...}
54
+ response.remote_ip # => "..."
55
+ response.status # => 200
56
+ response.remote_ip # => "..."
57
+ response.local_port # => 51601
58
+ response.local_address # => "..."
59
+ ```
60
+
61
+ #### Source Type: `id`
62
+
63
+ ```ruby
64
+ payment_request_source = CheckoutSdk::PaymentRequestSource.new
65
+ payment_request_source.type = "id"
66
+ payment_request_source.token = "src_..."
67
+ payment_request_source.amount = 2022
68
+ payment_request_source.currency = "GBP"
69
+
70
+ api_resource = CheckoutSdk::ApiResource.new
71
+
72
+ # Send API call
73
+ response = api_resource.request_payment(payment_request_source)
74
+
75
+ # response parsing
76
+ response.data # => {...}
77
+ response.body # => "..."
78
+ response.headers # => {...}
79
+ response.remote_ip # => "..."
80
+ response.status # => 200
81
+ response.remote_ip # => "..."
82
+ response.local_port # => 51601
83
+ response.local_address # => "..."
84
+ ```
85
+
86
+
87
+ #### Source Type: `card`
88
+ [Fully PCI Compliant](https://docs.checkout.com/docs/pci-compliance) merchants only
35
89
  ```ruby
36
90
  payment_request_source = CheckoutSdk::PaymentRequestSource.new
37
91
  payment_request_source.type = "card"
@@ -42,23 +96,11 @@ payment_request_source.card_name = "Bruce Wayne"
42
96
  payment_request_source.card_cvv = "100"
43
97
  payment_request_source.amount = 2022
44
98
  payment_request_source.currency = "GBP"
45
- payment_request_source.capture = true
46
- payment_request_source.threeds_enabled = false
47
- payment_request_source.threeds_attempt_n3d = false
48
- payment_request_source.recipient_dob = "1992-04-06"
49
- payment_request_source.recipient_account_number = "1234567890"
50
- payment_request_source.recipient_zip = "12345"
51
- payment_request_source.recipient_last_name = "Elmo"
52
- payment_request_source.risk_enabled = true
53
- payment_request_source.billing_descriptor_name = "Nancy"
54
- payment_request_source.billing_descriptor_city = "Berlin"
55
- payment_request_source.processing_mid = "CheckoutSdk"
56
-
57
99
 
58
100
  api_resource = CheckoutSdk::ApiResource.new
59
101
 
60
102
  # Send API call
61
- response = api_resource.request_payments(payment_request_source)
103
+ response = api_resource.request_payment(payment_request_source)
62
104
 
63
105
  # response parsing
64
106
  response.data # => {...}
@@ -8,7 +8,7 @@ class CheckoutSdk::ApiResource
8
8
  @checkout_connection = Excon.new("#{CheckoutSdk.configuration.base_url}", persistent: true)
9
9
  end
10
10
 
11
- def request_payments(data_object)
11
+ def request_payment(data_object)
12
12
  post_request("/payments", data_object.data)
13
13
  end
14
14
 
@@ -47,17 +47,25 @@ class CheckoutSdk::ApiResource
47
47
  path: path,
48
48
  body: MultiJson.dump(delete_blank(data)),
49
49
  headers: { "Content-Type" => "application/json",
50
- "Authorization" => "#{CheckoutSdk.configuration.secret_key}" }
50
+ "Authorization" => key(path) }
51
51
  )
52
52
  end
53
53
 
54
54
  def get(path)
55
55
  checkout_connection.get(
56
56
  path: path,
57
- headers: { "Authorization" => "#{CheckoutSdk.configuration.secret_key}" }
57
+ headers: { "Authorization" => CheckoutSdk.configuration.secret_key }
58
58
  )
59
59
  end
60
60
 
61
+ def key(path)
62
+ if path == "/tokens"
63
+ CheckoutSdk.configuration.public_key
64
+ else
65
+ CheckoutSdk.configuration.secret_key
66
+ end
67
+ end
68
+
61
69
  def delete_blank(data_hash)
62
70
  data_hash.delete_if do |k, v|
63
71
  (v.respond_to?(:empty?) ? v.empty? : !v) or v.instance_of?(Hash) && delete_blank(v).empty?
@@ -1,3 +1,3 @@
1
1
  module CheckoutSdk
2
- VERSION = "0.1.4"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -7,7 +7,7 @@ RSpec.describe CheckoutSdk::ApiResource do
7
7
  expect(api_resource.checkout_connection.data[:host]).to eql("test.com")
8
8
  end
9
9
 
10
- describe "#request_payments" do
10
+ describe "#request_payment" do
11
11
  let(:payment_request_source) { CheckoutSdk::PaymentRequestSource.new }
12
12
  let(:data) { { mock: true } }
13
13
 
@@ -19,7 +19,7 @@ RSpec.describe CheckoutSdk::ApiResource do
19
19
  headers:{"Authorization"=>"sk_test", "Content-Type"=>"application/json"},
20
20
  path:"/payments" })
21
21
 
22
- api_resource.request_payments(payment_request_source)
22
+ api_resource.request_payment(payment_request_source)
23
23
  end
24
24
  end
25
25
 
@@ -93,7 +93,7 @@ RSpec.describe CheckoutSdk::ApiResource do
93
93
 
94
94
  expect(api_resource.checkout_connection).to receive(:post)
95
95
  .with({ body:"{\"mock\":true}",
96
- headers:{"Authorization"=>"sk_test", "Content-Type"=>"application/json"},
96
+ headers:{"Authorization"=>"pk_test", "Content-Type"=>"application/json"},
97
97
  path:"/tokens" })
98
98
 
99
99
  api_resource.request_token(request_token)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: checkout_sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Khalid Jazaerly
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-10-05 00:00:00.000000000 Z
11
+ date: 2019-10-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler