bygpay 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -1
- data/README.md +1 -1
- data/bygpay.gemspec +1 -0
- data/lib/bygpay/byg_response.rb +77 -0
- data/lib/bygpay/configuration.rb +3 -1
- data/lib/bygpay/deposit/card.rb +21 -0
- data/lib/bygpay/deposit/mobile.rb +2 -8
- data/lib/bygpay/deposits.rb +4 -0
- data/lib/bygpay/utils.rb +14 -24
- data/lib/bygpay/version.rb +1 -1
- data/lib/bygpay.rb +2 -0
- metadata +18 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4dbbb7c0fc6bd86ab7308612d53253225cd1a99e
|
4
|
+
data.tar.gz: 6bfbd8cf31e41ec241dcf47c1cf65f4a4ad96a5f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 67aef33499c381da810352387eea781ba522fa20a0a3c02b3be50067923ab7f966c63e27732647f1f0537b350cf4314b8267a6213b922a5a49fb12ed7a861a55
|
7
|
+
data.tar.gz: 742a5738f22ffd2d9e6a4e1f1959f3e71fcdaf2bfa742c5901c20d7512bb1ae111e0fbd57af2aec7a3b0ee4344a94569ff26751eccc2054597b720fae1feb4ef
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
[![Code Climate](https://codeclimate.com/github/nukturnal/bygpay/badges/gpa.svg)](https://codeclimate.com/github/nukturnal/bygpay) [![codebeat badge](https://codebeat.co/badges/8db86406-18f8-4c2d-bacf-58ac1c700c0a)](https://codebeat.co/projects/github-com-nukturnal-bygpay-master)
|
1
|
+
[![Gem Version](https://badge.fury.io/rb/bygpay.svg)](https://badge.fury.io/rb/bygpay) [![Code Climate](https://codeclimate.com/github/nukturnal/bygpay/badges/gpa.svg)](https://codeclimate.com/github/nukturnal/bygpay) [![codebeat badge](https://codebeat.co/badges/8db86406-18f8-4c2d-bacf-58ac1c700c0a)](https://codebeat.co/projects/github-com-nukturnal-bygpay-master)
|
2
2
|
|
3
3
|
# Bygpay Ruby SDK
|
4
4
|
|
data/bygpay.gemspec
CHANGED
@@ -0,0 +1,77 @@
|
|
1
|
+
module Bygpay
|
2
|
+
class BygResponse
|
3
|
+
SUCCESS = 'success'
|
4
|
+
FAILED = 'fail'
|
5
|
+
PENDING = ['accepted','pending']
|
6
|
+
|
7
|
+
attr_accessor :data
|
8
|
+
|
9
|
+
def initialize(hash = {})
|
10
|
+
@data = Hashie::Mash.new(hash)
|
11
|
+
end
|
12
|
+
|
13
|
+
# Check if Bygpay Gateway processed requests without any issues
|
14
|
+
def request_successful?
|
15
|
+
data.status == SUCCESS
|
16
|
+
end
|
17
|
+
|
18
|
+
def success?
|
19
|
+
data.data.status == SUCCESS
|
20
|
+
end
|
21
|
+
|
22
|
+
def failed?
|
23
|
+
data.data.status == FAILED
|
24
|
+
end
|
25
|
+
|
26
|
+
def pending?
|
27
|
+
PENDING.include?(data.data.status)
|
28
|
+
end
|
29
|
+
|
30
|
+
def transaction_id
|
31
|
+
data.data.trnx_code
|
32
|
+
end
|
33
|
+
|
34
|
+
def processor_transaction_id
|
35
|
+
data.data.provider_txid
|
36
|
+
end
|
37
|
+
|
38
|
+
def transaction_status
|
39
|
+
data.data.status
|
40
|
+
end
|
41
|
+
|
42
|
+
def currency
|
43
|
+
data.data.currency
|
44
|
+
end
|
45
|
+
|
46
|
+
def amount
|
47
|
+
data.data.amount
|
48
|
+
end
|
49
|
+
|
50
|
+
def provider
|
51
|
+
data.data.provider
|
52
|
+
end
|
53
|
+
|
54
|
+
# Hash strucuture
|
55
|
+
# {
|
56
|
+
# "status": "success",
|
57
|
+
# "message": "Some messages",
|
58
|
+
# "data": {
|
59
|
+
# "uuid": "d1f3395e-ea08-4599-b8a5-41f5e7a4",
|
60
|
+
# "status": "accepted",
|
61
|
+
# "currency": "GHS",
|
62
|
+
# "trnx_code": "DTX00000008",
|
63
|
+
# "provider_txid": null,
|
64
|
+
# "extrnx_code": null,
|
65
|
+
# "walletno": "0276967627",
|
66
|
+
# "amount": 0.1,
|
67
|
+
# "provider": "TIGO"
|
68
|
+
# }
|
69
|
+
# }
|
70
|
+
# This may throw JSON::ParserError if the json_payload is not valid JSON.
|
71
|
+
def self.parse_response(json_payload)
|
72
|
+
data = JSON.parse(json_payload, symbolize_names: true)
|
73
|
+
resp = BygResponse.new(data)
|
74
|
+
resp
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
data/lib/bygpay/configuration.rb
CHANGED
@@ -2,7 +2,8 @@ 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
|
+
:withdraw_mobile_path, :withdraw_status_overide_path, :withdraw_status_path,
|
6
|
+
:deposit_card_path
|
6
7
|
|
7
8
|
def initialize
|
8
9
|
@base_url = nil
|
@@ -10,6 +11,7 @@ module Bygpay
|
|
10
11
|
|
11
12
|
# Preset default paths but allow for changes
|
12
13
|
@deposit_mobile_path = '/deposits/mobile'
|
14
|
+
@deposit_card_path = '/deposits/card'
|
13
15
|
@deposit_status_overide_path = '/deposits/status-overide'
|
14
16
|
@deposit_status_path = '/deposits'
|
15
17
|
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Bygpay
|
2
|
+
module Deposit
|
3
|
+
class Card < Bygpay::Deposits
|
4
|
+
|
5
|
+
# {
|
6
|
+
# "card_number" : "4111111111111111",
|
7
|
+
# "amount": 1.00,
|
8
|
+
# "expiry_month": 6,
|
9
|
+
# "expiry_year": 2017,
|
10
|
+
# "cvv": 618,
|
11
|
+
# "country": "GH",
|
12
|
+
# "currency": "GHS"
|
13
|
+
# }
|
14
|
+
# Perform a Bankcard debit request
|
15
|
+
def charge(amount, card_data = {})
|
16
|
+
post(card_deposit_endpoint, card_data.merge({amount: amount}))
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -8,15 +8,9 @@ module Bygpay
|
|
8
8
|
# "extrnx_code": null
|
9
9
|
# }
|
10
10
|
# Perform a mobile deposit request
|
11
|
-
def charge(amount,
|
12
|
-
post(mobile_deposit_endpoint,
|
11
|
+
def charge(amount, mobile_data = {})
|
12
|
+
post(mobile_deposit_endpoint, mobile_data.merge({amount: amount}))
|
13
13
|
end
|
14
|
-
|
15
|
-
# Return deposit transaction status
|
16
|
-
def transaction_status(uuid)
|
17
|
-
get_status(deposit_status_endpoint,uuid)
|
18
|
-
end
|
19
|
-
|
20
14
|
end
|
21
15
|
end
|
22
16
|
end
|
data/lib/bygpay/deposits.rb
CHANGED
data/lib/bygpay/utils.rb
CHANGED
@@ -2,8 +2,6 @@ require 'http'
|
|
2
2
|
|
3
3
|
module Bygpay
|
4
4
|
module Utils
|
5
|
-
extend self
|
6
|
-
|
7
5
|
attr_accessor :status, :response_text, :transaction_id,
|
8
6
|
:uuid, :result, :response
|
9
7
|
|
@@ -12,6 +10,11 @@ module Bygpay
|
|
12
10
|
Bygpay.configuration.deposit_mobile_path
|
13
11
|
end
|
14
12
|
|
13
|
+
# Mobile Deposit transactions endpoint
|
14
|
+
def card_deposit_endpoint
|
15
|
+
Bygpay.configuration.deposit_card_path
|
16
|
+
end
|
17
|
+
|
15
18
|
# Deposit transactions status check endpoint
|
16
19
|
def deposit_status_endpoint
|
17
20
|
Bygpay.configuration.deposit_status_path
|
@@ -30,7 +33,6 @@ module Bygpay
|
|
30
33
|
# Post payload
|
31
34
|
def post(endpoint, payload = {})
|
32
35
|
url = "#{Bygpay.configuration.base_url}#{endpoint}"
|
33
|
-
puts "URL: #{url}"
|
34
36
|
result = http_connect.post(url, json: payload)
|
35
37
|
|
36
38
|
parse_response(result.body)
|
@@ -44,27 +46,15 @@ module Bygpay
|
|
44
46
|
parse_response(result.body)
|
45
47
|
end
|
46
48
|
|
47
|
-
#
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
# "walletno": "0276967627",
|
57
|
-
# "amount": 0.1,
|
58
|
-
# "provider": "TIGO"
|
59
|
-
# }
|
60
|
-
# }
|
61
|
-
def parse_response(body)
|
62
|
-
@result = JSON.parse(body)
|
63
|
-
@transaction_id = @result['data']['trnx_code']
|
64
|
-
@response_text = @result['message']
|
65
|
-
@uuid = @result['data']['uuid']
|
66
|
-
@status = @result['data']['status']
|
67
|
-
@response = @result['status'] == 'success'
|
49
|
+
# Parse on JSON Body to BygResponse for parsing and processing
|
50
|
+
def parse_response(json_payload)
|
51
|
+
@response = Bygpay::BygResponse.parse_response(json_payload)
|
52
|
+
resp = @response.data
|
53
|
+
@transaction_id = resp.data.trnx_code
|
54
|
+
@response_text = resp.message
|
55
|
+
@uuid = resp.data.uuid
|
56
|
+
@status = @response.transaction_status
|
57
|
+
@result = @response.request_successful?
|
68
58
|
end
|
69
59
|
|
70
60
|
# global Bygpay connect
|
data/lib/bygpay/version.rb
CHANGED
data/lib/bygpay.rb
CHANGED
@@ -1,8 +1,10 @@
|
|
1
1
|
require 'bygpay/version'
|
2
2
|
require 'bygpay/configuration'
|
3
|
+
require 'bygpay/byg_response'
|
3
4
|
require 'bygpay/utils'
|
4
5
|
require 'bygpay/deposits'
|
5
6
|
require 'bygpay/deposit/mobile'
|
7
|
+
require 'bygpay/deposit/card'
|
6
8
|
require 'bygpay/withdrawals'
|
7
9
|
require 'bygpay/withdraw/mobile'
|
8
10
|
|
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.2.
|
4
|
+
version: 0.2.2
|
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-06-
|
11
|
+
date: 2017-06-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -66,6 +66,20 @@ dependencies:
|
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '2.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: hashie
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 3.5.5
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 3.5.5
|
69
83
|
description: Ruby Wrapper to process payments via any installed Bygpay Payment Gateway
|
70
84
|
email:
|
71
85
|
- alfred@encodevlabs.com
|
@@ -86,7 +100,9 @@ files:
|
|
86
100
|
- bin/setup
|
87
101
|
- bygpay.gemspec
|
88
102
|
- lib/bygpay.rb
|
103
|
+
- lib/bygpay/byg_response.rb
|
89
104
|
- lib/bygpay/configuration.rb
|
105
|
+
- lib/bygpay/deposit/card.rb
|
90
106
|
- lib/bygpay/deposit/mobile.rb
|
91
107
|
- lib/bygpay/deposits.rb
|
92
108
|
- lib/bygpay/utils.rb
|