smartpay 0.2.1 → 0.2.5

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: cb4d84133812657ba1e6e6683ea63bc14f9dd421420b0694d3d31aa0098ead74
4
- data.tar.gz: 8b356926abcb9d367eb64e5873859af80791499ab3ed2feb8c688deee487fbf6
3
+ metadata.gz: b85b02e47b248634100a1f5c9cc54aa977ae0306debfa54615f916c17b190d43
4
+ data.tar.gz: b001d7cc034fb87d5f80e2d9fafc202d343fc52a03ec2d13bbc774c0dd980fb4
5
5
  SHA512:
6
- metadata.gz: 32293e37471385b80585a095b8f9ebb828914997746970fb7a02111995bf7d75b09aad59ac2ece4955e36361f36f0d568754491547557d05e2d3fca20be058df
7
- data.tar.gz: e93cda74f1d6fa16a1b4e1b898f8498118cfada872f7ff6f15fb993d444e914d7fa866870e4d0a9c31d199043438c6e6404d2de37ea94e494aafe5b401dbcdd9
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 = '<YOUR_API_SECRET>' # the one starts with sk_test_
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
+ }
@@ -1,5 +1,8 @@
1
1
  <!DOCTYPE html>
2
2
  <html>
3
+ <head>
4
+ <%= stylesheet_link_tag "demo" %>
5
+ </head>
3
6
  <body>
4
7
  <%= form_tag smartpays_path do %>
5
8
  <%= submit_tag 'Checkout' %>
@@ -13,6 +13,14 @@ module Smartpay
13
13
  URI.escape("#{checkout_url}/login?session-id=#{response[:id]}&public-key=#{public_key}")
14
14
  end
15
15
 
16
+ def as_hash
17
+ @response
18
+ end
19
+
20
+ def as_json
21
+ @response.to_json
22
+ end
23
+
16
24
  private
17
25
 
18
26
  def checkout_url
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Smartpay
4
- VERSION = "0.2.1"
4
+ VERSION = "0.2.5"
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.1
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-19 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
@@ -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