smartpay 0.2.0 → 0.2.1
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 +72 -27
- data/lib/generators/smartpay/templates/initializer.rb +3 -3
- data/lib/smartpay/client.rb +3 -3
- data/lib/smartpay/configuration.rb +1 -1
- data/lib/smartpay/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cb4d84133812657ba1e6e6683ea63bc14f9dd421420b0694d3d31aa0098ead74
|
4
|
+
data.tar.gz: 8b356926abcb9d367eb64e5873859af80791499ab3ed2feb8c688deee487fbf6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
3
|
+
The Smartpay Ruby library offers easy access to Smartpay API from applications written in Ruby.
|
4
4
|
|
5
|
-
|
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
|
-
|
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
|
-
|
22
|
+
```sh
|
23
|
+
gem build smartpay.gemspec
|
24
|
+
```
|
12
25
|
|
13
|
-
|
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
|
-
|
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
|
-
|
46
|
+
#### Create your app
|
47
|
+
|
48
|
+
```sh
|
49
|
+
rails new app-with-smartpay
|
50
|
+
```
|
20
51
|
|
21
|
-
|
52
|
+
#### Add Smartpay
|
22
53
|
|
23
|
-
|
54
|
+
```sh
|
55
|
+
cd app-with-smartpay
|
56
|
+
bundle add smartpay
|
57
|
+
```
|
24
58
|
|
25
|
-
|
59
|
+
#### Generator
|
26
60
|
|
27
|
-
|
61
|
+
```sh
|
62
|
+
bundle exec rails generate smartpay:install
|
63
|
+
```
|
28
64
|
|
29
|
-
This
|
65
|
+
This introduces 4 changes for a pre-built Smartpay Checkout example:
|
30
66
|
|
31
|
-
1.
|
32
|
-
2.
|
33
|
-
3.
|
34
|
-
4.
|
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
|
-
|
72
|
+
#### Fill in your API keys
|
37
73
|
|
38
|
-
|
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
|
-
|
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
|
-
|
91
|
+
Visit [http://localhost:3000/smartpays](http://localhost:3000/smartpays).
|
46
92
|
|
47
|
-
Click the `checkout` button to be redirected to
|
93
|
+
Click the `checkout` button on the page to be redirected to Smartpay's Checkout.
|
48
94
|
|
49
|
-
|
95
|
+
To try out different cases, you can use the following test credit cards for different cases:
|
50
96
|
|
51
|
-
|
52
|
-
|
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.
|
5
|
-
config.checkout_url = 'https://checkout.smartpay.
|
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.
|
7
|
+
config.secret_key = 'sk_test_'
|
8
8
|
end
|
data/lib/smartpay/client.rb
CHANGED
@@ -24,12 +24,12 @@ module Smartpay
|
|
24
24
|
{
|
25
25
|
accept: :json,
|
26
26
|
content_type: :json,
|
27
|
-
Authorization: "Basic #{
|
27
|
+
Authorization: "Basic #{secret_key}"
|
28
28
|
}
|
29
29
|
end
|
30
30
|
|
31
|
-
def
|
32
|
-
Smartpay.configuration.
|
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, :
|
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'
|
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.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-
|
11
|
+
date: 2021-10-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|