globalpay_ruby_gem 0.1.0 → 1.0.0
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 +1 -1
- data/lib/globalpay_ruby_gem/helpers/const.rb +4 -2
- data/lib/globalpay_ruby_gem/version.rb +1 -1
- data/lib/globalpay_ruby_gem.rb +32 -14
- 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: 27c87a0f722dbba0502a9a14b4e4c5c2b7bc0575
|
4
|
+
data.tar.gz: ad37554b83d560e55c557d756ffbee331096a18d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3d0938a9b2342156ecd5e2e647e61ca0215170071f1c6989c0f53bf49edfa1afa7f414ac51cc0f036299c73aed5533176ddc878ae644f3d1796e8ada256a4909
|
7
|
+
data.tar.gz: 80d94d79fc812c822371f83b566f3fa1c941475252add353c763526a0fd8b487fe36c68e851e81ddcae3ee80dffc3e579af14efc6af4e48b0ff534af9c74de24
|
data/README.md
CHANGED
@@ -29,7 +29,7 @@ Or install it yourself as:
|
|
29
29
|
* 5. Validate the result by using the Retrieve transaction call
|
30
30
|
|
31
31
|
### Client Authentication
|
32
|
-
globalpay_ruby_gem.authenticate(
|
32
|
+
globalpay_ruby_gem.authenticate(client_id,client_secret)
|
33
33
|
|
34
34
|
### Transaction Initialization
|
35
35
|
response = globalpay_ruby_gem.initialize(access_token,returnurl,merchantreference,description,currencycode,totalamount,customer)
|
@@ -1,4 +1,6 @@
|
|
1
1
|
module Const
|
2
|
-
|
3
|
-
|
2
|
+
BASE_URL_LIVE = 'https://globalpay.azurewebsites.net'
|
3
|
+
BASE_URL_STAGING = 'https://globalpay.azurewebsites.net'
|
4
|
+
TOKEN_URL_LIVE ='http://globalpayauthserver.azurewebsites.net/connect/token'
|
5
|
+
TOKEN_URL_STAGING ='http://globalpayauthserver.azurewebsites.net/connect/token'
|
4
6
|
end
|
data/lib/globalpay_ruby_gem.rb
CHANGED
@@ -9,7 +9,7 @@ module GlobalpayRubyGem
|
|
9
9
|
|
10
10
|
def authentication(*args)
|
11
11
|
if args.size == 4
|
12
|
-
GlobalpayRubyGem.authenticate_client(args[0],args[1])
|
12
|
+
GlobalpayRubyGem.authenticate_client(args[0],args[1],args[2])
|
13
13
|
else
|
14
14
|
response = "{'error':'parameters miss match, expecting 4 paramters'}"
|
15
15
|
end
|
@@ -17,7 +17,7 @@ module GlobalpayRubyGem
|
|
17
17
|
|
18
18
|
def initialize(*args)
|
19
19
|
if args.size == 7
|
20
|
-
GlobalpayRubyGem.initialize_transaction(args[0],args[1],args[2],args[3],args[4],args[5],args[6])
|
20
|
+
GlobalpayRubyGem.initialize_transaction(args[0],args[1],args[2],args[3],args[4],args[5],args[6],args[7],args[8],args[9],args[10])
|
21
21
|
else
|
22
22
|
response = "{'error':'parameters miss match, expecting 7 paramters'}"
|
23
23
|
end
|
@@ -25,18 +25,24 @@ module GlobalpayRubyGem
|
|
25
25
|
|
26
26
|
def retrieve(*args)
|
27
27
|
if args.size == 4
|
28
|
-
GlobalpayRubyGem.retrieve_transaction(args[0],args[1],args[2],args[3])
|
28
|
+
GlobalpayRubyGem.retrieve_transaction(args[0],args[1],args[2],args[3],args[4])
|
29
29
|
else
|
30
30
|
response = "{'error':'parameters miss match, expecting 4 paramters'}"
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
34
|
|
35
|
-
def authenticate_client(client_id,client_secret)
|
35
|
+
def authenticate_client(client_id,client_secret,is_live)
|
36
36
|
http = HTTPClient.new
|
37
|
-
body =
|
38
|
-
|
39
|
-
|
37
|
+
body = 'client_id='+client_id+'&client_secret='+client_secret+'grant_type=client_credentials'
|
38
|
+
header = { 'Content-Type' => 'application/x-www-form-urlencoded'}
|
39
|
+
|
40
|
+
if is_live == "True"
|
41
|
+
res = http.post(TOKEN_URL_LIVE, body)
|
42
|
+
else
|
43
|
+
res = http.post(TOKEN_URL_STAGING, body)
|
44
|
+
end
|
45
|
+
|
40
46
|
if res.successful?(res.status)
|
41
47
|
res.body
|
42
48
|
else
|
@@ -44,13 +50,19 @@ module GlobalpayRubyGem
|
|
44
50
|
end
|
45
51
|
end
|
46
52
|
|
47
|
-
def initialize_transaction(access_token,returnurl,merchantreference,description,currencycode,totalamount,
|
53
|
+
def initialize_transaction(access_token,returnurl,merchantreference,merchantid,description,currencycode,totalamount,customeremail,customernumber,customerfirstname,customerlastname)
|
48
54
|
http = HTTPClient.new
|
49
|
-
body = { 'returnurl' => returnurl, 'merchantreference' => merchantreference, 'description' => description,
|
50
|
-
'currencycode' => currencycode, 'totalamount' => totalamount, 'customer' =>
|
51
|
-
'
|
55
|
+
body = { 'returnurl' => returnurl,'customerip' => '', 'merchantreference' => merchantreference, 'merchantid' => merchantid, 'description' => description,
|
56
|
+
'currencycode' => currencycode, 'totalamount' => totalamount, 'customer' => { 'email' => customeremail,'firstname' => customerfirstname, 'lastname' => customerlastname, 'mobile' => customernumber },
|
57
|
+
'paymentmethod' => 'card','transactionType' => 'Payment', 'connectionmode' => 'redirect', 'product' => [{'name' => description, 'unitprice' => totalamount,'quantity' => '1'}]}
|
52
58
|
header = { 'Content-Type' => 'application/json', 'Authorization' => "Bearer #{access_token}"}
|
53
|
-
|
59
|
+
|
60
|
+
if is_live == "True"
|
61
|
+
res = http.post(BASE_URL_LIVE + '/api/v3/Payment/SetRequest', body,header)
|
62
|
+
else
|
63
|
+
res = http.post(BASE_URL_STAGING + '/api/v3/Payment/SetRequest', body,header)
|
64
|
+
end
|
65
|
+
|
54
66
|
if res.successful?(res.status)
|
55
67
|
res.body
|
56
68
|
else
|
@@ -58,11 +70,17 @@ module GlobalpayRubyGem
|
|
58
70
|
end
|
59
71
|
end
|
60
72
|
|
61
|
-
def retrieve_transaction(access_token,merchantid,merchantreference,transactionrequest)
|
73
|
+
def retrieve_transaction(access_token,merchantid,merchantreference,transactionrequest,islive)
|
62
74
|
http = HTTPClient.new
|
63
75
|
body = { 'merchantId' => merchantid, 'merchantreference' => merchantreference, 'transactionRequest' => transactionrequest}
|
64
76
|
header = { 'Content-Type' => 'application/json', 'Authorization' => "Bearer #{access_token}"}
|
65
|
-
|
77
|
+
|
78
|
+
if is_live == "True"
|
79
|
+
res = http.post(BASE_URL_LIVE + '/api/v3/Payment/Retrieve', body,header)
|
80
|
+
else
|
81
|
+
res = http.post(BASE_URL_STAGING + '/api/v3/Payment/Retrieve', body,header)
|
82
|
+
end
|
83
|
+
|
66
84
|
if res.successful?(res.status)
|
67
85
|
res.body
|
68
86
|
else
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: globalpay_ruby_gem
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Codegidi
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-06-
|
11
|
+
date: 2018-06-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|