bygpay 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/README.md +90 -4
- data/lib/bygpay/configuration.rb +8 -3
- data/lib/bygpay/deposit/mobile.rb +1 -2
- data/lib/bygpay/utils.rb +14 -2
- data/lib/bygpay/version.rb +1 -1
- data/lib/bygpay/withdraw/mobile.rb +22 -0
- data/lib/bygpay/withdrawals.rb +6 -0
- data/lib/bygpay.rb +2 -3
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7a059301c0d3e744230e6498b1f7df5058c88aaf
|
4
|
+
data.tar.gz: d082d4051373a2d33f24aaec0f8a6bd2399a256c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: af82337c4032f15986d51b443222e793d3075e6f8ca7f21674231f037667ff2685f12c13aea6b350ac856ca91d8e7ee3281ee414ffdca1182504469c1da1a97f
|
7
|
+
data.tar.gz: 136c3f524bbe10a71b320508606b0de8be236df99ad18dc6200f6d544444b8bcc1d1492c1bcdc7159b6f252fea70752eacb3b775286be11b3bf00d372e12ca71
|
data/CHANGELOG.md
ADDED
data/README.md
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
[![Code Climate](https://codeclimate.com/github/nukturnal/bygpay/badges/gpa.svg)](https://codeclimate.com/github/nukturnal/bygpay)
|
2
|
+
|
1
3
|
# Bygpay
|
2
4
|
|
3
5
|
Ruby wrapper around Bygpay Payment Gateway. Bygpay is a self hosted payment processing gateway which gives merchants / business better flexiblity and control when it comes to payment processing.
|
@@ -27,11 +29,95 @@ Bygpay.configure do |config|
|
|
27
29
|
config.base_url = 'http://gateway.bygpay-server.com/api'
|
28
30
|
config.api_key = '8b4e5a9c-6eba-4cdd-94b6-65e6b514'
|
29
31
|
|
30
|
-
# Optional Configurations
|
32
|
+
# Optional Configurations (Every code below this line)
|
31
33
|
# (In case you've changed routes in your Bygpay Installation)
|
32
|
-
config.
|
33
|
-
config.
|
34
|
+
config.deposit_mobile_path = '/deposits/mobile'
|
35
|
+
config.deposit_status_overide_path = '/deposits/status-overide'
|
34
36
|
config.deposit_status_path = '/deposits'
|
37
|
+
|
38
|
+
config.withdraw_mobile_path = '/withdrawals/mobile'
|
39
|
+
config.withdraw_status_overide_path = '/withdrawals/status-overide'
|
40
|
+
config.withdraw_status_path = '/withdrawals'
|
41
|
+
end
|
42
|
+
```
|
43
|
+
|
44
|
+
## Transaction Statuses
|
45
|
+
|
46
|
+
Bygpay gateway uses four types of status messages to mark transactions.
|
47
|
+
* `accepted` A transaction is marked as `accepted` when it's initially receives the request from a client
|
48
|
+
* `pending` A transaction is marked a `pending` when the Gateway begins processing
|
49
|
+
* `success` A final status message `success` is used when processing completes successfully
|
50
|
+
* `fail` A final status message `fail' is used when the processing completes unsuccessfully
|
51
|
+
|
52
|
+
## Deposit Requests
|
53
|
+
|
54
|
+
#### Mobile Money
|
55
|
+
|
56
|
+
Currently SDK supports MTN, AIRTEL, TIGO, VODAFONE, you may refer to your Bygpay Gateway documentations for more provider options.
|
57
|
+
|
58
|
+
```ruby
|
59
|
+
# Making a Mobile Money Deposit Request
|
60
|
+
deposit = Bygpay::Deposit::Mobile.new
|
61
|
+
result = deposit.charge(1.99,{walletno: '0244124550', provider: 'MTN'})
|
62
|
+
if result
|
63
|
+
puts deposit.uuid
|
64
|
+
puts deposit.status # accepted, :pending, :fail, :success
|
65
|
+
puts deposit.transaction_id
|
66
|
+
else
|
67
|
+
puts deposit.response_text
|
68
|
+
puts deposit.status
|
69
|
+
end
|
70
|
+
```
|
71
|
+
|
72
|
+
Query Transaction status
|
73
|
+
```ruby
|
74
|
+
# Checking transaction status
|
75
|
+
# You always need the transaction UUID to get status response
|
76
|
+
deposit = Bygpay::Deposit::Mobile.new
|
77
|
+
result = deposit.transaction_status('e81216aa-9ef7-4c5c-aed0-6e5ff1fe')
|
78
|
+
if result
|
79
|
+
puts deposit.uuid
|
80
|
+
puts deposit.status # accepted, :pending, :fail, :success
|
81
|
+
puts deposit.transaction_id
|
82
|
+
else
|
83
|
+
puts deposit.response_text
|
84
|
+
puts deposit.status
|
85
|
+
end
|
86
|
+
```
|
87
|
+
|
88
|
+
## Withdraw Requests
|
89
|
+
|
90
|
+
#### Mobile Money
|
91
|
+
|
92
|
+
Currently SDK supports MTN, AIRTEL, TIGO, VODAFONE, you may refer to your Bygpay Gateway documentations for more provider options.
|
93
|
+
|
94
|
+
```ruby
|
95
|
+
# Making a Mobile Money Withdrawal Request
|
96
|
+
withdraw = Bygpay::Withdraw::Mobile.new
|
97
|
+
result = withdraw.send(1.99,{walletno: '0244124550', provider: 'MTN'})
|
98
|
+
if result
|
99
|
+
puts withdraw.uuid
|
100
|
+
puts withdraw.status # accepted, :pending, :fail, :success
|
101
|
+
puts withdraw.transaction_id
|
102
|
+
else
|
103
|
+
puts withdraw.response_text
|
104
|
+
puts withdraw.status
|
105
|
+
end
|
106
|
+
```
|
107
|
+
|
108
|
+
Query Transaction status
|
109
|
+
```ruby
|
110
|
+
# Checking transaction status
|
111
|
+
# You always need the transaction UUID to get status response
|
112
|
+
withdraw = Bygpay::Withdraw::Mobile.new
|
113
|
+
result = withdraw.transaction_status('e81216aa-9ef7-4c5c-aed0-6e5ff1fe')
|
114
|
+
if result
|
115
|
+
puts withdraw.uuid
|
116
|
+
puts withdraw.status # accepted, :pending, :fail, :success
|
117
|
+
puts withdraw.transaction_id
|
118
|
+
else
|
119
|
+
puts withdraw.response_text
|
120
|
+
puts withdraw.status
|
35
121
|
end
|
36
122
|
```
|
37
123
|
|
@@ -43,7 +129,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
43
129
|
|
44
130
|
## Contributing
|
45
131
|
|
46
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
132
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/nukturnal/bygpay. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
47
133
|
|
48
134
|
|
49
135
|
## License
|
data/lib/bygpay/configuration.rb
CHANGED
@@ -1,16 +1,21 @@
|
|
1
1
|
module Bygpay
|
2
2
|
class Configuration
|
3
3
|
attr_accessor :base_url, :api_key,
|
4
|
-
:
|
4
|
+
:deposit_mobile_path, :deposit_status_overide_path, :deposit_status_path,
|
5
|
+
:withdraw_mobile_path, :withdraw_status_overide_path, :withdraw_status_path
|
5
6
|
|
6
7
|
def initialize
|
7
8
|
@base_url = nil
|
8
9
|
@api_key = nil
|
9
10
|
|
10
11
|
# Preset default paths but allow for changes
|
11
|
-
@
|
12
|
-
@
|
12
|
+
@deposit_mobile_path = '/deposits/mobile'
|
13
|
+
@deposit_status_overide_path = '/deposits/status-overide'
|
13
14
|
@deposit_status_path = '/deposits'
|
15
|
+
|
16
|
+
@withdraw_mobile_path = '/withdrawals/mobile'
|
17
|
+
@withdraw_status_overide_path = '/withdrawals/status-overide'
|
18
|
+
@withdraw_status_path = '/withdrawals'
|
14
19
|
end
|
15
20
|
end
|
16
21
|
end
|
@@ -4,7 +4,6 @@ module Bygpay
|
|
4
4
|
|
5
5
|
# {
|
6
6
|
# "walletno" : "0276967627",
|
7
|
-
# "amount": 0.10,
|
8
7
|
# "provider": "TIGO",
|
9
8
|
# "extrnx_code": null
|
10
9
|
# }
|
@@ -15,7 +14,7 @@ module Bygpay
|
|
15
14
|
|
16
15
|
# Return deposit transaction status
|
17
16
|
def transaction_status(uuid)
|
18
|
-
get_status(
|
17
|
+
get_status(deposit_status_endpoint,uuid)
|
19
18
|
end
|
20
19
|
|
21
20
|
end
|
data/lib/bygpay/utils.rb
CHANGED
@@ -8,17 +8,28 @@ module Bygpay
|
|
8
8
|
|
9
9
|
# Mobile Deposit transactions endpoint
|
10
10
|
def mobile_deposit_endpoint
|
11
|
-
Bygpay.configuration.
|
11
|
+
Bygpay.configuration.deposit_mobile_path
|
12
12
|
end
|
13
13
|
|
14
14
|
# Deposit transactions status check endpoint
|
15
|
-
def
|
15
|
+
def deposit_status_endpoint
|
16
16
|
Bygpay.configuration.deposit_status_path
|
17
17
|
end
|
18
18
|
|
19
|
+
# Mobile Withdrawal transactions endpoint
|
20
|
+
def mobile_withdraw_endpoint
|
21
|
+
Bygpay.configuration.withdraw_mobile_path
|
22
|
+
end
|
23
|
+
|
24
|
+
# Withdraw transactions status check endpoint
|
25
|
+
def withdraw_status_endpoint
|
26
|
+
Bygpay.configuration.withdraw_status_path
|
27
|
+
end
|
28
|
+
|
19
29
|
# Post payload
|
20
30
|
def post(endpoint, payload = {})
|
21
31
|
url = "#{Bygpay.configuration.base_url}#{endpoint}"
|
32
|
+
puts "URL: #{url}"
|
22
33
|
result = http_connect.post(url, json: payload)
|
23
34
|
|
24
35
|
parse_response(result.body)
|
@@ -34,6 +45,7 @@ module Bygpay
|
|
34
45
|
|
35
46
|
# {
|
36
47
|
# "status": "success",
|
48
|
+
# "message": "Some messages",
|
37
49
|
# "data": {
|
38
50
|
# "uuid": "d1f3395e-ea08-4599-b8a5-41f5e7a4",
|
39
51
|
# "status": "accepted",
|
data/lib/bygpay/version.rb
CHANGED
@@ -0,0 +1,22 @@
|
|
1
|
+
module Bygpay
|
2
|
+
module Withdraw
|
3
|
+
class Mobile < Bygpay::Withdrawals
|
4
|
+
|
5
|
+
# {
|
6
|
+
# "walletno" : "0276967627",
|
7
|
+
# "provider": "TIGO",
|
8
|
+
# "extrnx_code": null
|
9
|
+
# }
|
10
|
+
# Perform a mobile deposit request
|
11
|
+
def send(amount, payload ={})
|
12
|
+
post(mobile_withdraw_endpoint, payload.merge({amount: amount}))
|
13
|
+
end
|
14
|
+
|
15
|
+
# Return deposit transaction status
|
16
|
+
def transaction_status(uuid)
|
17
|
+
get_status(withdraw_status_endpoint,uuid)
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
data/lib/bygpay.rb
CHANGED
@@ -3,11 +3,10 @@ require 'bygpay/configuration'
|
|
3
3
|
require 'bygpay/utils'
|
4
4
|
require 'bygpay/deposits'
|
5
5
|
require 'bygpay/deposit/mobile'
|
6
|
+
require 'bygpay/withdrawals'
|
7
|
+
require 'bygpay/withdraw/mobile'
|
6
8
|
|
7
9
|
module Bygpay
|
8
|
-
SUCCESS = 'success'
|
9
|
-
FAIL = 'fail'
|
10
|
-
PENDING = 'pending'
|
11
10
|
|
12
11
|
class << self
|
13
12
|
attr_accessor :configuration
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bygpay
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alfred Rowe
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-06-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -76,6 +76,7 @@ files:
|
|
76
76
|
- ".gitignore"
|
77
77
|
- ".rspec"
|
78
78
|
- ".travis.yml"
|
79
|
+
- CHANGELOG.md
|
79
80
|
- CODE_OF_CONDUCT.md
|
80
81
|
- Gemfile
|
81
82
|
- LICENSE.txt
|
@@ -90,6 +91,8 @@ files:
|
|
90
91
|
- lib/bygpay/deposits.rb
|
91
92
|
- lib/bygpay/utils.rb
|
92
93
|
- lib/bygpay/version.rb
|
94
|
+
- lib/bygpay/withdraw/mobile.rb
|
95
|
+
- lib/bygpay/withdrawals.rb
|
93
96
|
homepage: https://github.com/nukturnal/bygpay
|
94
97
|
licenses:
|
95
98
|
- MIT
|