polirb 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: b395b2a9071719ccdab261c0526c7dd1428ffb99
4
+ data.tar.gz: 173276ae595eb78efda264847475c6914e094c89
5
+ SHA512:
6
+ metadata.gz: cbf42fe84d6866d77992c39a21eb7500f30153f5a863656c7120d019d407c4433d54ba4f47d5a68aca26aa5f81bcc6c7aecf8a40cbdebda47d7c4a06012ea4cd
7
+ data.tar.gz: 1c0366aa9190af66ddf3fab18525f3afc7982f5b609ee48221fe66b80e353a94bef1a57273df8a5eb8c3a11e8dcdb3975c8ba905eb446b37f4777786a36c3c99
data/.gitignore ADDED
@@ -0,0 +1,3 @@
1
+ *.gem
2
+ .DS_Store
3
+ Gemfile.lock
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/LICENSE.md ADDED
@@ -0,0 +1,8 @@
1
+ The MIT License (MIT)
2
+ Copyright (c) 2016 Jeremy Tennant
3
+
4
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
5
+
6
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
7
+
8
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,45 @@
1
+ # POLIrb
2
+
3
+
4
+ ## Description
5
+ Unofficial Poli Gem for Ruby
6
+
7
+ ## Installation
8
+ ### Install the gem
9
+ Command line:
10
+ ```
11
+ $ gem install polirb
12
+ ```
13
+ Or in your application's Gemfile:
14
+ ```
15
+ gem 'polirb', '~> 0.1.0'
16
+ ```
17
+
18
+ ### Global Configuration
19
+
20
+ To make things easier, you can define your client credentials at a global level:
21
+
22
+ ``` ruby
23
+ # Set the configuration
24
+ Polirb.configure(
25
+ :merchant_code => "SAMPLE_MERCHANT_CODE",
26
+ :authentication_code => "SAMPLE_AUTHENTICATION_CODE",
27
+ :merchant_homepage_url => "http://www.example.com/",
28
+ :success_url => "http://www.example.com/poli/success",
29
+ :failure_url => "http://www.example.com/poli/failure",
30
+ :cancellation_url => "http://www.example.com/poli/cancellation",
31
+ :notification_url => "http://www.example.com/poli/notification",
32
+ :timeout => "900",
33
+ )
34
+
35
+ # Get the configuration
36
+ Polirb.configuration # => { client_id => 'CLIENT_ID', client_secret => 'CLIENT_SECRET' }
37
+
38
+ # Reset the configuration
39
+ Polirb.reset_configuration
40
+ ```
41
+
42
+
43
+
44
+ ## License
45
+ MIT - For terms refer to LICENSE.md
@@ -0,0 +1,46 @@
1
+ require 'bigdecimal'
2
+
3
+ module Polirb
4
+ module Transactions
5
+
6
+ def initiate_transaction(amount, merchant_reference, merchant_data)
7
+ defaults = {
8
+ "CurrencyCode" => "AUD",
9
+ "MerchantHomepageURL" => self.merchant_homepage_url,
10
+ "SuccessURL" => self.success_url,
11
+ "FailureURL" => self.failure_url,
12
+ "CancellationURL" => self.cancellation_url,
13
+ "NotificationURL" => self.notification_url,
14
+ "Timeout" => self.timeout,
15
+ }
16
+ supplied = {
17
+ "Amount" => amount,
18
+ "MerchantReference" => merchant_reference,
19
+ "MerchantData" => merchant_data,
20
+ }
21
+ defaults.merge!(supplied)
22
+
23
+ initiate_transaction_response(request(:post, Polirb::Static::INITIATE_TRANSACTION, defaults))
24
+
25
+ end
26
+
27
+ private
28
+
29
+ def initiate_transaction_response(response)
30
+ if response.body["Success"] == true
31
+ {
32
+ :success => true,
33
+ :transaction_ref_no => response.body["TransactionRefNo"],
34
+ :navigate_url => response.body["NavigateURL"],
35
+ }
36
+ else
37
+ {
38
+ :success => false,
39
+ :error_code => "",
40
+ :error_message => "",
41
+ }
42
+ end
43
+ end
44
+
45
+ end
46
+ end
@@ -0,0 +1,40 @@
1
+ require 'polirb/client'
2
+ require 'polirb/request'
3
+ require 'polirb/static'
4
+ require 'polirb/client/transactions'
5
+
6
+ module Polirb
7
+ class Client
8
+ include Polirb::Request
9
+ include Polirb::Static
10
+ include Polirb::Transactions
11
+
12
+ attr_reader :merchant_code, :authentication_code, :merchant_homepage_url, :success_url, :failure_url, :cancellation_url, :notification_url, :timeout
13
+
14
+ # Initialize a Polirb::Client instance
15
+ #
16
+ # options[:merchant_code]
17
+ # options[:authentication_code]
18
+ # options[:merchant_homepage_url]
19
+ # options[:success_url]
20
+ # options[:failure_url]
21
+ # options[:cancellation_url]
22
+ # options[:notification_url]
23
+ # options[:timeout]
24
+ #
25
+ def initialize(options={})
26
+ unless options.kind_of?(Hash)
27
+ raise ArgumentError, "Options hash required."
28
+ end
29
+
30
+ @merchant_code = options[:merchant_code]
31
+ @authentication_code = options[:authentication_code]
32
+ @merchant_homepage_url = options[:merchant_homepage_url]
33
+ @success_url = options[:success_url]
34
+ @failure_url = options[:failure_url]
35
+ @cancellation_url = options[:cancellation_url]
36
+ @notification_url = options[:notification_url]
37
+ @timeout = options[:timeout]
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,204 @@
1
+ module Polirb
2
+ class Error < StandardError; end
3
+ # class ConfigurationError < Error; end
4
+ # class Unauthorized < Error; end
5
+ # class NotFound < Error; end
6
+ end
7
+
8
+
9
+ # 1001 Invalid Token The token specified in the request corresponds to a POLi ID that does not exist in the database. Please contact POLi Support.
10
+ # 1002 Illegal Token The token specified in the request corresponds to a POLi ID that does not belong to the specified merchant. Please confirm that the specified merchant code is correct. If the issue persists please contact POLi Support.
11
+ # 1003 Invalid Merchant Code The merchant code specified in the request does not exist in the database. Please check that you have input the given merchant code correctly. If you are sure you have, please contact POLi Support.
12
+ # 1004 Inactive Merchant The merchant code specified in the request corresponds to a merchant that is inactive. The merchant code you are using has been set to inactive. If you think this is an error, please contact POLi Support.
13
+ # 1005 Merchant Not Authenticated The merchant authentication code supplied is not correct or the authentication type has not been specified in the POLi™ system. Please check you have put the correct authentication code in for your merchant code. If you are certain you have, please contact POLi Support.
14
+ # 1006 Deleted Merchant The merchant code specified in the request corresponds to a merchant that has been deleted. The merchant code you are using has been deleted. If you think this is an error, please contact POLi Support.
15
+ # 1007 Invalid Currency Code The specified currency code does not exist in the database. The currency code you are attempting to use is invalid. Please note that the only acceptable options are AUD and NZD.
16
+ # 1008 Invalid Merchant Currency The specified currency code does not correspond to an active currency for the specified merchant. The merchant you are using is set up for a different currency code than the one you provided.
17
+ # 1009 Currency System Limit Exceeded The payment amount in the specified currency has exceeded the system limit for that currency. Inform the customer that POLi™ applies transaction limits for security reasons and to try another payment limit. Do not specify the limit. If you would like to change your limit, please contact POLi Support.
18
+ # 1010 Currency VAR Limit Exceeded The payment amount in the specified currency has exceeded the VAR limit for that currency. Inform the customer that POLi™ applies transaction limits for security reasons and to try another payment limit. Do not specify the limit. If you would like to change your limit, please contact POLi Support.
19
+ # 1011 Currency Merchant Single Transaction Limit Exceeded The payment amount in the specified currency has exceeded the merchant’s single transaction limit for that currency. Inform the customer that POLi™ applies transaction limits for security reasons and to try another payment limit. Do not specify the limit. If you would like to change your limit, please contact POLi Support.
20
+ # 1012 Currency Merchant Daily Cumulative Limit Exceeded The payment amount in the specified currency has exceeded the merchant’s daily cumulative limit for that currency. Inform the customer that POLi™ applies transaction limits for security reasons and to try another payment limit. Do not specify the limit. If you would like to change your limit, please contact POLi Support.
21
+ # 1013 Invalid Merchant Established Date Time The difference between the specified merchant established time and the system time is more than 24 hours. Check your date and time settings.
22
+ # 1014 Invalid URL Format The format of the specified URL is invalid. Please check the URL fields in your initiate data and ensure they are correct.
23
+ # 1015 Invalid timeout value The specified timeout value is less than the system minimum timeout value. Please check the Timeout field you provided in your initiate data.
24
+ # 1016 The transaction has expired The transaction being enquired upon has lapsed past the 15min enquiry window Use the Merchant Console to attain the outcome of this transaction
25
+ # 1017 Blocked User IP address The IP address of the user is blocked, restricted or otherwise from a list of known suspect IP addresses Do not try to initiate a transaction again. NOTE: Strongly recommend that the user not be allowed to complete the transaction using another payment option at the Merchant’s discretion.
26
+ # 1018 Invalid IP address format The IP address is in an invalid format Try again passing in the correct data
27
+ # 1019 Invalid IP address The IP address is invalid Try again passing in the correct data
28
+ # 1020 No merchant primary account The merchant has not set up a primary account to be used Set up a primary account for the merchant through the console and try initiating the transaction again after it has been successfully added.
29
+ # 1021 Invalid Field Characters The specified field contains invalid characters. Make sure there are no special characters in invalid fields.
30
+ # 1022 Mandatory Field No value is supplied for a mandatory field. A field considered mandatory has no data in it.
31
+ # 1023 Invalid Field Length The specified field has an invalid length. The data you have specified for a field is either too long or too short. Please verify the requirements for the field and retry.
32
+ # 1024 Invalid Currency Amount In Field The specified field contains invalid currency amount. The amount format is incorrect. Please ensure that no fewer or greater than two decimal places are specified.
33
+ # 1025 Invalid Field Range The value in the field is out of the allowable range. Please check the values and make sure they are within acceptable ranges.
34
+ # 1026 Invalid Transaction Status The transaction has not followed the anticipated transaction status path NOTE: This error should never be returned to a Merchant. If it does then please inform POLi Support.
35
+ # 1027 Invalid Merchant Financial Institution The Financial Institution Code passed in is not allowed for this merchant This merchant does not allow the bank you attempted to select.
36
+ # 1028 Invalid Financial Institution Code The Financial Institution Code passed in is not valid POLi does not support the bank you attempted to select.
37
+ # 1029 Inactive Financial Institution The Financial Institution Code passed in is not currently active The financial institution you selected is currently inactive.
38
+ # 1030 Deleted Financial Institution The Financial Institution Code passed in has been deleted The financial institution you selected has been deleted.
39
+ # 1031 Invalid Financial Institution Vector The vector for the passed in Financial Institution Code is not available or nonexistent NOTE: This error should never be returned to a Merchant. If it does then please inform POLi Support.
40
+ # 1032 Invalid Transaction Status Code The Transaction Status Code passed in is not valid NOTE: This error should never be returned to a Merchant. If it does then please inform POLi Support.
41
+ # 1033 Invalid Transaction Status Codes The Transaction Status Codes passed in are not valid NOTE: This error should never be returned to a Merchant. If it does then please inform POLi Support.
42
+ # 1034 Invalid entity code The merchant code is not valid. NOTE: This error should never be returned to a Merchant. If it does then please inform POLi Support.
43
+ # 1035 Inactive entity code The entity code is not active. NOTE: This error should never be returned to a Merchant. If it does then please inform POLi Support.
44
+ # 1036 Deleted entity code The entity code has been deleted. NOTE: This error should never be returned to a Merchant. If it does then please inform POLi Support..
45
+ # 1037 Either the TransactionRefNo or the MerchantReference must be supplied The TransactionRefNo or MerchantReference passed in incorrect. NOTE: This error should never be returned to a Merchant. If it does then please inform POLi Support.
46
+ # 2001 Invalid Token The token is invalid. NOTE: This error should never be returned to a Merchant. If it does then please inform POLi Support.
47
+ # 2002 Expired Token The current token has timed out. The transaction has expired. Please retry your payment.
48
+ # 2003 Illegal Token The token is illegal. NOTE: This error should never be returned to a Merchant. If it does then please inform POLi Support.
49
+ # 2004 Invalid merchant code The merchant code passed is invalid NOTE: This error should never be returned to a Merchant. If it does then please inform POLi Support.
50
+ # 2005 Inactive merchant code The merchant code passed is marked as inactive The merchant code has been set to inactive. Please contact POLi Support if you think this is an error.
51
+ # 2006 Deleted merchant code The merchant code passed has been deleted The merchant code passed has been deleted. Please contact POLi Support if you think this is an error.
52
+ # 2007 Invalid transaction status The transaction status was not as expected. This may point to a problem with the bank site. Contact POLi support for more details.
53
+ # 2008 Invalid payment amount The payment amount was invalid The amount paid for the transaction was not what was expected. Contact POLi support for more details.
54
+ # 2009 Invalid merchant name The merchant name is invalid NOTE: This error should never be returned to a Merchant. If it does then please inform POLi Support.
55
+ # 2010 Invalid merchant sort code format The sort code format is invalid The BSB or sort code was not what was expected. Contact POLi support for more details.
56
+ # 2011 Invalid merchant account number format The merchant account number format is invalid The account number was not what was expected. Contact POLi support for more details.
57
+ # 2012 Invalid language code The language code is invalid NOTE: This error should never be returned to a Merchant. If it does then please inform POLi Support.
58
+ # 2013 Invalid Financial Institution code The financial institution code is invalid The FI code attempted was not found. Contact POLi support for more details.
59
+ # 2014 Invalid merchant financial institution The merchant financial institution is invalid The FI code was not valid. Contact POLi support for more details.
60
+ # 2015 Inactive financial institution The financial institution passed is inactive The FI code attempted was unavailable. Contact POLi support for more details.
61
+ # 2016 Non-existent financial institution vector The vector for the given financial institution does not exist The FI code attempted was unavailable. Contact POLi support for more details.
62
+ # 2017 Invalid transaction reference format The transaction reference format was unexpected NOTE: This error should never be returned to a Merchant. If it does then please inform POLi Support.
63
+ # 2018 Invalid Eula language The Eula language was invalid NOTE: This error should never be returned to a Merchant. If it does then please inform POLi Support.
64
+ # 2019 Deleted Financial Institution The financial institution was deleted The FI code attempted was unavailable. Contact POLi support for more details.
65
+ # 2020 Invalid transaction ref no The transaction ref no is invalid The transaction reference number was invalid. Contact POLi support for more details.
66
+ # 2021 Invalid Payment Amount The amount being paid is not equal to the transaction amount The user’s locale can affect the way that currency amounts are displayed on the screen. For example, a German locale may display the amount with a comma rather than a decimal point. This affects the way that POLi™ interprets the amount and may result in a failure. Setting the locale to En-AU, En-US, or En-GB will rectify this issue.
67
+ # 2022 Invalid merchant sort code The merchant sort code does not equal the {4} sort code. The sort code or BSB was invalid. Contact POLi support for more details.
68
+ # 2023 Invalid merchant account number The merchant account number does not equal the {4} account number The account number was invalid. Contact POLi support for more details.
69
+ # 2024 Invalid URL format Invalid URL format The URL format for one of the URL fields provided in the initiate data was invalid. Check your web services.
70
+ # 2025 Invalid step sequence Invalid step sequence NOTE: This error should never be returned to a Merchant. If it does then please inform POLi Support.
71
+ # 2026 Invalid step type code Invalid step type code NOTE: This error should never be returned to a Merchant. If it does then please inform POLi Support.
72
+ # 2027 Invalid POLi ID Invalid POLi ID NOTE: This error should never be returned to a Merchant. If it does then please inform POLi Support.
73
+ # 2028 Invalid Certificate Invalid Certificate The certificate supplied by the bank is invalid. Please note this error only applies to the downloadable POLi Browser client
74
+ # 2029 No start up details found No start up details found NOTE: This error should never be returned to a Merchant. If it does then please inform POLi Support.
75
+ # 2030 No time remaining found No time remaining found NOTE: This error should never be returned to a Merchant. If it does then please inform POLi Support.
76
+ # 2031 Invalid IP address format The IP address format was incorrect Please ensure the IP address has been passed in correctly.
77
+ # 2032 Invalid IP address The IP address has changed during the payment Retry the transaction. This may be caused by a momentary loss of connection, such as a mobile device changing from WiFi to 3G or 4G.
78
+ # 2033 Invalid vector signature Invalid vector signature NOTE: This error should never be returned to a Merchant. If it does then please inform POLi Support.
79
+ # 2034 Invalid merchant suffix format Invalid merchant suffix format The suffix provided was in an incorrect format. Contact POLi support for more details.
80
+ # 2035 The merchant account suffix does not equal the account suffix The bank account suffix being paid to does not equal to the account suffix set up by the merchant. NOTE: This error should never be returned to a Merchant. If it does then please inform POLi Support.
81
+ # 2036 Unsupported wininet version POLi was unable to access the bank security information The certificate supplied by the bank cannot be accessed. Please note this error only applies to the downloadable POLi Browser client
82
+ # 2037 Missing transaction data signing certificate NOTE: This error should never be returned to a Merchant. If it does then please inform POLi Support.
83
+ # 2038 Error signing transaction data NOTE: This error should never be returned to a Merchant. If it does then please inform POLi Support.
84
+ # 2039 Second POLi Browser detected POLi has detected 'POLiBrowser.exe' is already running Reboot your computer to fix this issue
85
+ # 2040 Invalid payee reference The Payee Reference was different to the one expected. This can be caused by a customer changing the reference, or an error. Contact POLi support for more details.
86
+ # 2041 Invalid date time The date and time POLi collected from the bank page is not what was expected Retry your transaction, or contact POLi support for more details.
87
+ # 3001 Invalid token NOTE: This error should never be returned to a Merchant. If it does then please inform POLi Support.
88
+ # 3002 Expired token NOTE: This error should never be returned to a Merchant. If it does then please inform POLi Support.
89
+ # 3003 Illegal Token NOTE: This error should never be returned to a Merchant. If it does then please inform POLi Support.
90
+ # 3004 Invalid merchant The merchant code was invalid. Contact POLi support for more details.
91
+ # 3005 Inactive merchant The merchant code has been set to Inactive. Contact POLi support for more details.
92
+ # 3006 Deleted merchant The merchant code has been deleted. Contact POLi support for more details.
93
+ # 3007 Invalid transaction status NOTE: This error should never be returned to a Merchant. If it does then please inform POLi Support.
94
+ # 3008 Invalid financial institution code NOTE: This error should never be returned to a Merchant. If it does then please inform POLi Support.
95
+ # 3009 Invalid merchant financial institution NOTE: This error should never be returned to a Merchant. If it does then please inform POLi Support.
96
+ # 3010 Inactive financial institution NOTE: This error should never be returned to a Merchant. If it does then please inform POLi Support.
97
+ # 3011 Invalid financial instituiton vector NOTE: This error should never be returned to a Merchant. If it does then please inform POLi Support.
98
+ # 3012 Invalid language code NOTE: This error should never be returned to a Merchant. If it does then please inform POLi Support.
99
+ # 3013 Invalid country code NOTE: This error should never be returned to a Merchant. If it does then please inform POLi Support.
100
+ # 3014 Invalid currency code NOTE: This error should never be returned to a Merchant. If it does then please inform POLi Support.
101
+ # 3015 Invalid eula language NOTE: This error should never be returned to a Merchant. If it does then please inform POLi Support.
102
+ # 3016 Deleted financial institution NOTE: This error should never be returned to a Merchant. If it does then please inform POLi Support.
103
+ # 3017 Invalid merchant terms and conditions language NOTE: This error should never be returned to a Merchant. If it does then please inform POLi Support.
104
+ # 3018 Invalid URL format NOTE: This error should never be returned to a Merchant. If it does then please inform POLi Support.
105
+ # 3019 Invalid step type code NOTE: This error should never be returned to a Merchant. If it does then please inform POLi Support.
106
+ # 3020 Invalid eula version NOTE: This error should never be returned to a Merchant. If it does then please inform POLi Support.
107
+ # 3021 Invalid FAQ language NOTE: This error should never be returned to a Merchant. If it does then please inform POLi Support.
108
+ # 3022 The financial institution NOTE: This error should never be returned to a Merchant. If it does then please inform POLi Support.
109
+ # 3023 The transaction has expired NOTE: This error should never be returned to a Merchant. If it does then please inform POLi Support.
110
+ # 3024 No helper pane details found NOTE: This error should never be returned to a Merchant. If it does then please inform POLi Support.
111
+ # 3025 No failure details found NOTE: This error should never be returned to a Merchant. If it does then please inform POLi Support.
112
+ # 3026 User time out of sync The user's local time and timezone is out of sync with the POLi Server. Please check that the time, date and time zone are correct on your computer
113
+ # 3027 Invalid IP Address format
114
+ # 3028 Invalid IP Address The IP address has changed during the payment Retry the transaction. This may be caused by a momentary loss of connection
115
+ # 3029 No merchant checkout URL The IP address has changed during the payment Retry the transaction. This may be caused by a momentary loss of connection
116
+ # 3030 The transaction was terminated in an unknown state The transaction passed its timeout value while in Unknown status This may point to a problem with the customer's bank. Please contact POLi Support for more details.
117
+ # 3031 Payment URL for merchant has expired Payment url has expired There may be an error in the implementation of POLi™. Check your web services.
118
+ # 3033 Payment URL is not valid Payment URL is invalid An invalid POLiLinkURL has been attempted
119
+ # 3034 Failed to update customer id Non Fatal Error
120
+ # 3035 Failed to update transactions top up indicator Non Fatal Error
121
+ # 4001 Unknown Error An internal error has occurred Please retry your POLi payment. If the error persists, please contact the merchant, quoting the POLi ID.
122
+ # 4005 Null Result Error Bank page is not recognised by POLi. POLi has encountered an unexpected bank page. This may be due to a new or changed bank page. Our support team has been advised of the error and will address this error as soon as possible.
123
+ # 4007 Invalid Transaction Status The transaction status was not as expected. This may point to a problem with the bank site. Contact POLi support for more details.
124
+ # 4030 ThreatMetrix rejected this user An error has occurred. Please contact the merchant for more information.
125
+ # 4031 Payment Data Not Matched The payment information is missing or has changed This may point to a problem with the bank site. Contact POLi support for more details.
126
+ # 4032 Unhandled Exception An exception has occurred during payment This may point to a problem with the bank site. Contact POLi support for more details.
127
+ # 4033 Unhandled HttpRequestException An HTTP Request exception has occurred during payment This may point to a problem with the bank site. Contact POLi support for more details.
128
+ # 4034 JavaScript execution failed An error has occurred executing Javascript during the transaction. This may point to a problem with the bank site. Contact POLi Support for more details.
129
+ # 4040 Blacklisted Account Please contact POLi Support for further information.
130
+ # 4050 Merchant account details Invalid The merchant's account is not valid Please contact POLi Support for more information or update your merchant bank account.
131
+ # 4051 Internet banking locked Your internet banking service is locked. Please contact your bank for further details.
132
+ # 4052 Third-party payments not supported Your account does not support third-party payments. Please contact your bank for further details.
133
+ # 5001 An unknown error as occured Please contact POLi Support for more details.
134
+ # 5002 No transaction token Please contact POLi Support for more details.
135
+ # 5003 Client certificate error Please contact POLi Support for more details.
136
+ # 5004 Unable to execute The transaction cannot proceed as it is not in an active state Retry the payment. Contact your merchant if the issue persists.
137
+ # 5005 Unexpected page POLi has encountered an unexpected bank page. This may be due to a new or changed bank page. Our support team has been advised of the error and will address this error as soon as possible.
138
+ # 5006 Null reference error POLi has encountered an error with a bank page. This may be due to an changed bank page, your payment timing out, or as a result of multiple errors.
139
+ # 5007 Null or empty string POLi has encountered an error with a bank page or field. This may be due to an changed bank page, your payment timing out, or as a result of multiple errors.
140
+ # 5008 IE Invalid SSL Error POLi is unable to verify the bank's security certificate.
141
+ # 5009 Host invalid SSL error POLi is unable to verify the bank's security certificate. The bank may have recently updated their security certificate, or the bank website is currently unavailable.
142
+ # 5010 Disabled JavaScript JavaScript may not be enabled or is blocked by a browser extension. Please enable javascript in your browser and try again
143
+ # 5011 Unable to obtain vector POLi cannot proceed due to an error. An internal error has occurred.
144
+ # 5012 Vector error An internal error has occurred.
145
+ # 5013 Vector processing error An internal error has occurred.
146
+ # 5014 Communication error There is an error communicating with POLi server. This may be caused by a connection dropout or firewall settings on your computer.
147
+ # 5015 Host error The POLi server has returned an error when processing the transaction. Please retry your POLi payment.
148
+ # 5016 Action Initiated Abort An internal error has occurred.
149
+ # 5017 Vector XML Reader error An internal error has occurred.
150
+ # 5018 Vector XML Deserialise Error POLi is unable to continue due to an internal error.
151
+ # 5019 Unsupported Wininet version Error no longer in use. An internal error has occurred.
152
+ # 5020 Vector Signature Mismatch An internal error has occurred.
153
+ # 5021 Page Data Mismatch Non-fatal error Logging information only.
154
+ # 5022 Null Vector An internal error has occurred.
155
+ # 5023 No financial institution details in vector An internal error has occurred.
156
+ # 5024 No financial institution start URL in vector An internal error has occurred.
157
+ # 5025 No trace dump filter in vector An internal error has occurred.
158
+ # 5026 Invalid Wininet offset POLi is unable to verify the bank's security certificate. The bank website may be currently unavailable. Retry payment at a later time.
159
+ # 5027 Platform not supported Your computer does not support the POLi Payment System.
160
+ # 5028 Potential Westpac session corruption An internal error has occurred.
161
+ # 5029 User is attempting to pay an unsaved payee using a mobile vector which does not support unsaved payees The user's bank requires a saved payee. Retry the payment using a desktop operating system.
162
+ # 5030 ThreatMetrix rejected this user An error has occurred. Please contact the merchant for more information.
163
+ # 5040 Blacklisted Account An error has occurred. Please contact the merchant for further information.
164
+ # 8001 Operational Error Without Trace Information An operational error occurs but there is no trace information available. Perform the web service again.
165
+ # 8002 Operational Error With Trace Information An operational error occurs and trace information is available. Perform the web service again.
166
+ # 8003 Invalid Field Characters The specified field contains invalid characters. There may be an error in the implementation of POLi™. Check your web services.
167
+ # 8004 Mandatory Field No value is supplied for a mandatory field. There may be an error in the implementation of POLi™. Check your web services.
168
+ # 8005 Invalid Field Length The specified field has an invalid length. There may be an error in the implementation of POLi™. Check your web services.
169
+ # 8006 Invalid Currency Amount In Field The specified field contains invalid currency amount. There may be an error in the implementation of POLi™. Check your web services.
170
+ # 8007 Invalid Field Range The value in the field is out of the allowable range. There may be an error in the implementation of POLi™. Check your web services. Please contact POLi Support if the issue persists.
171
+ # 11002 Unable to Send Nudge A nudge sent to the merchant has failed. The Nudge Notification URL may be publicly inaccessible, misconfigured, or the destination is down or taking too long to respond.
172
+ # 12001 Merchant Code Required Merchant code is empty Provide a non-empty merchant code
173
+ # 12002 Merchant Code Length Merchant code length exceeds maximum number of characters allowed. Provide a Merchant Code with valid length.
174
+ # 12003 or 1003 Invalid Merchant Code Merchant Code doesn’t exist or inactive Provide a valid Merchant Code.
175
+ # 12004 Authentication Code Required Authentication Code is empty Provide a non-empty Authentication Code
176
+ # 12005 Authentication Code Length Authentication Code length exceeds maximum number of characters allowed. Provide an Authentication Code with valid length.
177
+ # 12006 or 1005 Invalid Authentication Code Authentication Code is not valid Provide a valid Authentication Code.
178
+ # 12010 Request Type is Required Request Type is empty Provide a non-empty Request Type
179
+ # 12011 Request Type Length Request Type length exceeds maximum number of characters allowed. Provide a Request Type with a valid length
180
+ # 12012 Invalid Request Type Request Type is not valid. It must be either Manual or Email. Provide a Request Type set to either Manual or Email.
181
+ # 12013 Invalid Payment Amount Payment Amount is empty. Either it is empty or not a decimal number or decimal precision exceeds 2 or not in the range of 1.00 and 10000.00 Provide a valid Payment Amount.
182
+ # 12014 Payment Reference is required Payment reference is empty. Provide a non-empty Payment Reference.
183
+ # 12015 Invalid Payment Reference Payment reference is not valid.
184
+ # 12016 Invalid Confirmation Email Confirmation Email is either empty or not one of the values Yes, No Provide Confirmation Email with a valid value.
185
+ # 12017 Invalid Customer Reference Customer Reference is either empty or not one of the values Yes, No Provide Customer Reference with a valid value.
186
+ # 12018 Recipient Name is required Recipient Name is empty. Provide a non-empty Recipient Name.
187
+ # 12019 Recipient Name Length Recipient Name length exceeds maximum number of characters allowed Provide a Recipient Name with a valid length.
188
+ # 12020 Invalid Recipient Name Recipient Name is not valid. Check invalid characters in the Recipient Name.
189
+ # 12021 Recipient Email is required Recipient Email is empty. Provide a non-empty recipient email.
190
+ # 12022 Recipient Email Length Recipient Email length exceeds maximum number of characters allowed. Provide a Recipient Email with a valid length.
191
+ # 12023 Invalid Recipient Email Recipient Email is not valid. Check Recipient Email follows email address rules.
192
+ # 12024 Email Delivery Failed Email Delivery to Payer failed. Check payer email address is valid and active.
193
+ # 14050 A transaction-specific error has occurred System Error Contact POLi support.
194
+ # 14053 The amount specified exceeds the individual transaction limit set by the merchant Validation issue Either raise the limit or lower the amount for the transaction.
195
+ # 14054 The amount specified will cause the daily transaction limit to be exceeded Validation issue Either raise the limit or lower the amount for the transaction.
196
+ # 14055 General failure to initiate a transaction System Error Contact POLi support.
197
+ # 14056 Error in merchant-defined data Validation issue Check the length of the MerchantData field.
198
+ # 14057 One or more values specified have failed a validation check Validation issue Check that you have met the validation rules.
199
+ # 14058 The monetary amount specified is invalid Validation issue Check that the amount is in the correct format.
200
+ # 14059 A URL provided for one or more fields was not formatted correctly Validation issue Check the URL formats.
201
+ # 14060 The currency code supplied is not supported by POLi or the specific merchant Validation issue Please provide only AUD or NZD.
202
+ # 14061 The MerchantReference field contains invalid characters Validation issue MercantReference can only contain alphanumeric and these symbols:@-_=:?./
203
+ # 14062 One or more fields that are mandatory did not have values specified Validation issue Please provide all mandatory fields.
204
+ # 14099 An unexpected error has occurred within transaction functionality System Error Contact POLi support.
@@ -0,0 +1,49 @@
1
+ require 'rest-client'
2
+ require 'active_support'
3
+ require 'active_support/core_ext'
4
+ require 'json'
5
+ require 'hashie'
6
+ require 'openssl'
7
+ require 'date'
8
+ require 'uri'
9
+ require 'base64'
10
+
11
+ module Polirb
12
+ module Request
13
+
14
+ protected
15
+
16
+ def request(*args)
17
+ resp = self.make_request(*args)
18
+
19
+ hash = Hashie::Mash.new(JSON.parse(resp.body))
20
+ raise Error.new(hash.error) if hash.error
21
+ raise Error.new(hash.errors.join(',')) if hash.errors
22
+ hash
23
+ end
24
+
25
+ def make_request(http_method, url, body={})
26
+ raise 'Merchant Code and Authentication Code required!' unless @merchant_code && @authentication_code
27
+
28
+ params = URI.encode_www_form(body)
29
+
30
+ headers = {
31
+ 'Authorization' => "Basic #{basic_auth(@merchant_code,@authentication_code)}"
32
+ }
33
+
34
+ # TODO(maros): Get the `RestClient::Request.execute` API to work.
35
+ if http_method == :get
36
+ RestClient.get("#{url}?#{params}", headers)
37
+ else
38
+ RestClient.post(url, params, headers)
39
+ end
40
+ end
41
+
42
+ private
43
+
44
+ def basic_auth(merchant_code,authentication_code)
45
+ Base64.encode64("#{merchant_code}:#{authentication_code}").gsub("\n","")
46
+ end
47
+
48
+ end
49
+ end
@@ -0,0 +1,5 @@
1
+ module Polirb
2
+ module Static
3
+ INITIATE_TRANSACTION = "https://poliapi.apac.paywithpoli.com/api/v2/Transaction/Initiate"
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ module Polirb
2
+ unless defined?(Polirb::VERSION)
3
+ VERSION = '0.1.0'
4
+ end
5
+ end
data/lib/polirb.rb ADDED
@@ -0,0 +1,54 @@
1
+ require 'polirb/client'
2
+ require 'polirb/errors'
3
+ require 'polirb/static'
4
+ require 'polirb/request'
5
+ require 'polirb/version'
6
+
7
+ module Polirb
8
+ @@options = {}
9
+
10
+ # Create a new Polirb::Client instance
11
+ #
12
+ def self.new(options={})
13
+ Polirb::Client.new(options)
14
+ end
15
+
16
+ # Define a global configuration
17
+ #
18
+ # options[:merchant_code]
19
+ # options[:authentication_code]
20
+ # options[:merchant_homepage_url]
21
+ # options[:success_url]
22
+ # options[:failure_url]
23
+ # options[:cancellation_url]
24
+ # options[:notification_url]
25
+ # options[:timeout]
26
+ #
27
+ def self.configure(options={})
28
+ unless options.kind_of?(Hash)
29
+ raise ArgumentError, "Options hash required."
30
+ end
31
+
32
+ @@options[:merchant_code] = options[:merchant_code]
33
+ @@options[:authentication_code] = options[:authentication_code]
34
+ @@options[:merchant_homepage_url] = options[:merchant_homepage_url]
35
+ @@options[:success_url] = options[:success_url]
36
+ @@options[:failure_url] = options[:failure_url]
37
+ @@options[:cancellation_url] = options[:cancellation_url]
38
+ @@options[:notification_url] = options[:notification_url]
39
+ @@options[:timeout] = options[:timeout]
40
+ @@options
41
+ end
42
+
43
+ # Returns global configuration hash
44
+ #
45
+ def self.configuration
46
+ @@options
47
+ end
48
+
49
+ # Resets the global configuration
50
+ #
51
+ def self.reset_configuration
52
+ @@options = {}
53
+ end
54
+ end
data/polirb.gemspec ADDED
@@ -0,0 +1,25 @@
1
+ require File.expand_path('../lib/polirb/version', __FILE__)
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = "polirb"
5
+ s.version = Polirb::VERSION.dup
6
+ s.summary = "POLi API wrapper"
7
+ s.description = "Ruby wrapper for the POLi API"
8
+ s.homepage = "http://github.com/tennantje/polirb"
9
+ s.authors = ["Jeremy Tennant"]
10
+ s.email = ["tennantje@gmail.com"]
11
+ s.license = "MIT"
12
+
13
+ s.add_development_dependency 'rspec', '~> 3.4'
14
+ s.add_development_dependency 'webmock', '~> 2.1'
15
+
16
+ s.add_runtime_dependency 'json', '~> 2.0'
17
+ s.add_runtime_dependency 'rest-client', '~> 2.0'
18
+ s.add_runtime_dependency 'hashie', '~> 3.4'
19
+ s.add_runtime_dependency 'activesupport', '~> 5.0'
20
+
21
+ s.files = `git ls-files`.split("\n")
22
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
23
+ s.executables = `git ls-files -- bin/*`.split("\n").map{|f| File.basename(f)}
24
+ s.require_paths = ["lib"]
25
+ end
metadata ADDED
@@ -0,0 +1,140 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: polirb
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Jeremy Tennant
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-11-22 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rspec
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '3.4'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '3.4'
27
+ - !ruby/object:Gem::Dependency
28
+ name: webmock
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '2.1'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '2.1'
41
+ - !ruby/object:Gem::Dependency
42
+ name: json
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '2.0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '2.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rest-client
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '2.0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
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.4'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '3.4'
83
+ - !ruby/object:Gem::Dependency
84
+ name: activesupport
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '5.0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '5.0'
97
+ description: Ruby wrapper for the POLi API
98
+ email:
99
+ - tennantje@gmail.com
100
+ executables: []
101
+ extensions: []
102
+ extra_rdoc_files: []
103
+ files:
104
+ - ".gitignore"
105
+ - Gemfile
106
+ - LICENSE.md
107
+ - README.md
108
+ - lib/polirb.rb
109
+ - lib/polirb/client.rb
110
+ - lib/polirb/client/transactions.rb
111
+ - lib/polirb/errors.rb
112
+ - lib/polirb/request.rb
113
+ - lib/polirb/static.rb
114
+ - lib/polirb/version.rb
115
+ - polirb.gemspec
116
+ homepage: http://github.com/tennantje/polirb
117
+ licenses:
118
+ - MIT
119
+ metadata: {}
120
+ post_install_message:
121
+ rdoc_options: []
122
+ require_paths:
123
+ - lib
124
+ required_ruby_version: !ruby/object:Gem::Requirement
125
+ requirements:
126
+ - - ">="
127
+ - !ruby/object:Gem::Version
128
+ version: '0'
129
+ required_rubygems_version: !ruby/object:Gem::Requirement
130
+ requirements:
131
+ - - ">="
132
+ - !ruby/object:Gem::Version
133
+ version: '0'
134
+ requirements: []
135
+ rubyforge_project:
136
+ rubygems_version: 2.5.1
137
+ signing_key:
138
+ specification_version: 4
139
+ summary: POLi API wrapper
140
+ test_files: []