polirb 0.1.0 → 0.1.1

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: b395b2a9071719ccdab261c0526c7dd1428ffb99
4
- data.tar.gz: 173276ae595eb78efda264847475c6914e094c89
3
+ metadata.gz: 32b720fb822753c160b1635a1ea3e9d231a7884d
4
+ data.tar.gz: 2f43f959736f53d9aab24ca6d194eb295bd96873
5
5
  SHA512:
6
- metadata.gz: cbf42fe84d6866d77992c39a21eb7500f30153f5a863656c7120d019d407c4433d54ba4f47d5a68aca26aa5f81bcc6c7aecf8a40cbdebda47d7c4a06012ea4cd
7
- data.tar.gz: 1c0366aa9190af66ddf3fab18525f3afc7982f5b609ee48221fe66b80e353a94bef1a57273df8a5eb8c3a11e8dcdb3975c8ba905eb446b37f4777786a36c3c99
6
+ metadata.gz: a19c9f3ee9b9da8ca5b005bccc8b312f95e04e61acc95dc6b7720c4ea8d19c7e86c09faaa32040fdc9dcec76d3e792ae7dae19dbef88f4096fc04112a84f40b4
7
+ data.tar.gz: 00888c567fd9d3bea5db5ada3e57e144397072fdd4b33b951e5238bf157f498e657a02293e47df34a421bcd855077ca48f8c2dc4b9b7809ad9b0cb36548ed6ae
data/README.md CHANGED
@@ -1,8 +1,5 @@
1
1
  # POLIrb
2
-
3
-
4
- ## Description
5
- Unofficial Poli Gem for Ruby
2
+ Unofficial Poli Gem for Ruby. This is VERY MUCH a pre-release; in its current iteration - I've not yet even tested it with an API key from POLi.
6
3
 
7
4
  ## Installation
8
5
  ### Install the gem
@@ -33,7 +30,7 @@ Polirb.configure(
33
30
  )
34
31
 
35
32
  # Get the configuration
36
- Polirb.configuration # => { client_id => 'CLIENT_ID', client_secret => 'CLIENT_SECRET' }
33
+ Polirb.configuration # => { ... }
37
34
 
38
35
  # Reset the configuration
39
36
  Polirb.reset_configuration
@@ -24,14 +24,18 @@ module Polirb
24
24
 
25
25
  end
26
26
 
27
+ def get_transaction(transaction_token)
28
+ get_transaction_response(request(:get, Polirb::Static::GET_TRANSACTION, { "token" => transaction_token } ))
29
+ end
30
+
27
31
  private
28
32
 
29
33
  def initiate_transaction_response(response)
30
- if response.body["Success"] == true
34
+ if response["Success"] == true
31
35
  {
32
36
  :success => true,
33
- :transaction_ref_no => response.body["TransactionRefNo"],
34
- :navigate_url => response.body["NavigateURL"],
37
+ :transaction_ref_no => response["TransactionRefNo"],
38
+ :navigate_url => response["NavigateURL"],
35
39
  }
36
40
  else
37
41
  {
@@ -42,5 +46,25 @@ module Polirb
42
46
  end
43
47
  end
44
48
 
49
+ def get_transaction_response(response)
50
+ if response
51
+ {
52
+ :success => true,
53
+ :currency_code => response["CurrencyCode"],
54
+ :payment_amount => response["PaymentAmount"],
55
+ :amount_paid => response["AmountPaid"],
56
+ :end_date_time => response["EndDateTime"],
57
+ :transaction_status_code => response["TransactionStatusCode"],
58
+ :error_code => response["ErrorCode"],
59
+ :merchant_reference => response["MerchantReference"],
60
+ :merchant_data => response["MerchantData"],
61
+ }
62
+ else
63
+ {
64
+ :success => false,
65
+ }
66
+ end
67
+ end
68
+
45
69
  end
46
70
  end
@@ -31,7 +31,6 @@ module Polirb
31
31
  'Authorization' => "Basic #{basic_auth(@merchant_code,@authentication_code)}"
32
32
  }
33
33
 
34
- # TODO(maros): Get the `RestClient::Request.execute` API to work.
35
34
  if http_method == :get
36
35
  RestClient.get("#{url}?#{params}", headers)
37
36
  else
data/lib/polirb/static.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  module Polirb
2
2
  module Static
3
- INITIATE_TRANSACTION = "https://poliapi.apac.paywithpoli.com/api/v2/Transaction/Initiate"
3
+ INITIATE_TRANSACTION = "https://poliapi.apac.paywithpoli.com/api/v2/Transaction/Initiate"
4
+ GET_TRANSACTION = "https://poliapi.apac.paywithpoli.com/api/v2/Transaction/GetTransaction"
4
5
  end
5
6
  end
@@ -1,5 +1,5 @@
1
1
  module Polirb
2
2
  unless defined?(Polirb::VERSION)
3
- VERSION = '0.1.0'
3
+ VERSION = '0.1.1'
4
4
  end
5
5
  end
data/polirb.gemspec CHANGED
@@ -12,6 +12,7 @@ Gem::Specification.new do |s|
12
12
 
13
13
  s.add_development_dependency 'rspec', '~> 3.4'
14
14
  s.add_development_dependency 'webmock', '~> 2.1'
15
+ s.add_development_dependency 'pry-byebug', '~> 3.1', '>= 3.1.0'
15
16
 
16
17
  s.add_runtime_dependency 'json', '~> 2.0'
17
18
  s.add_runtime_dependency 'rest-client', '~> 2.0'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: polirb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeremy Tennant
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-11-22 00:00:00.000000000 Z
11
+ date: 2017-02-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -38,6 +38,26 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '2.1'
41
+ - !ruby/object:Gem::Dependency
42
+ name: pry-byebug
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.1'
48
+ - - ">="
49
+ - !ruby/object:Gem::Version
50
+ version: 3.1.0
51
+ type: :development
52
+ prerelease: false
53
+ version_requirements: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - "~>"
56
+ - !ruby/object:Gem::Version
57
+ version: '3.1'
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: 3.1.0
41
61
  - !ruby/object:Gem::Dependency
42
62
  name: json
43
63
  requirement: !ruby/object:Gem::Requirement