pesepay 0.1.0 → 0.1.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/.github/workflows/main.yml +16 -16
- data/.gitignore +13 -13
- data/.rspec +3 -3
- data/.rubocop.yml +13 -13
- data/CHANGELOG.md +5 -5
- data/CODE_OF_CONDUCT.md +84 -84
- data/Gemfile +14 -14
- data/Gemfile.lock +58 -57
- data/LICENSE.txt +21 -21
- data/README.md +154 -144
- data/Rakefile +12 -12
- data/bin/console +15 -15
- data/bin/setup +8 -8
- data/lib/pesepay/version.rb +5 -5
- data/lib/pesepay.rb +266 -262
- data/pesepay.gemspec +37 -37
- metadata +3 -6
data/README.md
CHANGED
|
@@ -1,144 +1,154 @@
|
|
|
1
|
-
# Pesepay
|
|
2
|
-
|
|
3
|
-
Pesepay is a payment gateway ruby gem that allows you to make and manage payments online.
|
|
4
|
-
|
|
5
|
-
## Installation
|
|
6
|
-
|
|
7
|
-
Add this line to your application's Gemfile:
|
|
8
|
-
|
|
9
|
-
```ruby
|
|
10
|
-
gem 'pesepay'
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
And then execute:
|
|
14
|
-
|
|
15
|
-
$ bundle install
|
|
16
|
-
|
|
17
|
-
Or install it yourself as:
|
|
18
|
-
|
|
19
|
-
$ gem install pesepay
|
|
20
|
-
|
|
21
|
-
## Usage
|
|
22
|
-
|
|
23
|
-
- initiate_transaction is a method in the Pesepay class that allows merchants to initiate a payment transaction. When called, it sends a request to the Pesepay API with the transaction details, such as the amount, currency, description, and reference number. If the request is successful, the method returns a Response object containing a reference number, poll URL, and redirect URL. The reference number can be used for tracking purposes, while the poll URL and redirect URL are used for further processing and redirecting the customer to complete the payment.
|
|
24
|
-
|
|
25
|
-
- make_seamless_payment is another method in the Pesepay class, designed for seamless payment processing. It enables merchants to process credit card payments without redirecting customers to the Pesepay platform. This method also sends a request to the Pesepay API with the necessary payment details, and if the request is successful, it returns a Response object with a reference number, poll URL, and redirect URL. These URLs are crucial for handling the payment process and communicating the status back to the merchant's platform. Additionally, this method requires specific payment method details, like credit card information, to perform the seamless payment.
|
|
26
|
-
|
|
27
|
-
- get_payment_method_code(currency_code): This method returns the payment method code for the specified currency code.
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
### To redirect to pesepay page and make paymnets
|
|
41
|
-
|
|
42
|
-
```ruby
|
|
43
|
-
|
|
44
|
-
# Set the return URL and result URL for handling the transaction status
|
|
45
|
-
|
|
46
|
-
pesepay.result_url = "http://example.com/gateway/
|
|
47
|
-
pesepay.return_url = "http://example.com/gateway/return"
|
|
48
|
-
|
|
49
|
-
# Create a transaction for $100 with the currency code "USD" and the reason "Pizza"
|
|
50
|
-
|
|
51
|
-
transaction = pesepay.create_transaction(100, "USD", "Pizza", 11.99)
|
|
52
|
-
|
|
53
|
-
# Initiate the transaction and get the response from the API
|
|
54
|
-
|
|
55
|
-
response = pesepay.initiate_transaction(transaction)
|
|
56
|
-
|
|
57
|
-
if response.success
|
|
58
|
-
|
|
59
|
-
# Transaction initiation was successful, so redirect the user to the provided redirect URL
|
|
60
|
-
|
|
61
|
-
poll_url = response.pollUrl
|
|
62
|
-
redirect_to response.redirectUrl
|
|
63
|
-
else
|
|
64
|
-
|
|
65
|
-
# There was an error, so display the error message to the user
|
|
66
|
-
|
|
67
|
-
puts response.message
|
|
68
|
-
end
|
|
69
|
-
```
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
#
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
#
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
##
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
1
|
+
# Pesepay
|
|
2
|
+
|
|
3
|
+
Pesepay is a payment gateway ruby gem that allows you to make and manage payments online.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
Add this line to your application's Gemfile:
|
|
8
|
+
|
|
9
|
+
```ruby
|
|
10
|
+
gem 'pesepay'
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
And then execute:
|
|
14
|
+
|
|
15
|
+
$ bundle install
|
|
16
|
+
|
|
17
|
+
Or install it yourself as:
|
|
18
|
+
|
|
19
|
+
$ gem install pesepay
|
|
20
|
+
|
|
21
|
+
## Usage
|
|
22
|
+
|
|
23
|
+
- initiate_transaction is a method in the Pesepay class that allows merchants to initiate a payment transaction. When called, it sends a request to the Pesepay API with the transaction details, such as the amount, currency, description, and reference number. If the request is successful, the method returns a Response object containing a reference number, poll URL, and redirect URL. The reference number can be used for tracking purposes, while the poll URL and redirect URL are used for further processing and redirecting the customer to complete the payment.
|
|
24
|
+
|
|
25
|
+
- make_seamless_payment is another method in the Pesepay class, designed for seamless payment processing. It enables merchants to process credit card payments without redirecting customers to the Pesepay platform. This method also sends a request to the Pesepay API with the necessary payment details, and if the request is successful, it returns a Response object with a reference number, poll URL, and redirect URL. These URLs are crucial for handling the payment process and communicating the status back to the merchant's platform. Additionally, this method requires specific payment method details, like credit card information, to perform the seamless payment.
|
|
26
|
+
|
|
27
|
+
- get_payment_method_code(currency_code): This method returns the payment method code for the specified currency code.
|
|
28
|
+
|
|
29
|
+
Here is an example of how you might use the Pesepay gem in your code:
|
|
30
|
+
|
|
31
|
+
```ruby
|
|
32
|
+
require 'pesepay'
|
|
33
|
+
|
|
34
|
+
# Create a new Pesepay object with your integration key and encryption key
|
|
35
|
+
|
|
36
|
+
pesepay = Pesepay::Pesepay.new('INTEGRATION_KEY', 'ENCRYPTION_KEY')
|
|
37
|
+
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### To redirect to pesepay page and make paymnets
|
|
41
|
+
|
|
42
|
+
```ruby
|
|
43
|
+
|
|
44
|
+
# Set the return URL and result URL for handling the transaction status
|
|
45
|
+
|
|
46
|
+
pesepay.result_url = "http://example.com/gateway/result"
|
|
47
|
+
pesepay.return_url = "http://example.com/gateway/return"
|
|
48
|
+
|
|
49
|
+
# Create a transaction for $100 with the currency code "USD" and the reason "Pizza"
|
|
50
|
+
|
|
51
|
+
transaction = pesepay.create_transaction(100, "USD", "Pizza", 11.99)
|
|
52
|
+
|
|
53
|
+
# Initiate the transaction and get the response from the API
|
|
54
|
+
|
|
55
|
+
response = pesepay.initiate_transaction(transaction)
|
|
56
|
+
|
|
57
|
+
if response.success
|
|
58
|
+
|
|
59
|
+
# Transaction initiation was successful, so redirect the user to the provided redirect URL
|
|
60
|
+
|
|
61
|
+
poll_url = response.pollUrl
|
|
62
|
+
redirect_to response.redirectUrl
|
|
63
|
+
else
|
|
64
|
+
|
|
65
|
+
# There was an error, so display the error message to the user
|
|
66
|
+
|
|
67
|
+
puts response.message
|
|
68
|
+
end
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### To Make a seamless payment using credit card for $50 with the currency code "USD"
|
|
72
|
+
|
|
73
|
+
```ruby
|
|
74
|
+
payment = pesepay.create_seamless_transaction("USD", "PZW204", "customer@example.com", "555-555-1212", "John Smith")
|
|
75
|
+
|
|
76
|
+
# visa
|
|
77
|
+
payment_method_required_fields = {
|
|
78
|
+
"creditCardExpiryDate": "09/23",
|
|
79
|
+
"creditCardNumber": "4867960000005461",
|
|
80
|
+
"creditCardSecurityNumber": "608"
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
response = pesepay.make_seamless_payment(payment, "Test payment", 100, payment_method_required_fields, "merchant_ref")
|
|
84
|
+
|
|
85
|
+
if response.success
|
|
86
|
+
|
|
87
|
+
# Payment was successful, so save the reference number and poll URL for checking the transaction status
|
|
88
|
+
reference_number = response.reference_number
|
|
89
|
+
poll_url = response.poll_url
|
|
90
|
+
|
|
91
|
+
# whole response data
|
|
92
|
+
data = response.raw_data
|
|
93
|
+
else
|
|
94
|
+
|
|
95
|
+
# There was an error, so display the error message to the user
|
|
96
|
+
|
|
97
|
+
puts response.message
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
# If paying using mobile money, provide the required payment details
|
|
101
|
+
|
|
102
|
+
payment = pesepay.create_seamless_transaction("USD", "PZW211", "customer@example.com", "555-555-1212", "John Smith")
|
|
103
|
+
|
|
104
|
+
# direct mobile payments e.g ecocash, innbucs
|
|
105
|
+
payment_method_required_fields = {
|
|
106
|
+
'customerPhoneNumber': '0777777777'
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
response = pesepay.make_seamless_payment(payment, "Test payment", 100.00, payment_method_required_fields, "merchant_ref")
|
|
110
|
+
|
|
111
|
+
if response.success
|
|
112
|
+
|
|
113
|
+
# Payment was successful, so save the reference number and poll URL for checking the transaction status
|
|
114
|
+
|
|
115
|
+
reference_number = response.referenceNumber
|
|
116
|
+
poll_url = response.pollUrl
|
|
117
|
+
# whole response data
|
|
118
|
+
data = response.raw_data
|
|
119
|
+
|
|
120
|
+
else
|
|
121
|
+
|
|
122
|
+
# There was an error, so display the error message to the user
|
|
123
|
+
|
|
124
|
+
puts response.message
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
# Get the payment method code for the currency code "USD"
|
|
128
|
+
|
|
129
|
+
payment_method_code = payment.get_payment_method_code('USD')
|
|
130
|
+
|
|
131
|
+
puts payment_method_code
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
Make sure to replace 'INTEGRATION_KEY' and 'ENCRYPTION_KEY' with your actual Pesepay integration and encryption keys. Additionally, adjust the URLs and payment details accordingly to match your application's requirements.
|
|
137
|
+
|
|
138
|
+
## Development
|
|
139
|
+
|
|
140
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
|
141
|
+
|
|
142
|
+
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).
|
|
143
|
+
|
|
144
|
+
## Contributing
|
|
145
|
+
|
|
146
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/gitnyasha/pesepay. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/gitnyasha/pesepay/blob/master/CODE_OF_CONDUCT.md).
|
|
147
|
+
|
|
148
|
+
## License
|
|
149
|
+
|
|
150
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
|
151
|
+
|
|
152
|
+
## Code of Conduct
|
|
153
|
+
|
|
154
|
+
Everyone interacting in the Pesepay project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/gitnyasha/pesepay/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require "bundler/gem_tasks"
|
|
4
|
-
require "rspec/core/rake_task"
|
|
5
|
-
|
|
6
|
-
RSpec::Core::RakeTask.new(:spec)
|
|
7
|
-
|
|
8
|
-
require "rubocop/rake_task"
|
|
9
|
-
|
|
10
|
-
RuboCop::RakeTask.new
|
|
11
|
-
|
|
12
|
-
task default: %i[spec rubocop]
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "bundler/gem_tasks"
|
|
4
|
+
require "rspec/core/rake_task"
|
|
5
|
+
|
|
6
|
+
RSpec::Core::RakeTask.new(:spec)
|
|
7
|
+
|
|
8
|
+
require "rubocop/rake_task"
|
|
9
|
+
|
|
10
|
+
RuboCop::RakeTask.new
|
|
11
|
+
|
|
12
|
+
task default: %i[spec rubocop]
|
data/bin/console
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
#!/usr/bin/env ruby
|
|
2
|
-
# frozen_string_literal: true
|
|
3
|
-
|
|
4
|
-
require "bundler/setup"
|
|
5
|
-
require "pesepay"
|
|
6
|
-
|
|
7
|
-
# You can add fixtures and/or initialization code here to make experimenting
|
|
8
|
-
# with your gem easier. You can also use a different console, if you like.
|
|
9
|
-
|
|
10
|
-
# (If you use this, don't forget to add pry to your Gemfile!)
|
|
11
|
-
# require "pry"
|
|
12
|
-
# Pry.start
|
|
13
|
-
|
|
14
|
-
require "irb"
|
|
15
|
-
IRB.start(__FILE__)
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
require "bundler/setup"
|
|
5
|
+
require "pesepay"
|
|
6
|
+
|
|
7
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
|
8
|
+
# with your gem easier. You can also use a different console, if you like.
|
|
9
|
+
|
|
10
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
|
11
|
+
# require "pry"
|
|
12
|
+
# Pry.start
|
|
13
|
+
|
|
14
|
+
require "irb"
|
|
15
|
+
IRB.start(__FILE__)
|
data/bin/setup
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
set -euo pipefail
|
|
3
|
-
IFS=$'\n\t'
|
|
4
|
-
set -vx
|
|
5
|
-
|
|
6
|
-
bundle install
|
|
7
|
-
|
|
8
|
-
# Do any other automated setup that you need to do here
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
set -euo pipefail
|
|
3
|
+
IFS=$'\n\t'
|
|
4
|
+
set -vx
|
|
5
|
+
|
|
6
|
+
bundle install
|
|
7
|
+
|
|
8
|
+
# Do any other automated setup that you need to do here
|
data/lib/pesepay/version.rb
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Pesepay
|
|
4
|
-
VERSION = "0.1.
|
|
5
|
-
end
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Pesepay
|
|
4
|
+
VERSION = "0.1.1"
|
|
5
|
+
end
|