smartpay 0.1.0 → 0.2.0
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 +34 -6
- data/lib/generators/smartpay/install_generator.rb +17 -0
- data/lib/generators/smartpay/templates/controller.rb +68 -0
- data/lib/generators/smartpay/templates/initializer.rb +8 -0
- data/lib/generators/smartpay/templates/views/index.html.erb +8 -0
- data/lib/smartpay/client.rb +2 -0
- data/lib/smartpay/version.rb +1 -1
- metadata +10 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 574ea8c0a8437a946bebba2924965c3a5c62ee8c4ccc990a3222491ccebb30ee
|
4
|
+
data.tar.gz: fb334df6541a5869c2ad7df5250f69f7c7593e6b5f804fdcbb3d878298a82cbd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9778570f0c65d94e1f5006ce19254ceef5cfc369f5b654579b091777048ce20c6ba317c0e9fa307de9d8a46dd4feda0ed774d2ce401786c059375d93f3b9e054
|
7
|
+
data.tar.gz: a8aca7526235571495966f9f68dbc7dfe4693cf56d832c5a01543993fd88cce0c19af0a14a0137e7c42d6287485bb6c200c8cc3596984eaa6798bdf592be3ab6
|
data/README.md
CHANGED
@@ -6,23 +6,51 @@ TODO: Delete this and the text above, and describe your gem
|
|
6
6
|
|
7
7
|
## Installation
|
8
8
|
|
9
|
-
Add
|
9
|
+
Add the latest version of Smartpay to your project's dependencies:
|
10
|
+
|
11
|
+
$ bundle add smartpay
|
12
|
+
|
13
|
+
Or, you can add this line to your application's Gemfile and specify the version restriction:
|
10
14
|
|
11
15
|
```ruby
|
12
|
-
gem 'smartpay'
|
16
|
+
gem 'smartpay', "~> 0.1.0"
|
13
17
|
```
|
14
18
|
|
15
19
|
And then execute:
|
16
20
|
|
17
21
|
$ bundle install
|
18
22
|
|
19
|
-
|
23
|
+
## Usage for Ruby on Rails
|
24
|
+
|
25
|
+
After installed the gem package, you can generate relevant files with:
|
26
|
+
|
27
|
+
$ bundle exec rails generate smartpay:install
|
28
|
+
|
29
|
+
This will introduce 4 changes, including a simple example for checkout session flow:
|
30
|
+
|
31
|
+
1. Add new initializer in `config/initializers/smartpay.rb`
|
32
|
+
2. Add controller to `app/controllers/smartpays_controller.rb`
|
33
|
+
3. Add view to `app/views/smartpays/index.html.erb`
|
34
|
+
4. Add routes to `config/routes.rb` for checkout session
|
35
|
+
|
36
|
+
### Setup Server Credentials
|
37
|
+
|
38
|
+
Make sure you have the credentials (API key & secret) from Smartpay before you can have a working integration.
|
39
|
+
You can find your credentials at the `settings > credentials` page on your [dashboard](https://merchant.smartpay.co/settings/credentials).
|
40
|
+
|
41
|
+
Update your API key and secret to the fields `public_key` and `api_secret` in `config/initializers/smartpay.rb`.
|
42
|
+
|
43
|
+
### Test with Checkout Session
|
44
|
+
|
45
|
+
Start your server and navigate to `http://localhost:3000/smartpays`.
|
20
46
|
|
21
|
-
|
47
|
+
Click the `checkout` button to be redirected to the Checkout page.
|
22
48
|
|
23
|
-
|
49
|
+
Replace any of these test accounts to the field `customerInfo.emailAddress` of request payload in `app/controllers/smartpays_controller.rb` to simulate a payment.
|
24
50
|
|
25
|
-
|
51
|
+
1. Payment succeeds: `success@smartpay.co`
|
52
|
+
2. Payment requires authentication: `auth.required@smartpay.co`
|
53
|
+
3. Payment is declined: `declined@smartpay.co`
|
26
54
|
|
27
55
|
## Development
|
28
56
|
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "rails/generators"
|
4
|
+
|
5
|
+
module Smartpay
|
6
|
+
class InstallGenerator < Rails::Generators::Base
|
7
|
+
source_root File.expand_path("templates", __dir__)
|
8
|
+
|
9
|
+
def install
|
10
|
+
template "initializer.rb", "config/initializers/smartpay.rb"
|
11
|
+
template "controller.rb", "app/controllers/smartpays_controller.rb"
|
12
|
+
directory "views", "app/views/smartpays"
|
13
|
+
|
14
|
+
route "resources :smartpays, only: [:index, :create]"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
class SmartpaysController < ApplicationController
|
2
|
+
def new
|
3
|
+
end
|
4
|
+
|
5
|
+
def create
|
6
|
+
session = Smartpay::Api.create_checkout_session(
|
7
|
+
{
|
8
|
+
"customerInfo": {
|
9
|
+
"emailAddress": "success@smartpay.co",
|
10
|
+
"firstName": nil,
|
11
|
+
"lastName": nil,
|
12
|
+
"firstNameKana": nil,
|
13
|
+
"lastNameKana": nil,
|
14
|
+
"address": nil,
|
15
|
+
"phoneNumber": nil,
|
16
|
+
"dateOfBirth": nil,
|
17
|
+
"legalGender": nil,
|
18
|
+
"reference": nil
|
19
|
+
},
|
20
|
+
"orderData": {
|
21
|
+
"amount": 250,
|
22
|
+
"currency": "JPY",
|
23
|
+
"captureMethod": nil,
|
24
|
+
"confirmationMethod": nil,
|
25
|
+
"coupons": nil,
|
26
|
+
"shippingInfo": {
|
27
|
+
"address": {
|
28
|
+
"line1": "line1",
|
29
|
+
"line2": nil,
|
30
|
+
"line3": nil,
|
31
|
+
"line4": nil,
|
32
|
+
"line5": nil,
|
33
|
+
"subLocality": nil,
|
34
|
+
"locality": "locality",
|
35
|
+
"administrativeArea": nil,
|
36
|
+
"postalCode": "123",
|
37
|
+
"country": "JP"},
|
38
|
+
"addressType": nil},
|
39
|
+
"lineItemData": [{
|
40
|
+
"price": nil,
|
41
|
+
"priceData": {
|
42
|
+
"productData": {
|
43
|
+
"name": "レブロン 18 LOW",
|
44
|
+
"brand": nil,
|
45
|
+
"categories": nil,
|
46
|
+
"description": nil,
|
47
|
+
"gtin": nil,
|
48
|
+
"images": nil,
|
49
|
+
"reference": nil,
|
50
|
+
"url": nil,
|
51
|
+
"metadata": nil},
|
52
|
+
"amount": 250,
|
53
|
+
"currency": "JPY",
|
54
|
+
"metadata": nil},
|
55
|
+
"quantity": 1,
|
56
|
+
"description": nil,
|
57
|
+
"metadata": nil
|
58
|
+
}]
|
59
|
+
},
|
60
|
+
"reference": "order_ref_1234567",
|
61
|
+
"metadata": nil,
|
62
|
+
"successUrl": "https://docs.smartpay.co/example-pages/checkout-successful",
|
63
|
+
"cancelUrl": "https://docs.smartpay.co/example-pages/checkout-canceled",
|
64
|
+
"test": true
|
65
|
+
})
|
66
|
+
redirect_to session.redirect_url
|
67
|
+
end
|
68
|
+
end
|
data/lib/smartpay/client.rb
CHANGED
data/lib/smartpay/version.rb
CHANGED
metadata
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: smartpay
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Smartpay
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
date: 2021-10-18 00:00:00.000000000 Z
|
@@ -38,7 +38,7 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '3.0'
|
41
|
-
description:
|
41
|
+
description:
|
42
42
|
email:
|
43
43
|
- uxe@smartpay.co
|
44
44
|
executables: []
|
@@ -55,6 +55,10 @@ files:
|
|
55
55
|
- Rakefile
|
56
56
|
- bin/console
|
57
57
|
- bin/setup
|
58
|
+
- lib/generators/smartpay/install_generator.rb
|
59
|
+
- lib/generators/smartpay/templates/controller.rb
|
60
|
+
- lib/generators/smartpay/templates/initializer.rb
|
61
|
+
- lib/generators/smartpay/templates/views/index.html.erb
|
58
62
|
- lib/smartpay.rb
|
59
63
|
- lib/smartpay/api.rb
|
60
64
|
- lib/smartpay/client.rb
|
@@ -68,7 +72,7 @@ metadata:
|
|
68
72
|
homepage_uri: https://smartpay.co
|
69
73
|
source_code_uri: https://github.com/smartpay-co/sdk-ruby
|
70
74
|
changelog_uri: https://github.com/smartpay-co/sdk-ruby/blob/main/CHANGELOG.md
|
71
|
-
post_install_message:
|
75
|
+
post_install_message:
|
72
76
|
rdoc_options: []
|
73
77
|
require_paths:
|
74
78
|
- lib
|
@@ -83,8 +87,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
83
87
|
- !ruby/object:Gem::Version
|
84
88
|
version: '0'
|
85
89
|
requirements: []
|
86
|
-
rubygems_version: 3.0.
|
87
|
-
signing_key:
|
90
|
+
rubygems_version: 3.0.9
|
91
|
+
signing_key:
|
88
92
|
specification_version: 4
|
89
93
|
summary: The Smartpay Ruby SDK offers easy access to Smartpay API from applications
|
90
94
|
written in Ruby.
|