smartpay 0.2.1 → 0.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +66 -1
- data/lib/generators/smartpay/install_generator.rb +1 -0
- data/lib/generators/smartpay/templates/assets/stylesheets/demo.css +18 -0
- data/lib/generators/smartpay/templates/views/index.html.erb +3 -0
- data/lib/smartpay/responses/checkout_session.rb +8 -0
- data/lib/smartpay/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b85b02e47b248634100a1f5c9cc54aa977ae0306debfa54615f916c17b190d43
|
4
|
+
data.tar.gz: b001d7cc034fb87d5f80e2d9fafc202d343fc52a03ec2d13bbc774c0dd980fb4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fc3a2b1c0d41558e07cd4298119446f5fada619c0625e66278437c503c7980d353d1eee2e0948bf3be036e33facbff391354705c11068f3a13dfd226873a1e11
|
7
|
+
data.tar.gz: c5ae98b31fb8c102bf9ace17467569fba7642f121d00ca2aac64ca9f28cfdca26988c063713fbd43a9aab63914cd9bb3e7107c321589f225ecb0ac7f7ee4bef5
|
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)
|
@@ -76,7 +141,7 @@ Edit the keys with your own credentials in `config/initializers/smartpay.rb`.
|
|
76
141
|
```ruby
|
77
142
|
...
|
78
143
|
config.public_key = '<YOUR_PUBLIC_KEY>' # the one starts with pk_test_
|
79
|
-
config.secret_key = '<
|
144
|
+
config.secret_key = '<YOUR_SECRET_KEY>' # the one starts with sk_test_
|
80
145
|
...
|
81
146
|
```
|
82
147
|
|
@@ -9,6 +9,7 @@ module Smartpay
|
|
9
9
|
def install
|
10
10
|
template "initializer.rb", "config/initializers/smartpay.rb"
|
11
11
|
template "controller.rb", "app/controllers/smartpays_controller.rb"
|
12
|
+
template "assets/stylesheets/demo.css", "app/assets/stylesheets/demo.css"
|
12
13
|
directory "views", "app/views/smartpays"
|
13
14
|
|
14
15
|
route "resources :smartpays, only: [:index, :create]"
|
@@ -0,0 +1,18 @@
|
|
1
|
+
input[type="submit"] {
|
2
|
+
padding: 0 40px;
|
3
|
+
font: 500 16px/48px Helvetica, sans-serif;
|
4
|
+
appearance: none;
|
5
|
+
position: absolute;
|
6
|
+
left: 50%;
|
7
|
+
top: 50%;
|
8
|
+
transform: translate(-50%, -50%);
|
9
|
+
border: 0;
|
10
|
+
color: #fff;
|
11
|
+
background: #4456dd;
|
12
|
+
border-radius: 6px;
|
13
|
+
cursor: pointer;
|
14
|
+
}
|
15
|
+
|
16
|
+
input[type="submit"]:hover {
|
17
|
+
background: #3445c1;
|
18
|
+
}
|
data/lib/smartpay/version.rb
CHANGED
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.
|
4
|
+
version: 0.2.5
|
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-
|
11
|
+
date: 2021-10-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|
@@ -56,6 +56,7 @@ files:
|
|
56
56
|
- bin/console
|
57
57
|
- bin/setup
|
58
58
|
- lib/generators/smartpay/install_generator.rb
|
59
|
+
- lib/generators/smartpay/templates/assets/stylesheets/demo.css
|
59
60
|
- lib/generators/smartpay/templates/controller.rb
|
60
61
|
- lib/generators/smartpay/templates/initializer.rb
|
61
62
|
- lib/generators/smartpay/templates/views/index.html.erb
|