gladepay 0.1.4 → 0.1.5
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/README.md +5 -5
- data/lib/gladepay.rb +16 -16
- data/lib/gladepay/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1ebcc5dec54974f3aa502ec3c2eb8b75261bdf2e
|
4
|
+
data.tar.gz: 27969552954f751bfc52476f99e66e2220001fc1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3e7c6706a3c725a1c3ab9fab6b2f5284a401ef310b67b2c40263c12963ed9ef540f3c285c9b755ba0b5bef6fa6290b0150e6148123242c44dc3efe69841ed8b0
|
7
|
+
data.tar.gz: a1d95b38e8bbba91d3d2b39f54714bfc48990eaa9b5c0855af8cfe21b0bd2239cbce1ff85fa99ab0b7dc48ffed52b90d61929f854ce447c14adce182ffe93848
|
data/README.md
CHANGED
@@ -51,17 +51,17 @@ Or install it yourself as:
|
|
51
51
|
'currency' => 'NGN'
|
52
52
|
}
|
53
53
|
|
54
|
-
@
|
55
|
-
@
|
54
|
+
@merchant_id = "GP0000001" #Test Data
|
55
|
+
@merchant_key = "123456789"
|
56
56
|
live = true #for live server, default false for test server
|
57
57
|
|
58
58
|
# Demp or Test Server Instance
|
59
|
-
gladepay = Gladepay.new(@
|
59
|
+
gladepay = Gladepay.new(@merchant_id, @merchant_key) # Or
|
60
60
|
|
61
|
-
# gladepay = Gladepay.new(@
|
61
|
+
# gladepay = Gladepay.new(@merchant_id, @merchant_key, false)
|
62
62
|
|
63
63
|
#LIVE SERVER Instance
|
64
|
-
# gladepay = Gladepay.new(@
|
64
|
+
# gladepay = Gladepay.new(@merchant_id, @merchant_key, true) #for live server
|
65
65
|
|
66
66
|
#Get Response
|
67
67
|
response = gladepay.card_payment(
|
data/lib/gladepay.rb
CHANGED
@@ -9,21 +9,21 @@ require 'json'
|
|
9
9
|
class Gladepay
|
10
10
|
include Api
|
11
11
|
|
12
|
-
attr_reader :
|
12
|
+
attr_reader :merchant_id, :merchant_key, :base_url, :live
|
13
|
+
|
14
|
+
def initialize(merchant_id = nil, merchant_key = nil, live = false)
|
15
|
+
@merchant_id = if merchant_id.nil?
|
16
|
+
ENV['merchant_id']
|
17
|
+
else
|
18
|
+
merchant_id
|
19
|
+
end
|
13
20
|
|
14
|
-
def initialize(merchant_key = nil, merchant_secret = nil, live = false)
|
15
21
|
@merchant_key = if merchant_key.nil?
|
16
|
-
ENV['
|
22
|
+
ENV['merchant_key']
|
17
23
|
else
|
18
24
|
merchant_key
|
19
25
|
end
|
20
26
|
|
21
|
-
@merchant_secret = if merchant_secret.nil?
|
22
|
-
ENV['MERCHANT_SECRET']
|
23
|
-
else
|
24
|
-
merchant_secret
|
25
|
-
end
|
26
|
-
|
27
27
|
@live = live
|
28
28
|
|
29
29
|
@base_url = if @live
|
@@ -32,17 +32,17 @@ class Gladepay
|
|
32
32
|
DEMO_BASE_URL
|
33
33
|
end
|
34
34
|
|
35
|
-
if @
|
36
|
-
raise GladepayBadKeyError, 'No merchant
|
35
|
+
if @merchant_id.nil?
|
36
|
+
raise GladepayBadKeyError, 'No merchant Id supplied and couldn\'t find any in environment variables. Make sure to set merchant Id as an environment variable merchant_id'
|
37
37
|
end
|
38
38
|
|
39
|
-
raise GladepayBadKeyError, "Invalid merchant key #{@
|
39
|
+
raise GladepayBadKeyError, "Invalid merchant key #{@merchant_id}" unless @merchant_id[0..1] == 'GP'
|
40
40
|
|
41
|
-
if @
|
42
|
-
raise GladepayBadKeyError, 'No merchant
|
41
|
+
if @merchant_key.nil?
|
42
|
+
raise GladepayBadKeyError, 'No merchant key supplied and couldn\'t find any in environment variables. Make sure to set the merchant key as an environment variable merchant_key'
|
43
43
|
end
|
44
44
|
|
45
|
-
raise GladepayBadKeyError, "Invalid merchant
|
45
|
+
raise GladepayBadKeyError, "Invalid merchant key #{@merchant_key}" unless @merchant_key.to_i.to_s == @merchant_key
|
46
46
|
|
47
47
|
raise GladepayBadKeyError, 'Invalid BaseUrl Must SPECIFY LIVE or DEMO server' if @base_url.nil? && !@base_url.is_a?(TrueClass)
|
48
48
|
end
|
@@ -288,7 +288,7 @@ class Gladepay
|
|
288
288
|
begin
|
289
289
|
jdata = JSON.generate(data)
|
290
290
|
base_url_with_method = current_base_url + '/' + api_method
|
291
|
-
response = RestClient.put base_url_with_method, jdata, content_type: :json, accept: :json, key: @
|
291
|
+
response = RestClient.put base_url_with_method, jdata, content_type: :json, accept: :json, key: @merchant_key, mid: @merchant_id
|
292
292
|
|
293
293
|
unless response.code == 200 || response.code == 201
|
294
294
|
raise GladepayServerError.new(response), 'HTTP Code ' + response.code.to_s + ': ' + response.body.to_s
|
data/lib/gladepay/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gladepay
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chinaka Light
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-10-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|