paytech_gem 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/README.md +54 -0
- data/Rakefile +4 -0
- data/lib/paytech_gem/version.rb +5 -0
- data/lib/paytech_gem.rb +69 -0
- data/paytech_gem.gemspec +39 -0
- data/sig/paytech_gem.rbs +4 -0
- metadata +53 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: ef87bc72625aa5649b7c9725c0c75622c445656ddd05eabdc95400b849122fd0
|
4
|
+
data.tar.gz: df26220c284432217e79c274ac376944a404313c145780e312998bd02e527276
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b465fca272bfa9c1a225f486154115efaf077329e0f73840f388ff432664ef17591fde0dbcba26116b827ac272d78872e40df43b7ef8b5df2ce590fb7c909eca
|
7
|
+
data.tar.gz: ee4b68eae8d384231c95599d38c639ea955fff8125b8d570414a1f44eb2cddf9b86d26e849c4382fd26f9271817041d15338b8e792e86a799a39c4bff87d0e69
|
data/README.md
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
# PaytechGem
|
2
|
+
|
3
|
+
|
4
|
+
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/paytech_gem`. To experiment with that code, run `bin/console` for an interactive prompt.
|
5
|
+
|
6
|
+
## Installation
|
7
|
+
|
8
|
+
Add this line to your application's Gemfile:
|
9
|
+
|
10
|
+
$ gem 'paytech_gem', '~> 0.1.0' # Adjust the version as needed
|
11
|
+
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle install
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install paytech_gem -v '0.1.0' # Adjust the version as needed
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
Create a paytech.rb file in the root of your project to configure the gem
|
24
|
+
|
25
|
+
# paytech.rb
|
26
|
+
require 'paytech_gem'
|
27
|
+
|
28
|
+
PaytechGem.configure do |config|
|
29
|
+
config.paytech_api_key = 'your_api_key'
|
30
|
+
config.paytech_api_secret = 'your_secret_key'
|
31
|
+
config.currency = 'XOF'
|
32
|
+
config.command_name = 'Invoice from Paytech'
|
33
|
+
config.env = 'test'
|
34
|
+
config.ipn_url = 'URL for IPN (Instant Payment Notification)'
|
35
|
+
config.success_url = 'URL for successful transactions'
|
36
|
+
config.cancel_url = 'URL for canceled transactions'
|
37
|
+
|
38
|
+
|
39
|
+
end
|
40
|
+
|
41
|
+
Call it on by:
|
42
|
+
|
43
|
+
invoice = PaytechGem.initialize_payment(10000, "iphone" , ref_command)
|
44
|
+
puts invoice
|
45
|
+
## Development
|
46
|
+
|
47
|
+
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
48
|
+
|
49
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
50
|
+
|
51
|
+
## Contributing
|
52
|
+
|
53
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/paytech_gem.
|
54
|
+
# paytech_gem
|
data/Rakefile
ADDED
data/lib/paytech_gem.rb
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "paytech_gem/version"
|
4
|
+
require 'httparty'
|
5
|
+
|
6
|
+
module PaytechGem
|
7
|
+
class Configuration
|
8
|
+
attr_accessor :api_key, :api_secret, :currency, :command_name,
|
9
|
+
:env, :ipn_url, :success_url, :cancel_url
|
10
|
+
|
11
|
+
def initialize
|
12
|
+
# Set default values or leave them nil
|
13
|
+
@api_key = ENV['PAYTECH_API_KEY']
|
14
|
+
@api_secret = ENV['PAYTECH_SECRET_KEY']
|
15
|
+
@currency = 'XOF'
|
16
|
+
@command_name = 'Depot compte Nessi via PayTech'
|
17
|
+
@env = ENV['PAYTECH_ENV']
|
18
|
+
@ipn_url = 'https://www.yapsy.sn/api/v1/paytech/ipn'
|
19
|
+
@success_url = 'https://www.yapsy.sn/paytech/success'
|
20
|
+
@cancel_url = 'https://www.yapsy.sn/paytech/cancel'
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
class << self
|
25
|
+
attr_accessor :config
|
26
|
+
|
27
|
+
def configure
|
28
|
+
self.config ||= Configuration.new
|
29
|
+
yield(config)
|
30
|
+
end
|
31
|
+
|
32
|
+
def initialize_payment(amount, item_name, ref_command)
|
33
|
+
url = 'https://paytech.sn/api/payment/request-payment'
|
34
|
+
headers = {
|
35
|
+
'Accept': 'application/json',
|
36
|
+
'Content-Type': 'application/json',
|
37
|
+
'API_KEY': config.paytech_api_key,
|
38
|
+
'API_SECRET': config.paytech_api_secret
|
39
|
+
}
|
40
|
+
|
41
|
+
data = {
|
42
|
+
item_name: item,
|
43
|
+
item_price: amount,
|
44
|
+
currency: config.currency,
|
45
|
+
ref_command: ref_command,
|
46
|
+
command_name: config.command_name,
|
47
|
+
env: config.env,
|
48
|
+
ipn_url: config.ipn_url,
|
49
|
+
success_url: config.success_url,
|
50
|
+
cancel_url: config.cancel_url
|
51
|
+
}
|
52
|
+
|
53
|
+
response = HTTParty.post(url, body: data.to_json, headers: headers)
|
54
|
+
|
55
|
+
if response.code == 200
|
56
|
+
json_response = JSON.parse(response.body)
|
57
|
+
return json_response
|
58
|
+
else
|
59
|
+
return "Error: #{response.code} - #{response.body}"
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
begin
|
66
|
+
require 'paytech' # Assuming users have a paytech.rb file in their project
|
67
|
+
rescue LoadError
|
68
|
+
|
69
|
+
end
|
data/paytech_gem.gemspec
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "lib/paytech_gem/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "paytech_gem"
|
7
|
+
spec.version = PaytechGem::VERSION
|
8
|
+
spec.authors = ["Yapsee"]
|
9
|
+
spec.email = ["yapsasee@gmail.com"]
|
10
|
+
|
11
|
+
spec.summary = "Paytech library."
|
12
|
+
spec.description = "This gem helps you implement payments through a senegalses aggregator Paytech."
|
13
|
+
spec.homepage = "https://github.com/yapsee/paytech_gem"
|
14
|
+
spec.required_ruby_version = ">= 2.6.0"
|
15
|
+
|
16
|
+
spec.metadata["allowed_push_host"] = "https://rubygems.org"
|
17
|
+
|
18
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
19
|
+
spec.metadata["source_code_uri"] = "https://github.com/yapsee/paytech_gem"
|
20
|
+
spec.metadata["changelog_uri"] = "https://github.com/yapsee/paytech_gem."
|
21
|
+
|
22
|
+
# Specify which files should be added to the gem when it is released.
|
23
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
24
|
+
spec.files = Dir.chdir(__dir__) do
|
25
|
+
`git ls-files -z`.split("\x0").reject do |f|
|
26
|
+
(File.expand_path(f) == __FILE__) ||
|
27
|
+
f.start_with?(*%w[bin/ test/ spec/ features/ .git appveyor Gemfile])
|
28
|
+
end
|
29
|
+
end
|
30
|
+
spec.bindir = "exe"
|
31
|
+
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
32
|
+
spec.require_paths = ["lib"]
|
33
|
+
|
34
|
+
# Uncomment to register a new dependency of your gem
|
35
|
+
# spec.add_dependency "example-gem", "~> 1.0"
|
36
|
+
|
37
|
+
# For more information and examples about making a new gem, check out our
|
38
|
+
# guide at: https://bundler.io/guides/creating_gem.html
|
39
|
+
end
|
data/sig/paytech_gem.rbs
ADDED
metadata
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: paytech_gem
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Yapsee
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2023-12-04 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: This gem helps you implement payments through a senegalses aggregator
|
14
|
+
Paytech.
|
15
|
+
email:
|
16
|
+
- yapsasee@gmail.com
|
17
|
+
executables: []
|
18
|
+
extensions: []
|
19
|
+
extra_rdoc_files: []
|
20
|
+
files:
|
21
|
+
- README.md
|
22
|
+
- Rakefile
|
23
|
+
- lib/paytech_gem.rb
|
24
|
+
- lib/paytech_gem/version.rb
|
25
|
+
- paytech_gem.gemspec
|
26
|
+
- sig/paytech_gem.rbs
|
27
|
+
homepage: https://github.com/yapsee/paytech_gem
|
28
|
+
licenses: []
|
29
|
+
metadata:
|
30
|
+
allowed_push_host: https://rubygems.org
|
31
|
+
homepage_uri: https://github.com/yapsee/paytech_gem
|
32
|
+
source_code_uri: https://github.com/yapsee/paytech_gem
|
33
|
+
changelog_uri: https://github.com/yapsee/paytech_gem.
|
34
|
+
post_install_message:
|
35
|
+
rdoc_options: []
|
36
|
+
require_paths:
|
37
|
+
- lib
|
38
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
39
|
+
requirements:
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: 2.6.0
|
43
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
requirements: []
|
49
|
+
rubygems_version: 3.4.22
|
50
|
+
signing_key:
|
51
|
+
specification_version: 4
|
52
|
+
summary: Paytech library.
|
53
|
+
test_files: []
|