smartpay 0.2.3 → 0.2.4

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: 0c6d6af18ab67f641631f6e67525ae39c64286ae716819fa2d96658b0571f83b
4
- data.tar.gz: 64a89a61dd9cfec7fffad3735bea54ad22c5387e2b68bc8caa54148803aea394
3
+ metadata.gz: 6c3f54543398cb0fc174621f0527f86329337fb0bce18911f334b32389358db6
4
+ data.tar.gz: fd7f015bfa49ec0bdf491e34113048098cae02c782abf3b1a8e8bf2df1799387
5
5
  SHA512:
6
- metadata.gz: 7f2ca92bd0867e03a3f2ab3f2c964bfdb1ead71ade148ea753b28aec3ee57aed4d7ab394041620bba30a02055839b214f164e562ed6281e96bf53968a958e6b4
7
- data.tar.gz: 1426c5205f369b614791c2b8277df030f8f693e31b1caf9ac36f8cfef017a95570599ee957c2f615401fb57a6b95f38720d9cdf4296b3cdf8563dc4a5110dde0
6
+ metadata.gz: 72b70c530d31746bc173e6544dec2681413c97f9ebb099afed726366400e2f5a3420bcc44e078ece36debfd8fd858aec05c77f346c994605eb7900e468774d25
7
+ data.tar.gz: ff85cd4be5986f315734e67d312b9f0696c7702ca11cb4a4d6768808c26a4557d23f01851f37fbd9506e178399a02224aacceee7e9e32719f2629cbceb95a109
data/README.md CHANGED
@@ -2,6 +2,11 @@
2
2
 
3
3
  The Smartpay Ruby library offers easy access to Smartpay API from applications written in Ruby.
4
4
 
