CnpOnline 8.31.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 +7 -0
- data/CHANGELOG +139 -0
- data/CONTRIBUTORS +2 -0
- data/DESCRIPTION +5 -0
- data/LICENSE +22 -0
- data/README.md +72 -0
- data/Rakefile +89 -0
- data/Rakefile~ +89 -0
- data/SETUP.md +46 -0
- data/bin/Setup.rb +124 -0
- data/bin/sample_batch_driver.rb +123 -0
- data/bin/sample_driver.rb +49 -0
- data/lib/Communications.rb +85 -0
- data/lib/Configuration.rb +67 -0
- data/lib/EnvironmentVariables.rb +22 -0
- data/lib/LitleBatchRequest.rb +562 -0
- data/lib/LitleListeners.rb +142 -0
- data/lib/LitleOnline.rb +62 -0
- data/lib/LitleOnlineRequest.rb +297 -0
- data/lib/LitleRequest.rb +494 -0
- data/lib/LitleTransaction.rb +463 -0
- data/lib/LitleXmlMapper.rb +64 -0
- data/lib/XMLFields.rb +1869 -0
- data/lib/cacert.pem +3331 -0
- data/samples/Auth/LitleAuthReversalTransaction.rb +15 -0
- data/samples/Auth/LitleAuthorizationTransaction.rb +31 -0
- data/samples/Auth/LitlePaymentFullLifeCycle.rb +47 -0
- data/samples/Batch/AccountUpdate.rb +64 -0
- data/samples/Batch/SampleBatchDriver.rb +94 -0
- data/samples/Capture/LitleCaptureGivenAuthTransaction.rb +30 -0
- data/samples/Capture/LitleCaptureTransaction.rb +14 -0
- data/samples/Capture/LitleForceCaptureTransaction.rb +26 -0
- data/samples/Capture/LitlePartialCapture.rb +16 -0
- data/samples/Credit/LitleCreditTransaction.rb +16 -0
- data/samples/Credit/LitleRefundTransaction.rb +29 -0
- data/samples/Other/LitleAvsTransaction.rb +34 -0
- data/samples/Other/LitleVoidTransaction.rb +18 -0
- data/samples/Paypage/FullPaypageLifeCycle.rb +74 -0
- data/samples/Run_all.rb +17 -0
- data/samples/Sale/LitleSaleTransaction.rb +29 -0
- data/samples/Sale/SampleSaleTransaction.rb +24 -0
- data/test/certification/certTest1_base.rb +945 -0
- data/test/certification/certTest2_authenhanced.rb +573 -0
- data/test/certification/certTest3_authreversal.rb +185 -0
- data/test/certification/certTest4_echeck.rb +278 -0
- data/test/certification/certTest5_token.rb +204 -0
- data/test/certification/certTest_batchAll.rb +337 -0
- data/test/certification/ts_all.rb +33 -0
- data/test/functional/test_activate.rb +100 -0
- data/test/functional/test_activateReversal.rb +56 -0
- data/test/functional/test_auth.rb +298 -0
- data/test/functional/test_authReversal.rb +69 -0
- data/test/functional/test_balanceInquiry.rb +80 -0
- data/test/functional/test_batch.rb +164 -0
- data/test/functional/test_batchStream.rb +145 -0
- data/test/functional/test_cancelSubscription.rb +55 -0
- data/test/functional/test_capture.rb +84 -0
- data/test/functional/test_captureGivenAuth.rb +235 -0
- data/test/functional/test_configuration.rb +89 -0
- data/test/functional/test_createPlan.rb +85 -0
- data/test/functional/test_credit.rb +174 -0
- data/test/functional/test_deactivate.rb +80 -0
- data/test/functional/test_deactivateReversal.rb +56 -0
- data/test/functional/test_depositReversal.rb +56 -0
- data/test/functional/test_echeckCredit.rb +134 -0
- data/test/functional/test_echeckRedeposit.rb +88 -0
- data/test/functional/test_echeckSale.rb +177 -0
- data/test/functional/test_echeckVerification.rb +127 -0
- data/test/functional/test_echeckVoid.rb +41 -0
- data/test/functional/test_forceCapture.rb +183 -0
- data/test/functional/test_litle_requests.rb +356 -0
- data/test/functional/test_load.rb +82 -0
- data/test/functional/test_loadReversal.rb +56 -0
- data/test/functional/test_override.rb +64 -0
- data/test/functional/test_refundReversal.rb +56 -0
- data/test/functional/test_sale.rb +259 -0
- data/test/functional/test_token.rb +115 -0
- data/test/functional/test_unload.rb +82 -0
- data/test/functional/test_unloadReversal.rb +56 -0
- data/test/functional/test_updateCardValidationNumOnToken.rb +43 -0
- data/test/functional/test_updatePlan.rb +58 -0
- data/test/functional/test_updateSubscription.rb +76 -0
- data/test/functional/test_xmlfields.rb +427 -0
- data/test/functional/ts_all.rb +66 -0
- data/test/unit/test_LitleAUBatch.rb +216 -0
- data/test/unit/test_LitleBatchRequest.rb +643 -0
- data/test/unit/test_LitleOnlineRequest.rb +295 -0
- data/test/unit/test_LitleRequest.rb +316 -0
- data/test/unit/test_LitleTransaction.rb +397 -0
- data/test/unit/test_activate.rb +92 -0
- data/test/unit/test_activateReversal.rb +44 -0
- data/test/unit/test_auth.rb +421 -0
- data/test/unit/test_authReversal.rb +82 -0
- data/test/unit/test_balanceInquiry.rb +52 -0
- data/test/unit/test_cancelSubscription.rb +43 -0
- data/test/unit/test_capture.rb +73 -0
- data/test/unit/test_captureGivenAuth.rb +188 -0
- data/test/unit/test_createPlan.rb +52 -0
- data/test/unit/test_credit.rb +342 -0
- data/test/unit/test_deactivate.rb +52 -0
- data/test/unit/test_deactivateReversal.rb +44 -0
- data/test/unit/test_depositReversal.rb +44 -0
- data/test/unit/test_echeckCredit.rb +71 -0
- data/test/unit/test_echeckRedeposit.rb +94 -0
- data/test/unit/test_echeckSale.rb +71 -0
- data/test/unit/test_echeckVerification.rb +71 -0
- data/test/unit/test_echeckVoid.rb +54 -0
- data/test/unit/test_forceCapture.rb +145 -0
- data/test/unit/test_load.rb +53 -0
- data/test/unit/test_loadReversal.rb +44 -0
- data/test/unit/test_refundReversal.rb +44 -0
- data/test/unit/test_sale.rb +465 -0
- data/test/unit/test_token.rb +144 -0
- data/test/unit/test_unload.rb +53 -0
- data/test/unit/test_unloadReversal.rb +44 -0
- data/test/unit/test_updateCardValidationNumOnToken.rb +80 -0
- data/test/unit/test_updatePlan.rb +45 -0
- data/test/unit/test_updateSubscription.rb +172 -0
- data/test/unit/test_xmlfields.rb +2930 -0
- data/test/unit/ts_unit.rb +65 -0
- metadata +255 -0
data/bin/Setup.rb
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
# Copyright (c) 2011 Litle & Co.
|
|
4
|
+
#
|
|
5
|
+
# Permission is hereby granted, free of charge, to any person
|
|
6
|
+
# obtaining a copy of this software and associated documentation
|
|
7
|
+
# files (the "Software"), to deal in the Software without
|
|
8
|
+
# restriction, including without limitation the rights to use,
|
|
9
|
+
# copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
# copies of the Software, and to permit persons to whom the
|
|
11
|
+
# Software is furnished to do so, subject to the following
|
|
12
|
+
# conditions:
|
|
13
|
+
#
|
|
14
|
+
# The above copyright notice and this permission notice shall be
|
|
15
|
+
# included in all copies or substantial portions of the Software.
|
|
16
|
+
#
|
|
17
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
18
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
|
19
|
+
# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
20
|
+
# NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
21
|
+
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
22
|
+
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
23
|
+
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
24
|
+
# OTHER DEALINGS IN THE SOFTWARE.
|
|
25
|
+
|
|
26
|
+
# make setup file executable
|
|
27
|
+
|
|
28
|
+
#
|
|
29
|
+
# Configuration generation for URL and credentials
|
|
30
|
+
#
|
|
31
|
+
class Setup
|
|
32
|
+
attr_reader :handle, :path
|
|
33
|
+
def initialize(filename)
|
|
34
|
+
@handle = File.new(filename, File::CREAT | File::TRUNC | File::RDWR, 0o600)
|
|
35
|
+
File.open(filename, 'w') do |f|
|
|
36
|
+
puts 'Welcome to Litle Ruby_SDK'
|
|
37
|
+
puts 'Please input your user name:'
|
|
38
|
+
f.puts 'user: ' + gets
|
|
39
|
+
puts 'Please input your password:'
|
|
40
|
+
f.puts 'password: ' + gets
|
|
41
|
+
puts 'Please input your merchantId:'
|
|
42
|
+
|
|
43
|
+
f.puts 'currency_merchant_map:'
|
|
44
|
+
f.puts ' DEFAULT: ' + gets
|
|
45
|
+
f.puts "default_report_group: 'Default Report Group'"
|
|
46
|
+
|
|
47
|
+
puts "Please choose Litle url from the following list (example: 'prelive') or directly input another URL:
|
|
48
|
+
sandbox => https://www.testvantivcnp.com/sandbox/communicator/online
|
|
49
|
+
prelive => https://payments.vantivprelive.com/vap/communicator/online
|
|
50
|
+
postlive => https://payments.vantivpostlive.com/vap/communicator/online
|
|
51
|
+
production => https://payments.vantivcnp.com/vap/communicator/online
|
|
52
|
+
transact_prelive => https://transact.vantivprelive.com/vap/communicator/online
|
|
53
|
+
transact_postlive => https://transact.vantivpostlive.com/vap/communicator/online
|
|
54
|
+
transact_production => https://transact.vantivcnp.com/vap/communicator/online"
|
|
55
|
+
f.puts 'url: ' + Setup.choice(gets)
|
|
56
|
+
puts 'Please input the proxy address, if no proxy hit enter key: '
|
|
57
|
+
f.puts 'proxy_addr: ' + gets
|
|
58
|
+
puts 'Please input the proxy port, if no proxy hit enter key: '
|
|
59
|
+
f.puts 'proxy_port: ' + gets
|
|
60
|
+
puts 'Please input your sFTP username for batch processing; if no sFTP, hit enter key: '
|
|
61
|
+
f.puts 'sftp_username: ' + gets
|
|
62
|
+
puts 'Please input your sFTP password for batch processing; if no sFTP, hit enter key: '
|
|
63
|
+
f.puts 'sftp_password: ' + gets
|
|
64
|
+
puts 'Please input your sFTP url for batch processing; if no sFTP, hit enter key: '
|
|
65
|
+
f.puts 'sftp_url: ' + gets
|
|
66
|
+
puts 'Please input your url for fast batch processing; if no fast batch, hit enter key: '
|
|
67
|
+
f.puts 'fast_url: ' + gets
|
|
68
|
+
puts 'Please input your port for fast batch processing; if no fast batch, hit enter key: '
|
|
69
|
+
f.puts 'fast_port: ' + gets
|
|
70
|
+
|
|
71
|
+
f.puts 'printxml: false'
|
|
72
|
+
# default http timeout set to 500 ms
|
|
73
|
+
f.puts 'timeout: 500'
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
def finished
|
|
78
|
+
@handle.close
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
def self.choice(litle_env)
|
|
82
|
+
litle_online_ctx = 'vap/communicator/online'
|
|
83
|
+
if litle_env == "sandbox\n"
|
|
84
|
+
return 'https://www.testvantivcnp.com/sandbox/communicator/online'
|
|
85
|
+
elsif litle_env == "prelive\n"
|
|
86
|
+
return 'https://payments.vantivprelive.com/' + litle_online_ctx
|
|
87
|
+
elsif litle_env == "postlive\n"
|
|
88
|
+
return 'https://payments.vantivpostlive.com/' + litle_online_ctx
|
|
89
|
+
elsif litle_env == "production\n"
|
|
90
|
+
return 'https://payments.vantivcnp.com/' + litle_online_ctx
|
|
91
|
+
elsif litle_env == "transact_production\n"
|
|
92
|
+
return 'https://transact.vantivcnp.com/' + litle_online_ctx
|
|
93
|
+
elsif litle_env == "transact_prelive\n"
|
|
94
|
+
return 'https://transact.vantivprelive.com/' + litle_online_ctx
|
|
95
|
+
elsif litle_env == "transact_postlive\n"
|
|
96
|
+
return 'https://transact.vantivpostlive.com/' + litle_online_ctx
|
|
97
|
+
else
|
|
98
|
+
return 'https://www.testvantivcnp.com/sandbox/communicator/online'
|
|
99
|
+
end
|
|
100
|
+
end
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
#
|
|
104
|
+
#
|
|
105
|
+
# Optionally enable the configuration to reside in a custom location
|
|
106
|
+
# if the $LITLE_CONFIG_DIR directory is set
|
|
107
|
+
#
|
|
108
|
+
|
|
109
|
+
# make the config.yml file in the LITLE_CONFIG_DIR directory or HOME directory
|
|
110
|
+
path = if !ENV['LITLE_CONFIG_DIR'].nil?
|
|
111
|
+
ENV['LITLE_CONFIG_DIR']
|
|
112
|
+
else
|
|
113
|
+
ENV['HOME']
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
# make the config.yml file hidden
|
|
117
|
+
# create a config file contain all the configuration data
|
|
118
|
+
config_file = path + '/.litle_SDK_config.yml'
|
|
119
|
+
f = Setup.new(config_file)
|
|
120
|
+
|
|
121
|
+
# return the path of the config file and the path file
|
|
122
|
+
@path = File.expand_path(config_file)
|
|
123
|
+
puts 'The Litle configuration file has been generated, the file is located at: ' + @path
|
|
124
|
+
f.finished
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
=begin
|
|
3
|
+
Copyright (c) 2011 Litle & Co.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person
|
|
6
|
+
obtaining a copy of this software and associated documentation
|
|
7
|
+
files (the "Software"), to deal in the Software without
|
|
8
|
+
restriction, including without limitation the rights to use,
|
|
9
|
+
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
copies of the Software, and to permit persons to whom the
|
|
11
|
+
Software is furnished to do so, subject to the following
|
|
12
|
+
conditions:
|
|
13
|
+
|
|
14
|
+
The above copyright notice and this permission notice shall be
|
|
15
|
+
included in all copies or substantial portions of the Software.
|
|
16
|
+
|
|
17
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
18
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
|
19
|
+
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
20
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
21
|
+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
22
|
+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
23
|
+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
24
|
+
OTHER DEALINGS IN THE SOFTWARE.
|
|
25
|
+
=end
|
|
26
|
+
|
|
27
|
+
#Sample Driver
|
|
28
|
+
require_relative '../lib/LitleOnline'
|
|
29
|
+
|
|
30
|
+
saleHash = {
|
|
31
|
+
'reportGroup'=>'Planets',
|
|
32
|
+
'id' => '006',
|
|
33
|
+
'orderId'=>'12344',
|
|
34
|
+
'amount'=>'6000',
|
|
35
|
+
'orderSource'=>'ecommerce',
|
|
36
|
+
'card'=>{
|
|
37
|
+
'type'=>'VI',
|
|
38
|
+
'number' =>'4100000000000001',
|
|
39
|
+
'expDate' =>'1210'
|
|
40
|
+
}}
|
|
41
|
+
|
|
42
|
+
accountUpdateHash = {
|
|
43
|
+
'reportGroup'=>'Planets',
|
|
44
|
+
'id'=>'12345',
|
|
45
|
+
'customerId'=>'0987',
|
|
46
|
+
'orderId'=>'1234',
|
|
47
|
+
'card'=>{
|
|
48
|
+
'type'=>'VI',
|
|
49
|
+
'number' =>'4100000000000001',
|
|
50
|
+
'expDate' =>'1210'
|
|
51
|
+
}}
|
|
52
|
+
|
|
53
|
+
rfrHash = {
|
|
54
|
+
'merchantId'=>101,
|
|
55
|
+
'postDay'=>'2013-06-04'
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
path = Dir.pwd
|
|
59
|
+
|
|
60
|
+
request = LitleOnline::LitleRequest.new({'sessionId'=>'8675309'})
|
|
61
|
+
|
|
62
|
+
request.create_new_litle_request(path)
|
|
63
|
+
puts "Created new LitleRequest at location: " + path
|
|
64
|
+
start = Time::now
|
|
65
|
+
#create five batches, each with 10 sales
|
|
66
|
+
#5.times{
|
|
67
|
+
batch = LitleOnline::LitleBatchRequest.new
|
|
68
|
+
batch.create_new_batch(path)
|
|
69
|
+
|
|
70
|
+
#add the same sale ten times
|
|
71
|
+
#10.times{
|
|
72
|
+
batch.sale(saleHash)
|
|
73
|
+
#}
|
|
74
|
+
batch.account_update(accountUpdateHash)
|
|
75
|
+
|
|
76
|
+
#close the batch, indicating we plan to add no more transactions
|
|
77
|
+
batch.close_batch()
|
|
78
|
+
#add the batch to the LitleRequest
|
|
79
|
+
request.commit_batch(batch)
|
|
80
|
+
#}
|
|
81
|
+
|
|
82
|
+
request.add_rfr_request(rfrHash)
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
# puts "Finished adding batches to LitleRequest at " + request.get_path_to_batches
|
|
87
|
+
#finish the Litle Request, indicating we plan to add no more batches
|
|
88
|
+
request.finish_request
|
|
89
|
+
puts "Generated final XML markup of the LitleRequest"
|
|
90
|
+
|
|
91
|
+
#send the batch files at the given directory over sFTP
|
|
92
|
+
request.send_to_litle
|
|
93
|
+
puts "Dropped off the XML of the LitleRequest over FTP"
|
|
94
|
+
#grab the expected number of responses from the sFTP server and save them to the given path
|
|
95
|
+
request.get_responses_from_server()
|
|
96
|
+
puts "Received the LitleRequest responses from the server"
|
|
97
|
+
#process the responses from the server with a listener which applies the given block
|
|
98
|
+
start = Time::now
|
|
99
|
+
request.process_responses({:transaction_listener => LitleOnline::DefaultLitleListener.new do |transaction|
|
|
100
|
+
type = transaction["type"]
|
|
101
|
+
#if we're dealing with a saleResponse (check the Litle XML Reference Guide!)
|
|
102
|
+
if(type == "saleResponse") then
|
|
103
|
+
#grab an attribute of the parent of the response
|
|
104
|
+
puts "Report Group: " + transaction["reportGroup"]
|
|
105
|
+
|
|
106
|
+
#grab some child elements of the transaction
|
|
107
|
+
puts "Litle Txn Id: " + transaction["litleTxnId"]
|
|
108
|
+
puts "Order Id: " + transaction["orderId"]
|
|
109
|
+
puts "Response: " + transaction["response"]
|
|
110
|
+
|
|
111
|
+
#grab a child element of a child element of the transation
|
|
112
|
+
puts "AVS Result: " + transaction["fraudResult"]["avsResult"]
|
|
113
|
+
puts "Token Response Message: " + transaction["tokenResponse"]["tokenMessage"]
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
if(type == "RFRResponse") then
|
|
117
|
+
puts "RFR Response Code: " + transaction["response"]
|
|
118
|
+
puts "RFR Response Message: " + transaction["message"]
|
|
119
|
+
end
|
|
120
|
+
end})
|
|
121
|
+
stop = Time::now
|
|
122
|
+
puts "Total time: " + (stop - start).to_s
|
|
123
|
+
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
=begin
|
|
4
|
+
Copyright (c) 2011 Litle & Co.
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person
|
|
7
|
+
obtaining a copy of this software and associated documentation
|
|
8
|
+
files (the "Software"), to deal in the Software without
|
|
9
|
+
restriction, including without limitation the rights to use,
|
|
10
|
+
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
+
copies of the Software, and to permit persons to whom the
|
|
12
|
+
Software is furnished to do so, subject to the following
|
|
13
|
+
conditions:
|
|
14
|
+
|
|
15
|
+
The above copyright notice and this permission notice shall be
|
|
16
|
+
included in all copies or substantial portions of the Software.
|
|
17
|
+
|
|
18
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
19
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
|
20
|
+
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
21
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
22
|
+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
23
|
+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
24
|
+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
25
|
+
OTHER DEALINGS IN THE SOFTWARE.
|
|
26
|
+
=end
|
|
27
|
+
|
|
28
|
+
#Sample Driver
|
|
29
|
+
#require 'LitleOnline'
|
|
30
|
+
#include LitleOnline
|
|
31
|
+
require_relative '../lib/LitleOnline'
|
|
32
|
+
hash = {
|
|
33
|
+
'reportGroup'=>'product1',
|
|
34
|
+
'orderId'=>'12344',
|
|
35
|
+
'card'=>{
|
|
36
|
+
'type'=>'VI',
|
|
37
|
+
'number' =>'4100000000000001',
|
|
38
|
+
'expDate' =>'1210'
|
|
39
|
+
},
|
|
40
|
+
'orderSource'=>'ecommerce',
|
|
41
|
+
'amount'=>'106'
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
#perform credit transaction
|
|
45
|
+
response= LitleOnline::LitleOnlineRequest.new.credit(hash)
|
|
46
|
+
|
|
47
|
+
#display results
|
|
48
|
+
puts "Message: "+response.message
|
|
49
|
+
puts "Litle Transaction ID: "+response.creditResponse.litleTxnId
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
Copyright (c) 2011 Litle & Co.
|
|
3
|
+
|
|
4
|
+
Permission is hereby granted, free of charge, to any person
|
|
5
|
+
obtaining a copy of this software and associated documentation
|
|
6
|
+
files (the "Software"), to deal in the Software without
|
|
7
|
+
restriction, including without limitation the rights to use,
|
|
8
|
+
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the
|
|
10
|
+
Software is furnished to do so, subject to the following
|
|
11
|
+
conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be
|
|
14
|
+
included in all copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
|
18
|
+
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
20
|
+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
21
|
+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
22
|
+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
23
|
+
OTHER DEALINGS IN THE SOFTWARE.
|
|
24
|
+
=end
|
|
25
|
+
|
|
26
|
+
#
|
|
27
|
+
# Used for all transmission to Litle over HTTP or HTTPS
|
|
28
|
+
# works with or without an HTTP proxy
|
|
29
|
+
#
|
|
30
|
+
# URL and proxy server settings are derived from the configuration file
|
|
31
|
+
#
|
|
32
|
+
module LitleOnline
|
|
33
|
+
class Communications
|
|
34
|
+
##For http or https post with or without a proxy
|
|
35
|
+
def Communications.http_post(post_data,config_hash)
|
|
36
|
+
|
|
37
|
+
proxy_addr = config_hash['proxy_addr']
|
|
38
|
+
proxy_port = config_hash['proxy_port']
|
|
39
|
+
litle_url = config_hash['url']
|
|
40
|
+
|
|
41
|
+
# setup https or http post
|
|
42
|
+
url = URI.parse(litle_url)
|
|
43
|
+
|
|
44
|
+
response_xml = nil
|
|
45
|
+
https = Net::HTTP.new(url.host, url.port, proxy_addr, proxy_port)
|
|
46
|
+
if(url.scheme == 'https')
|
|
47
|
+
https.use_ssl = url.scheme=='https'
|
|
48
|
+
https.verify_mode = OpenSSL::SSL::VERIFY_PEER
|
|
49
|
+
https.ca_file = File.join(File.dirname(__FILE__), "cacert.pem")
|
|
50
|
+
end
|
|
51
|
+
https.start { |http|
|
|
52
|
+
response = http.request_post(url.path, post_data.to_s, {'Content-Type'=>'text/xml','Connection'=>'close'})
|
|
53
|
+
response_xml = response
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
# validate response, only an HTTP 200 will work, redirects are not followed
|
|
57
|
+
case response_xml
|
|
58
|
+
when Net::HTTPOK
|
|
59
|
+
return response_xml.body
|
|
60
|
+
else
|
|
61
|
+
raise("Error with http http_post_request, code:" + response_xml.header.code)
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
=begin
|
|
68
|
+
NOTES ON HTTP TIMEOUT
|
|
69
|
+
|
|
70
|
+
Litle & Co. optimizes our systems to ensure the return of responses as quickly as possible, some portions of the process are beyond our control.
|
|
71
|
+
The round-trip time of an Authorization can be broken down into three parts, as follows:
|
|
72
|
+
1. Transmission time (across the internet) to Litle & Co. and back to the merchant
|
|
73
|
+
2. Processing time by the authorization provider
|
|
74
|
+
3. Processing time by Litle
|
|
75
|
+
Under normal operating circumstances, the transmission time to and from Litle does not exceed 0.6 seconds
|
|
76
|
+
and processing overhead by Litle occurs in 0.1 seconds.
|
|
77
|
+
Typically, the processing time by the card association or authorization provider can take between 0.5 and 3 seconds,
|
|
78
|
+
but some percentage of transactions may take significantly longer.
|
|
79
|
+
|
|
80
|
+
Because the total processing time can vary due to a number of factors, Litle & Co. recommends using a minimum timeout setting of
|
|
81
|
+
60 seconds to accomodate Sale transactions and 30 seconds if you are not utilizing Sale tranactions.
|
|
82
|
+
|
|
83
|
+
These settings should ensure that you do not frequently disconnect prior to receiving a valid authorization causing dropped orders
|
|
84
|
+
and/or re-auths and duplicate auths.
|
|
85
|
+
=end
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
Copyright (c) 2011 Litle & Co.
|
|
3
|
+
|
|
4
|
+
Permission is hereby granted, free of charge, to any person
|
|
5
|
+
obtaining a copy of this software and associated documentation
|
|
6
|
+
files (the "Software"), to deal in the Software without
|
|
7
|
+
restriction, including without limitation the rights to use,
|
|
8
|
+
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the
|
|
10
|
+
Software is furnished to do so, subject to the following
|
|
11
|
+
conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be
|
|
14
|
+
included in all copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
|
18
|
+
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
20
|
+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
21
|
+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
22
|
+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
23
|
+
OTHER DEALINGS IN THE SOFTWARE.
|
|
24
|
+
=end
|
|
25
|
+
|
|
26
|
+
require 'yaml'
|
|
27
|
+
#
|
|
28
|
+
# Loads the configuration from a file
|
|
29
|
+
#
|
|
30
|
+
module LitleOnline
|
|
31
|
+
class Configuration
|
|
32
|
+
class << self
|
|
33
|
+
# External logger, if specified
|
|
34
|
+
attr_accessor :logger
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def config
|
|
38
|
+
begin
|
|
39
|
+
if !(ENV['LITLE_CONFIG_DIR'].nil?)
|
|
40
|
+
config_file = ENV['LITLE_CONFIG_DIR'] + "/.litle_SDK_config.yml"
|
|
41
|
+
else
|
|
42
|
+
config_file = ENV['HOME'] + "/.litle_SDK_config.yml"
|
|
43
|
+
end
|
|
44
|
+
#if Env variable exist, then just override the data from config file
|
|
45
|
+
if (File.exists?(config_file))
|
|
46
|
+
datas=YAML.load_file(config_file)
|
|
47
|
+
else
|
|
48
|
+
environments = EnvironmentVariables.new
|
|
49
|
+
datas={}
|
|
50
|
+
environments.instance_variables.each {|var| datas[var.to_s.delete("@")] = environments.instance_variable_get(var) }
|
|
51
|
+
end
|
|
52
|
+
datas.each {|key,value| setENV(key,datas)}
|
|
53
|
+
return datas
|
|
54
|
+
rescue
|
|
55
|
+
return {}
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
end
|
|
59
|
+
def setENV(key,datas)
|
|
60
|
+
if !(ENV['litle_'+key].nil?)
|
|
61
|
+
datas[key]=ENV['litle_'+key]
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
end
|