fonepaisa 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.circleci/config.yml +64 -0
- data/.circleci/setup-rubygems.sh +3 -0
- data/.gitignore +3 -0
- data/.rubocop.yml +18 -0
- data/CHANGELOG.md +3 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +59 -0
- data/LICENSE +22 -0
- data/README.md +19 -0
- data/Rakefile +4 -0
- data/fonepaisa.gemspec +22 -0
- data/lib/fonepaisa.rb +21 -0
- data/lib/fonepaisa/client.rb +43 -0
- data/lib/fonepaisa/configuration.rb +18 -0
- data/lib/fonepaisa/payment_request_url.rb +14 -0
- data/lib/fonepaisa/version.rb +3 -0
- metadata +115 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 4b9b4888598457e984a9526dfaded9504136cf5f211f2968ead6cadb8cc4d79b
|
4
|
+
data.tar.gz: 1b8818296ff35f333ccea880a24294d525a5664d630cc2882774130b9c3ac2ac
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a64b142817cf2bf8099ede143b94a8d5216c23252da9cbb251a87a48644d6ab32b4b54aabd1d3206b96cf768cbae041611dd6f4898834b825265f3c6066d3d5b
|
7
|
+
data.tar.gz: 219a7cb98432cceff6e0fa205d1c8c3e1e0e8445aec75e29f37f7055732129cf3b56c048744503267896b2475663f37864e46f087510ea4067d1784a7297e367
|
@@ -0,0 +1,64 @@
|
|
1
|
+
version: 2.1
|
2
|
+
|
3
|
+
environment: &environment
|
4
|
+
LOG_LEVEL: WARN
|
5
|
+
|
6
|
+
jobs:
|
7
|
+
run_cops:
|
8
|
+
working_directory: ~/repos/fonepaisa
|
9
|
+
|
10
|
+
docker:
|
11
|
+
- image: circleci/ruby:2.6.4-buster-node
|
12
|
+
environment:
|
13
|
+
<<: *environment
|
14
|
+
|
15
|
+
steps:
|
16
|
+
- checkout
|
17
|
+
|
18
|
+
- run:
|
19
|
+
name: check dependencies
|
20
|
+
command: |
|
21
|
+
gem install bundler:2.1.4
|
22
|
+
bundle -v
|
23
|
+
bundle exec ruby -v
|
24
|
+
|
25
|
+
- run:
|
26
|
+
name: install gems
|
27
|
+
command: bundle install && bundle clean
|
28
|
+
|
29
|
+
- run:
|
30
|
+
name: run rubocop
|
31
|
+
command: bundle exec rake rubocop
|
32
|
+
|
33
|
+
publish_to_rubygems:
|
34
|
+
working_directory: ~/repos/fonepaisa
|
35
|
+
|
36
|
+
docker:
|
37
|
+
- image: circleci/ruby:2.6.4-buster-node
|
38
|
+
environment:
|
39
|
+
<<: *environment
|
40
|
+
|
41
|
+
steps:
|
42
|
+
- checkout
|
43
|
+
|
44
|
+
- run:
|
45
|
+
name: setup Rubygems
|
46
|
+
command: bash .circleci/setup-rubygems.sh
|
47
|
+
|
48
|
+
- run:
|
49
|
+
name: publish to Rubygems
|
50
|
+
command: |
|
51
|
+
gem build fonepaisa.gemspec
|
52
|
+
gem push "fonepaisa-$(git describe --tags).gem"
|
53
|
+
|
54
|
+
workflows:
|
55
|
+
version: 2
|
56
|
+
build_and_test:
|
57
|
+
jobs:
|
58
|
+
- run_cops
|
59
|
+
- publish_to_rubygems:
|
60
|
+
filters:
|
61
|
+
tags:
|
62
|
+
only: /.*/
|
63
|
+
branches:
|
64
|
+
ignore: /.*/
|
data/.gitignore
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
AllCops:
|
2
|
+
TargetRubyVersion: 2.4.0
|
3
|
+
NewCops: enable
|
4
|
+
|
5
|
+
Style/FrozenStringLiteralComment:
|
6
|
+
Enabled: false
|
7
|
+
|
8
|
+
Metrics/ClassLength:
|
9
|
+
Max: 300
|
10
|
+
|
11
|
+
Layout/LineLength:
|
12
|
+
Max: 120
|
13
|
+
|
14
|
+
Style/ClassAndModuleChildren:
|
15
|
+
Enabled: false
|
16
|
+
|
17
|
+
Style/Documentation:
|
18
|
+
Enabled: false
|
data/CHANGELOG.md
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
fonepaisa (0.1.0)
|
5
|
+
rest-client (~> 2.1)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
ast (2.4.1)
|
11
|
+
domain_name (0.5.20190701)
|
12
|
+
unf (>= 0.0.5, < 1.0.0)
|
13
|
+
http-accept (1.7.0)
|
14
|
+
http-cookie (1.0.3)
|
15
|
+
domain_name (~> 0.5)
|
16
|
+
mime-types (3.3.1)
|
17
|
+
mime-types-data (~> 3.2015)
|
18
|
+
mime-types-data (3.2020.1104)
|
19
|
+
netrc (0.11.0)
|
20
|
+
parallel (1.20.1)
|
21
|
+
parser (2.7.2.0)
|
22
|
+
ast (~> 2.4.1)
|
23
|
+
rainbow (3.0.0)
|
24
|
+
rake (10.5.0)
|
25
|
+
regexp_parser (2.0.0)
|
26
|
+
rest-client (2.1.0)
|
27
|
+
http-accept (>= 1.7.0, < 2.0)
|
28
|
+
http-cookie (>= 1.0.2, < 2.0)
|
29
|
+
mime-types (>= 1.16, < 4.0)
|
30
|
+
netrc (~> 0.8)
|
31
|
+
rexml (3.2.4)
|
32
|
+
rubocop (1.6.1)
|
33
|
+
parallel (~> 1.10)
|
34
|
+
parser (>= 2.7.1.5)
|
35
|
+
rainbow (>= 2.2.2, < 4.0)
|
36
|
+
regexp_parser (>= 1.8, < 3.0)
|
37
|
+
rexml
|
38
|
+
rubocop-ast (>= 1.2.0, < 2.0)
|
39
|
+
ruby-progressbar (~> 1.7)
|
40
|
+
unicode-display_width (>= 1.4.0, < 2.0)
|
41
|
+
rubocop-ast (1.3.0)
|
42
|
+
parser (>= 2.7.1.5)
|
43
|
+
ruby-progressbar (1.10.1)
|
44
|
+
unf (0.1.4)
|
45
|
+
unf_ext
|
46
|
+
unf_ext (0.0.7.7)
|
47
|
+
unicode-display_width (1.7.0)
|
48
|
+
|
49
|
+
PLATFORMS
|
50
|
+
ruby
|
51
|
+
|
52
|
+
DEPENDENCIES
|
53
|
+
bundler (~> 2.1.4)
|
54
|
+
fonepaisa!
|
55
|
+
rake (~> 10.0)
|
56
|
+
rubocop (~> 1.6)
|
57
|
+
|
58
|
+
BUNDLED WITH
|
59
|
+
2.1.4
|
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2020 Rakesh Tejra
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
data/Rakefile
ADDED
data/fonepaisa.gemspec
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
lib = File.expand_path('lib', __dir__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require 'fonepaisa/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = 'fonepaisa'
|
7
|
+
spec.version = Fonepaisa::VERSION
|
8
|
+
spec.authors = ['Rakesh Tejra']
|
9
|
+
spec.email = ['rtejra@gammastack.com']
|
10
|
+
spec.summary = 'Ruby bindings for the fonePaisa API'
|
11
|
+
spec.description = 'A library that interact with fonePaisa payment gateway service.'
|
12
|
+
spec.homepage = 'https://github.com/RakeshTejra/fonepaisa'
|
13
|
+
spec.license = 'MIT'
|
14
|
+
spec.required_ruby_version = '>= 2.4.0'
|
15
|
+
spec.files = `git ls-files`.split("\n")
|
16
|
+
|
17
|
+
spec.add_dependency 'rest-client', '~> 2.1'
|
18
|
+
|
19
|
+
spec.add_development_dependency 'bundler', '~> 2.1.4'
|
20
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
21
|
+
spec.add_development_dependency 'rubocop', '~> 1.6'
|
22
|
+
end
|
data/lib/fonepaisa.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'fonepaisa/configuration'
|
2
|
+
require 'fonepaisa/client'
|
3
|
+
require 'fonepaisa/payment_request_url'
|
4
|
+
|
5
|
+
module Fonepaisa
|
6
|
+
class FonepaisaError < StandardError; end
|
7
|
+
|
8
|
+
class << self
|
9
|
+
def configure
|
10
|
+
yield configuration
|
11
|
+
end
|
12
|
+
|
13
|
+
def configuration
|
14
|
+
@configuration ||= Configuration.new
|
15
|
+
end
|
16
|
+
|
17
|
+
def reset
|
18
|
+
@configuration = Configuration.new
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'digest'
|
2
|
+
require 'rest-client'
|
3
|
+
|
4
|
+
module Fonepaisa
|
5
|
+
class Client
|
6
|
+
attr_reader :params
|
7
|
+
|
8
|
+
BASE_URL = 'https://api.fonepaisa.com/v2'.freeze
|
9
|
+
|
10
|
+
def initialize(params)
|
11
|
+
@params = params
|
12
|
+
end
|
13
|
+
|
14
|
+
def response_valid?
|
15
|
+
# if hash field is nil then no need to verify response params
|
16
|
+
return true if params[:hash].nil?
|
17
|
+
|
18
|
+
attributes = params.dup
|
19
|
+
attributes.delete(:hash)
|
20
|
+
hash_key = secure_hash_key(attributes)
|
21
|
+
|
22
|
+
hash_key == params[:hash]
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def secure_hash_key(attributes)
|
28
|
+
data = Fonepaisa.configuration.salt!
|
29
|
+
|
30
|
+
attributes.sort.to_h.each do |_key, value|
|
31
|
+
data += "|#{value.gsub(/\s+/, ' ').strip}" unless value.nil?
|
32
|
+
end
|
33
|
+
|
34
|
+
Digest::SHA512.hexdigest(data).upcase
|
35
|
+
end
|
36
|
+
|
37
|
+
def request_params
|
38
|
+
params.merge(
|
39
|
+
api_key: Fonepaisa.configuration.api_key!
|
40
|
+
)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Fonepaisa
|
2
|
+
class Configuration
|
3
|
+
attr_accessor :api_key, :salt
|
4
|
+
|
5
|
+
def initialize
|
6
|
+
@api_key = nil
|
7
|
+
@salt = nil
|
8
|
+
end
|
9
|
+
|
10
|
+
def api_key!
|
11
|
+
api_key || raise(FonepaisaError, 'No api key specified.')
|
12
|
+
end
|
13
|
+
|
14
|
+
def salt!
|
15
|
+
salt || raise(FonepaisaError, 'No salt specified.')
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Fonepaisa
|
2
|
+
class PaymentRequestURL < Client
|
3
|
+
def execute
|
4
|
+
hash_key = secure_hash_key(request_params)
|
5
|
+
|
6
|
+
response = RestClient.post(
|
7
|
+
"#{BASE_URL}/getpaymentrequesturl",
|
8
|
+
request_params.merge(hash: hash_key)
|
9
|
+
)
|
10
|
+
|
11
|
+
response.body
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
metadata
ADDED
@@ -0,0 +1,115 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fonepaisa
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Rakesh Tejra
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-12-17 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rest-client
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.1'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.1'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 2.1.4
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 2.1.4
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rubocop
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.6'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.6'
|
69
|
+
description: A library that interact with fonePaisa payment gateway service.
|
70
|
+
email:
|
71
|
+
- rtejra@gammastack.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".circleci/config.yml"
|
77
|
+
- ".circleci/setup-rubygems.sh"
|
78
|
+
- ".gitignore"
|
79
|
+
- ".rubocop.yml"
|
80
|
+
- CHANGELOG.md
|
81
|
+
- Gemfile
|
82
|
+
- Gemfile.lock
|
83
|
+
- LICENSE
|
84
|
+
- README.md
|
85
|
+
- Rakefile
|
86
|
+
- fonepaisa.gemspec
|
87
|
+
- lib/fonepaisa.rb
|
88
|
+
- lib/fonepaisa/client.rb
|
89
|
+
- lib/fonepaisa/configuration.rb
|
90
|
+
- lib/fonepaisa/payment_request_url.rb
|
91
|
+
- lib/fonepaisa/version.rb
|
92
|
+
homepage: https://github.com/RakeshTejra/fonepaisa
|
93
|
+
licenses:
|
94
|
+
- MIT
|
95
|
+
metadata: {}
|
96
|
+
post_install_message:
|
97
|
+
rdoc_options: []
|
98
|
+
require_paths:
|
99
|
+
- lib
|
100
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - ">="
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: 2.4.0
|
105
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - ">="
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
requirements: []
|
111
|
+
rubygems_version: 3.0.3
|
112
|
+
signing_key:
|
113
|
+
specification_version: 4
|
114
|
+
summary: Ruby bindings for the fonePaisa API
|
115
|
+
test_files: []
|