5
+ ## Documentation
6
+
7
+ - [Payment Flow](https://docs.smartpay.co/#payment_flow)
8
+ - [API Document](https://api-doc.smartpay.co)
9
+
5
10
  ## Requirements
6
11
 
7
12
  - Ruby 2.6+
@@ -33,6 +38,66 @@ source 'https://rubygems.org'
33
38
  gem 'smartpay'
34
39
  ```
35
40
 
41
+ ## Usage
42
+
43
+ The package needs to be configured with your own API keys, you can find them on your [dashboard](https://dashboard.smartpay.co/settings/credentials).
44
+
45
+ ```ruby
46
+ Smartpay.configure do |config|
47
+ config.public_key = '<YOUR_PUBLIC_KEY>' # the one starts with pk_test_
48
+ config.secret_key = '<YOUR_SECRET_KEY>' # the one starts with sk_test_
49
+ end
50
+ ```
51
+
52
+ ### Create Checkout session
53
+
54
+ You can find the description and requirement for request payload in [API Document](https://api-doc.smartpay.co/#8a3538b1-530c-448c-8bae-4a41cdf0b8fd).
55
+
56
+ ```ruby
57
+ payloaad = {
58
+ "customerInfo": {
59
+ "emailAddress": "success@smartpay.co",
60
+ },
61
+ "orderData": {
62
+ "amount": 250,
63
+ "currency": "JPY",
64
+ "shippingInfo": {
65
+ "address": {
66
+ "line1": "line1",
67
+ "locality": "locality",
68
+ "postalCode": "123",
69
+ "country": "JP"
70
+ },
71
+ },
72
+ "lineItemData": [{
73
+ "priceData": {
74
+ "productData": {
75
+ "name": "レブロン 18 LOW",
76
+ },
77
+ "amount": 250,
78
+ "currency": "JPY",
79
+ },
80
+ "quantity": 1
81
+ }]
82
+ },
83
+ "reference": "order_ref_1234567",
84
+ "successUrl": "https://docs.smartpay.co/example-pages/checkout-successful",
85
+ "cancelUrl": "https://docs.smartpay.co/example-pages/checkout-canceled"
86
+ }
87
+ ```
88
+
89
+ Create a checkout session by using `Smartpay::Api.create_checkout_session` with your request payload.
90
+
91
+ ```ruby
92
+ session = Smartpay::Api.create_checkout_session(payload)
93
+ ```
94
+
95
+ Then, you can redirect your customer to the session url by calling `redirect_url`:
96
+
97
+ ```ruby
98
+ session.redirect_url
99
+ ```
100
+
36
101
  ## Use with your favorite frameworks
37
102
 
38
103
  ### Ruby on Rails (RoR)
@@ -64,7 +129,7 @@ bundle exec rails generate smartpay:install
64
129
 
65
130
  This introduces 4 changes for a pre-built Smartpay Checkout example:
66
131
 
67
- > 1. A new initializer - `config/initializers/smartpay.rb`. You will have to update the `config.public_api_key` and `config.private_api_key` with your own credentials to make this work.
132
+ > 1. A new initializer - `config/initializers/smartpay.rb`. You will have to update the `config.public_key` and `config.secret_key` with your own credentials to make this work.
68
133
  > 2. A new controller - `app/controllers/smartpays_controller.rb`. This is where you can see how a Checkout session is configured & created.
69
134
  > 3. A new view - `app/views/smartpays/index.html.erb`. The minimum frontend required.
70
135
  > 4. A new route in config/routes.rb.
@@ -75,8 +140,8 @@ Edit the keys with your own credentials in `config/initializers/smartpay.rb`.
75
140
 
76
141
  ```ruby
77
142
  ...
78
- config.public_api_key = '<YOUR_PUBLIC_API_KEY>' # the one starts with pk_test_
79
- config.private_api_key = '<YOUR_PRIVATE_API_KEY>' # the one starts with sk_test_
143
+ config.public_key = '<YOUR_PUBLIC_KEY>' # the one starts with pk_test_
144
+ config.secret_key = '<YOUR_SECRET_KEY>' # the one starts with sk_test_
80
145
  ...
81
146
  ```
82
147
 
@@ -3,6 +3,6 @@
3
3
  Smartpay.configure do |config|
4
4
  config.api_url = 'https://api.smartpay.co/smartpayments'
5
5
  config.checkout_url = 'https://checkout.smartpay.co'
6
- config.public_api_key = 'pk_test_'
7
- config.private_api_key = 'sk_test_'
6
+ config.public_key = 'pk_test_'
7
+ config.secret_key = 'sk_test_'
8
8
  end
@@ -3,7 +3,7 @@
3
3
  module Smartpay
4
4
  class Configuration
5
5
  attr_accessor :post_timeout
6
- attr_accessor :public_api_key, :private_api_key, :api_url, :checkout_url
6
+ attr_accessor :public_key, :secret_key, :api_url, :checkout_url
7
7
 
8
8
  DEFAULT_TIMEOUT_SETTING = 30
9
9
  DEFAULT_API_URL = 'https://api.smartpay.co'
@@ -10,7 +10,15 @@ module Smartpay
10
10
  end
11
11
 
12
12
  def redirect_url
13
- URI.escape("#{checkout_url}/login?session-id=#{response[:id]}&public-key=#{public_api_key}")
13
+ URI.escape("#{checkout_url}/login?session-id=#{response[:id]}&public-key=#{public_key}")
14
+ end
15
+
16
+ def as_hash
17
+ @response
18
+ end
19
+
20
+ def as_json
21
+ @response.to_json
14
22
  end
15
23
 
16
24
  private
@@ -19,8 +27,8 @@ module Smartpay
19
27
  Smartpay.configuration.checkout_url
20
28
  end
21
29
 
22
- def public_api_key
23
- Smartpay.configuration.public_api_key
30
+ def public_key
31
+ Smartpay.configuration.public_key
24
32
  end
25
33
  end
26
34
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Smartpay
4
- VERSION = "0.2.3"
4
+ VERSION = "0.2.4"
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.3
4
+ version: 0.2.4
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-21 00:00:00.000000000 Z
11
+ date: 2021-10-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client