smartpay 0.1.0 → 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: 38d6c56f2c6abb2cf337532c6e3d10943111aed67b585d62c5fb6bdc1ab26198
4
- data.tar.gz: 8f67b047ab3bfb8cc28c503657ea3f02bb83f6cab0fd25ce04ca9eab90853bb2
3
+ metadata.gz: 574ea8c0a8437a946bebba2924965c3a5c62ee8c4ccc990a3222491ccebb30ee
4
+ data.tar.gz: fb334df6541a5869c2ad7df5250f69f7c7593e6b5f804fdcbb3d878298a82cbd
5
5
  SHA512:
6
- metadata.gz: 87a360308fd0f6d5b5ec8cb73c28f611c03ae465ccb16bd5fc53d989812e95b84e1873890fa011fd27adde18d3f953c1974a26499f4b5beae36b4c79db6aa25b
7
- data.tar.gz: 020bc848c1ddb5bfe842bac6e78b622cde388fcd33de9719f5e877a2583e2b47aaa733c0e626d7aa7a8e41c35d7fc945feef9b1c02bd95eadc217211c7cd96ea
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 this line to your application's Gemfile:
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
- Or install it yourself as:
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
- $ gem install smartpay
47
+ Click the `checkout` button to be redirected to the Checkout page.
22
48
 
23
- ## Usage
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
- TODO: Write usage instructions here
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
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ Smartpay.configure do |config|
4
+ config.api_url = 'https://api.smartpay.re/smartpayments'
5
+ config.checkout_url = 'https://checkout.smartpay.re'
6
+ config.public_key = 'pk_test_'
7
+ config.api_secret = 'sk_test_'
8
+ end
@@ -0,0 +1,8 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <body>
4
+ <%= form_tag smartpays_path do %>
5
+ <%= submit_tag 'Checkout' %>
6
+ <% end %>
7
+ </body>
8
+ </html>
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'rest-client'
4
+
3
5
  module Smartpay
4
6
  class Client
5
7
  class << self
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Smartpay
4
- VERSION = "0.1.0"
4
+ VERSION = "0.2.0"
5
5
  end
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.1.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.3
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.