globalpay_ruby_gem 0.1.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0a5dbe57798a7b0922698d284d317035085f72fd
4
- data.tar.gz: 32f8bae82e57be329dae3ab3b1c7c48f200962f6
3
+ metadata.gz: 27c87a0f722dbba0502a9a14b4e4c5c2b7bc0575
4
+ data.tar.gz: ad37554b83d560e55c557d756ffbee331096a18d
5
5
  SHA512:
6
- metadata.gz: 47ed43086e7f518aef44f580100458fa0ef41e86dc07b630b8a2b70c1fa30c475578fae1d15951a040c51ed31d6a9ce902492d6f925e4175fdbc1b28ec13dd30
7
- data.tar.gz: 07924b517d0e3f2ee5b8e9dfa3752b5ea99f2cb62708b55b8f7dfdb2512a202e37af9e6eea80b1c66e0d481d8964ff84ae7cd84333e53cd88d328b00c9515214
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(username,password,client_id,client_secret)
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
- BASE_URL = 'https://globalpay.azurewebsites.net'
3
- TOKEN_URL ='http://globalpayauthserver.azurewebsites.net/connect/token'
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
@@ -1,3 +1,3 @@
1
1
  module GlobalpayRubyGem
2
- VERSION = "0.1.0"
2
+ VERSION = "1.0.0"
3
3
  end
@@ -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 = { 'username' => username, 'password' => password, 'client_id' => client_id,
38
- 'client_secret' => client_secret, 'grant_type' => 'client_credentials', 'scope' => 'globalpay_api'}
39
- res = http.post(TOKEN_URL, body)
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,customer)
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' => customer,
51
- 'customerip' => '', 'paymentmethod' => 'card','transactionType' => 'Payment', 'connectionmode' => 'redirect'}
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
- res = http.post(BASE_URL + '/api/v3/Payment/SetRequest', body,header)
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
- res = http.post(BASE_URL + '/api/v3/Payment/Retrieve', body,header)
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: 0.1.0
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-21 00:00:00.000000000 Z
11
+ date: 2018-06-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler