smartpay 0.2.0 → 0.2.1

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: 574ea8c0a8437a946bebba2924965c3a5c62ee8c4ccc990a3222491ccebb30ee
4
- data.tar.gz: fb334df6541a5869c2ad7df5250f69f7c7593e6b5f804fdcbb3d878298a82cbd
3
+ metadata.gz: cb4d84133812657ba1e6e6683ea63bc14f9dd421420b0694d3d31aa0098ead74
4
+ data.tar.gz: 8b356926abcb9d367eb64e5873859af80791499ab3ed2feb8c688deee487fbf6
5
5
  SHA512:
6
- metadata.gz: 9778570f0c65d94e1f5006ce19254ceef5cfc369f5b654579b091777048ce20c6ba317c0e9fa307de9d8a46dd4feda0ed774d2ce401786c059375d93f3b9e054
7
- data.tar.gz: a8aca7526235571495966f9f68dbc7dfe4693cf56d832c5a01543993fd88cce0c19af0a14a0137e7c42d6287485bb6c200c8cc3596984eaa6798bdf592be3ab6
6
+ metadata.gz: 32293e37471385b80585a095b8f9ebb828914997746970fb7a02111995bf7d75b09aad59ac2ece4955e36361f36f0d568754491547557d05e2d3fca20be058df
7
+ data.tar.gz: e93cda74f1d6fa16a1b4e1b898f8498118cfada872f7ff6f15fb993d444e914d7fa866870e4d0a9c31d199043438c6e6404d2de37ea94e494aafe5b401dbcdd9
data/README.md CHANGED
@@ -1,56 +1,101 @@
1
- # Smartpay
1
+ # Smartpay Ruby Library
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/smartpay`. To experiment with that code, run `bin/console` for an interactive prompt.
3
+ The Smartpay Ruby library offers easy access to Smartpay API from applications written in Ruby.
4
4
 
5
- TODO: Delete this and the text above, and describe your gem
5
+ ## Requirements
6
+
7
+ - Ruby 2.6+
8
+ - Smartpay `API keys & secrets`. You can find your credential at the `settings > credentials` page on your [dashboard](https://dashboard.smartpay.co/settings/credentials).
6
9
 
7
10
  ## Installation
8
11
 
9
- Add the latest version of Smartpay to your project's dependencies:
12
+ If you use system built-in Ruby, you might need to be the `sudoer` to be able to `sudo` in some of the following steps. We recommend you to use either [rbenv](https://github.com/rbenv/rbenv) or [rvm](https://rvm.io/) to have your own non-global Ruby to avoid potential permission issues.
13
+
14
+ Once you have your Ruby in place, add the latest version of Smartpay to your project's dependencies:
15
+
16
+ ```sh
17
+ gem install smartpay
18
+ ```
19
+
20
+ If you want to build the gem yourself from source:
10
21
 
11
- $ bundle add smartpay
22
+ ```sh
23
+ gem build smartpay.gemspec
24
+ ```
12
25
 
13
- Or, you can add this line to your application's Gemfile and specify the version restriction:
26
+ ### Bundler
27
+
28
+ If you are installing via bundler, make sure that you use the `https` resource in your Gemfile to avoid the risk of gems being compromised:
14
29
 
15
30
  ```ruby
16
- gem 'smartpay', "~> 0.1.0"
31
+ source 'https://rubygems.org'
32
+
33
+ gem 'smartpay'
34
+ ```
35
+
36
+ ## Use with your favorite frameworks
37
+
38
+ ### Ruby on Rails (RoR)
39
+
40
+ #### Install Rails
41
+
42
+ ```sh
43
+ gem install rails
17
44
  ```
18
45
 
19
- And then execute:
46
+ #### Create your app
47
+
48
+ ```sh
49
+ rails new app-with-smartpay
50
+ ```
20
51
 
21
- $ bundle install
52
+ #### Add Smartpay
22
53
 
23
- ## Usage for Ruby on Rails
54
+ ```sh
55
+ cd app-with-smartpay
56
+ bundle add smartpay
57
+ ```
24
58
 
25
- After installed the gem package, you can generate relevant files with:
59
+ #### Generator
26
60
 
27
- $ bundle exec rails generate smartpay:install
61
+ ```sh
62
+ bundle exec rails generate smartpay:install
63
+ ```
28
64
 
29
- This will introduce 4 changes, including a simple example for checkout session flow:
65
+ This introduces 4 changes for a pre-built Smartpay Checkout example:
30
66
 
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
67
+ > 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
+ > 2. A new controller - `app/controllers/smartpays_controller.rb`. This is where you can see how a Checkout session is configured & created.
69
+ > 3. A new view - `app/views/smartpays/index.html.erb`. The minimum frontend required.
70
+ > 4. A new route in config/routes.rb.
35
71
 
36
- ### Setup Server Credentials
72
+ #### Fill in your API keys
37
73
 
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).
74
+ Edit the keys with your own credentials in `config/initializers/smartpay.rb`.
40
75
 
41
- Update your API key and secret to the fields `public_key` and `api_secret` in `config/initializers/smartpay.rb`.
76
+ ```ruby
77
+ ...
78
+ 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_
80
+ ...
81
+ ```
82
+
83
+ #### Start your server
84
+
85
+ ```sh
86
+ bundle exec rails server
87
+ ```
42
88
 
43
89
  ### Test with Checkout Session
44
90
 
45
- Start your server and navigate to `http://localhost:3000/smartpays`.
91
+ Visit [http://localhost:3000/smartpays](http://localhost:3000/smartpays).
46
92
 
47
- Click the `checkout` button to be redirected to the Checkout page.
93
+ Click the `checkout` button on the page to be redirected to Smartpay's Checkout.
48
94
 
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.
95
+ To try out different cases, you can use the following test credit cards for different cases:
50
96
 
51
- 1. Payment succeeds: `success@smartpay.co`
52
- 2. Payment requires authentication: `auth.required@smartpay.co`
53
- 3. Payment is declined: `declined@smartpay.co`
97
+ - Payment succeeds: `4242 4242 4242 4242`
98
+ - Payment is declined: `4100 0000 0000 0019`
54
99
 
55
100
  ## Development
56
101
 
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  Smartpay.configure do |config|
4
- config.api_url = 'https://api.smartpay.re/smartpayments'
5
- config.checkout_url = 'https://checkout.smartpay.re'
4
+ config.api_url = 'https://api.smartpay.co/smartpayments'
5
+ config.checkout_url = 'https://checkout.smartpay.co'
6
6
  config.public_key = 'pk_test_'
7
- config.api_secret = 'sk_test_'
7
+ config.secret_key = 'sk_test_'
8
8
  end
@@ -24,12 +24,12 @@ module Smartpay
24
24
  {
25
25
  accept: :json,
26
26
  content_type: :json,
27
- Authorization: "Basic #{api_secret}"
27
+ Authorization: "Basic #{secret_key}"
28
28
  }
29
29
  end
30
30
 
31
- def api_secret
32
- Smartpay.configuration.api_secret
31
+ def secret_key
32
+ Smartpay.configuration.secret_key
33
33
  end
34
34
  end
35
35
  end
@@ -3,7 +3,7 @@
3
3
  module Smartpay
4
4
  class Configuration
5
5
  attr_accessor :post_timeout
6
- attr_accessor :public_key, :api_secret, :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'
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Smartpay
4
- VERSION = "0.2.0"
4
+ VERSION = "0.2.1"
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.0
4
+ version: 0.2.1
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-18 00:00:00.000000000 Z
11
+ date: 2021-10-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client