CnpChargeback 2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG +2 -0
- data/CONTRIBUTORS +0 -0
- data/DESCRIPTION +5 -0
- data/LICENSE +44 -0
- data/README.md +70 -0
- data/Rakefile +90 -0
- data/SETUP.md +44 -0
- data/bin/Setup.rb +97 -0
- data/lib/ChargebackDocument.rb +67 -0
- data/lib/ChargebackRetrieval.rb +85 -0
- data/lib/ChargebackUpdate.rb +97 -0
- data/lib/CnpChargeback.rb +61 -0
- data/lib/Communications.rb +314 -0
- data/lib/Configuration.rb +75 -0
- data/lib/EnvironmentVariables.rb +15 -0
- data/lib/XMLFields.rb +36 -0
- data/lib/cacert.pem +3331 -0
- data/test/certification/certTest.rb +158 -0
- data/test/certification/ts_all.rb +29 -0
- data/test/functional/test_chargeback_document.rb +87 -0
- data/test/functional/test_chargeback_retrieval.rb +83 -0
- data/test/functional/test_chargeback_update.rb +71 -0
- data/test/functional/ts_all.rb +32 -0
- data/test/unit/ts_unit.rb +29 -0
- metadata +186 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: ef3e5294caa57da878cb89bdc8d084baea1c52bc
|
4
|
+
data.tar.gz: c313304e8a93d8689130a458f39c77916731261f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: cb509240444d3df40ac8923e6a9cb455a98e0269b1198cc5c75a9c8ca0035421fab748966a75ecf5513256397fe7460c28a0e01ee14b2cc7a38200f09c4e3fb9
|
7
|
+
data.tar.gz: 190c8ebfac05c214b86429b59ea62f33bfbe755dd806f8afbdb58f030e7a1c9b78f9e3c1b29048ee6ce41e3729ecd0bf7433833bb25603ed5d4d9099598715a5
|
data/CHANGELOG
ADDED
data/CONTRIBUTORS
ADDED
File without changes
|
data/DESCRIPTION
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
Copyright (c) 2017 Vantiv eCommerce.
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person
|
4
|
+
obtaining a copy of this software and associated documentation
|
5
|
+
files (the "Software"), to deal in the Software without
|
6
|
+
restriction, including without limitation the rights to use,
|
7
|
+
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
copies of the Software, and to permit persons to whom the
|
9
|
+
Software is furnished to do so, subject to the following
|
10
|
+
conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be
|
13
|
+
included in all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
17
|
+
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
19
|
+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
20
|
+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
21
|
+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
22
|
+
OTHER DEALINGS IN THE SOFTWARE.
|
23
|
+
=======
|
24
|
+
MIT License
|
25
|
+
|
26
|
+
Copyright (c) 2018 vantiv
|
27
|
+
|
28
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
29
|
+
of this software and associated documentation files (the "Software"), to deal
|
30
|
+
in the Software without restriction, including without limitation the rights
|
31
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
32
|
+
copies of the Software, and to permit persons to whom the Software is
|
33
|
+
furnished to do so, subject to the following conditions:
|
34
|
+
|
35
|
+
The above copyright notice and this permission notice shall be included in all
|
36
|
+
copies or substantial portions of the Software.
|
37
|
+
|
38
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
39
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
40
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
41
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
42
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
43
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
44
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
# cnp-chargeback-sdk-ruby
|
2
|
+
Ruby SDK implementing Vantiv eCommerce Chargeback API
|
3
|
+
|
4
|
+
About Vantiv eCommerce
|
5
|
+
------------
|
6
|
+
[Vantiv eCommerce](https://developer.vantiv.com/community/ecommerce) powers the payment processing engines for leading companies that sell directly to consumers through internet retail, direct response marketing (TV, radio and telephone), and online services. Vantiv eCommerce is the leading authority in card-not-present (CNP) commerce, transaction processing and merchant services.
|
7
|
+
|
8
|
+
About this SDK
|
9
|
+
--------------
|
10
|
+
The Vantiv eCommerce Ruby Chargeback SDK is a Ruby implementation of the [Vantiv eCommerce](https://developer.vantiv.com/community/ecommerce) Chargeback API. This SDK was created to make it as easy as possible to manage your chargebacks using Vantiv eCommerce API. This SDK utilizes the HTTPS protocol to securely connect to Vantiv eCommerce. Using the SDK requires coordination with the Vantiv eCommerce team in order to be provided with credentials for accessing our systems.
|
11
|
+
|
12
|
+
Each Ruby Chargeback SDK release supports all of the functionality present in the associated Vantiv eCommerce Chargeback API version (e.g., SDK v2.1.0 supports Vantiv eCommerce Chargeback API v2.1). Please see the Chargeback API reference guide to get more details on what the Vantiv eCommerce chargeback engine supports.
|
13
|
+
|
14
|
+
See LICENSE file for details on using this software.
|
15
|
+
|
16
|
+
Source Code available from : [https://github.com/Vantiv/cnp-sdk-for-ruby](https://github.com/Vantiv/cnp-chargeback-sdk-ruby)
|
17
|
+
|
18
|
+
Please contact [Vantiv eCommerce](https://developer.vantiv.com/community/ecommerce) to receive valid merchant credentials in order to run tests successfully or if you require assistance in any way. We are reachable at sdksupport@Vantiv.com
|
19
|
+
|
20
|
+
|
21
|
+
Setup
|
22
|
+
-----
|
23
|
+
|
24
|
+
1) Install the CnpChargeback Ruby gem from rubygems.org, this will install the latest SDK gem in your Ruby environment.
|
25
|
+
Our gem is available publicly from rubygems.org. Use the command below to install.
|
26
|
+
|
27
|
+
>sudo gem install CnpChargeback
|
28
|
+
|
29
|
+
Note: If you get errors, you might have to configure your proxy.
|
30
|
+
|
31
|
+
2) Once the gem is installed run our setup program to generate a configuration file. The configuration file resides in your home directory
|
32
|
+
$HOME/.cnp_chargeback_config.yml
|
33
|
+
|
34
|
+
For more details on setup see our instructions [here](https://github.com/Vantiv/cnp-sdk-for-ruby/blob/12.X/SETUP.md)
|
35
|
+
|
36
|
+
3) Example usage:
|
37
|
+
|
38
|
+
```ruby
|
39
|
+
require 'CnpChargeback'
|
40
|
+
include CnpChargeback
|
41
|
+
|
42
|
+
# Retrieving information about a chargeback by caseId:
|
43
|
+
response = ChargebackRetrieval.new.get_chargeback_by_case_id(case_id: "123")
|
44
|
+
#access response elements
|
45
|
+
transactionId = response.transactionId
|
46
|
+
cycle = response.cycle
|
47
|
+
|
48
|
+
# Retrieving a list of chargebacks by activity date
|
49
|
+
response = ChargebackRetrieval.new.get_chargebacks_by_date(activity_date: "2018-01-01")
|
50
|
+
# access response elements
|
51
|
+
transactionId = response[5].transactionId
|
52
|
+
cycle = response[3].cycle
|
53
|
+
|
54
|
+
# Update chargeback case
|
55
|
+
ChargebackUpdate.new.represent_case(case_id: 10000, note: "Test note", representment_amount: 12000)
|
56
|
+
response = ChargebackUpdate.new.assign_case_to_user(case_id: 10000, user_id: "jdeo@company.com", note: "Test note")
|
57
|
+
|
58
|
+
# Upload document
|
59
|
+
response = ChargebackDocument.new.upload_document(case_id: "10000", document_path: "invoice.pdf")
|
60
|
+
response_code = response.responseCode
|
61
|
+
|
62
|
+
# Retrieve a list of documents by case id
|
63
|
+
response = ChargebackDocument.new.list_documents(case_id: "10000")
|
64
|
+
document_list = response.documentId
|
65
|
+
```
|
66
|
+
|
67
|
+
|
68
|
+
Please contact Vantiv eCommerce with any further questions. You can reach us at sdksupport@vantiv.com.
|
69
|
+
|
70
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,90 @@
|
|
1
|
+
# Copyright (c) 2018 Vantiv eCommerce.
|
2
|
+
#
|
3
|
+
# Permission is hereby granted, free of charge, to any person
|
4
|
+
# obtaining a copy of this software and associated documentation
|
5
|
+
# files (the "Software"), to deal in the Software without
|
6
|
+
# restriction, including without limitation the rights to use,
|
7
|
+
# copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
# copies of the Software, and to permit persons to whom the
|
9
|
+
# Software is furnished to do so, subject to the following
|
10
|
+
# conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be
|
13
|
+
# included in all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
17
|
+
# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
# NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
19
|
+
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
20
|
+
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
21
|
+
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
22
|
+
# OTHER DEALINGS IN THE SOFTWARE.
|
23
|
+
require 'rubygems'
|
24
|
+
require 'rubygems/package_task'
|
25
|
+
require 'rake/testtask'
|
26
|
+
require 'rake/clean'
|
27
|
+
|
28
|
+
spec = Gem::Specification.new do |s|
|
29
|
+
FileUtils.rm_rf('pkg')
|
30
|
+
s.name = 'CnpChargeback'
|
31
|
+
s.summary = 'Ruby Chargeback SDK produced by Vantiv eCommerce for chargeback processing using Vantiv eCommerce XML format v12.3'
|
32
|
+
s.description = File.read(File.join(File.dirname(__FILE__), 'DESCRIPTION'))
|
33
|
+
s.requirements =
|
34
|
+
['Contact sdksupport@vantiv.com for more information']
|
35
|
+
s.version = '2.1'
|
36
|
+
s.author = 'Vantiv - eCommerce'
|
37
|
+
s.email = 'sdksupport@vantiv.com'
|
38
|
+
s.homepage = 'https://developer.vantiv.com/community/ecommerce/pages/sdks#jive_content_id_Ruby_SDK'
|
39
|
+
s.platform = Gem::Platform::RUBY
|
40
|
+
s.required_ruby_version = '>=2.2.0'
|
41
|
+
s.files = Dir['**/**']
|
42
|
+
s.test_files = Dir['test/unit/ts_unit.rb']
|
43
|
+
s.has_rdoc = true
|
44
|
+
s.add_dependency('xml-object')
|
45
|
+
s.add_dependency('xml-mapping')
|
46
|
+
s.add_dependency('mimemagic')
|
47
|
+
s.add_dependency('net-sftp')
|
48
|
+
s.add_dependency('libxml-ruby')
|
49
|
+
s.add_dependency('crack')
|
50
|
+
s.add_dependency('iostreams')
|
51
|
+
s.add_development_dependency('mocha')
|
52
|
+
end
|
53
|
+
|
54
|
+
Gem::PackageTask.new(spec) do |pkg|
|
55
|
+
pkg.gem_spec = spec
|
56
|
+
pkg.need_zip = true
|
57
|
+
pkg.need_tar = true
|
58
|
+
end
|
59
|
+
|
60
|
+
namespace :test do
|
61
|
+
Rake::TestTask.new do |t|
|
62
|
+
t.libs << '.'
|
63
|
+
t.name = 'unit'
|
64
|
+
t.test_files = FileList['test/unit/ts_unit.rb']
|
65
|
+
t.verbose = true
|
66
|
+
end
|
67
|
+
|
68
|
+
Rake::TestTask.new do |t|
|
69
|
+
t.libs << '.'
|
70
|
+
t.name = 'functional'
|
71
|
+
t.test_files = FileList['test/functional/ts_all.rb']
|
72
|
+
t.verbose = true
|
73
|
+
end
|
74
|
+
|
75
|
+
Rake::TestTask.new do |t|
|
76
|
+
t.libs << '.'
|
77
|
+
t.name = 'certification'
|
78
|
+
t.test_files = FileList['test/certification/certTest*.rb']
|
79
|
+
t.verbose = true
|
80
|
+
end
|
81
|
+
|
82
|
+
Rake::TestTask.new do |t|
|
83
|
+
t.libs << '.'
|
84
|
+
t.name = 'all'
|
85
|
+
t.test_files = FileList['test/**/*.rb']
|
86
|
+
t.verbose = true
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
task default: 'gem'
|
data/SETUP.md
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
Setting up and Configuring the Vantiv eCommerce Chargeback SDK
|
2
|
+
=========================================
|
3
|
+
|
4
|
+
Running the built in configuration file generator
|
5
|
+
-------------------------------------------------
|
6
|
+
The Ruby Chargeback SDK ships with a built in program which can be used to generate your specific configuration.
|
7
|
+
|
8
|
+
This program runs as follows:
|
9
|
+
|
10
|
+
```
|
11
|
+
>Setup.rb
|
12
|
+
Welcome to Vantiv eCommerce Ruby_Chargeback_SDK
|
13
|
+
please input your user name:
|
14
|
+
test_user
|
15
|
+
please input your password:
|
16
|
+
test_password
|
17
|
+
Please choose Vantiv eCommerce url from the following list (example: 'prelive') or directly input another URL:
|
18
|
+
sandbox => https://www.testvantivcnp.com/services/chargebacks
|
19
|
+
prelive => https://payments.vantivprelive.com/services/chargebacks
|
20
|
+
sandbox
|
21
|
+
Please input the proxy address, if no proxy hit enter key:
|
22
|
+
|
23
|
+
Please input the proxy port, if no proxy hit enter key:
|
24
|
+
|
25
|
+
The Vantiv eCommerce configuration file has been generated, the file is located at: /<your-home-directory>/.cnp_chargeback_config.yml
|
26
|
+
```
|
27
|
+
|
28
|
+
Modifying your configuration
|
29
|
+
----------------------------
|
30
|
+
You may change the configuration values at anytime by running Setup.rb again, or simpy opening the configuration file directly in the editor of your choice and changing the appropriate fields.
|
31
|
+
|
32
|
+
Changing the location of the Cnp configuration file:
|
33
|
+
------------------------------------------------------
|
34
|
+
NOTICE you can set the environment variable $CNP_CB_CONFIG_DIR to locate your configuration file in a location other than the $HOME Directory, the the file will reside in $CNP_CB_CONFIG_DIR/.cnp_chargeback_config.yml
|
35
|
+
|
36
|
+
Sample configuration file contents
|
37
|
+
----------------------------------
|
38
|
+
```
|
39
|
+
user: test_user
|
40
|
+
password: test_password
|
41
|
+
url: https://www.testvantivcnp.com/services/chargebacks
|
42
|
+
proxy_addr: yourproxyserver
|
43
|
+
proxy_port: 8080
|
44
|
+
```
|
data/bin/Setup.rb
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
=begin
|
4
|
+
Copyright (c) 2017 Vantiv eCommerce
|
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
|
+
NON-INFRINGEMENT. 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
|
+
# make setup file executable
|
29
|
+
require 'iostreams'
|
30
|
+
|
31
|
+
#
|
32
|
+
# Configuration generation for URL and credentials
|
33
|
+
#
|
34
|
+
class Setup
|
35
|
+
attr_reader :handle, :path
|
36
|
+
def initialize(filename)
|
37
|
+
@handle = File.new(filename, File::CREAT|File::TRUNC|File::RDWR, 0600)
|
38
|
+
File.open(filename, 'w') do |f|
|
39
|
+
puts 'Welcome to Vantiv eCommerce Ruby_SDK'
|
40
|
+
puts 'Please input your user name:'
|
41
|
+
f.puts 'user: '+ gets
|
42
|
+
puts 'Please input your password:'
|
43
|
+
f.puts 'password: ' + gets
|
44
|
+
puts 'Please input your merchantId:'
|
45
|
+
f.puts 'merchantID: ' + gets
|
46
|
+
puts "Please choose Vantiv eCommerce url from the following list (example: 'prelive') or directly input another URL:
|
47
|
+
sandbox => https://www.testvantivcnp.com/services/chargebacks
|
48
|
+
prelive => https://payments.vantivprelive.com/services/chargebacks"
|
49
|
+
f.puts 'url: ' + Setup.choice(gets)
|
50
|
+
puts 'Please input the proxy address, if no proxy hit enter key: '
|
51
|
+
f.puts 'proxy_addr: ' + gets
|
52
|
+
puts 'Please input the proxy port, if no proxy hit enter key: '
|
53
|
+
f.puts 'proxy_port: ' + gets
|
54
|
+
f.puts 'printxml: false'
|
55
|
+
# default http timeout set to 500 ms
|
56
|
+
f.puts 'timeout: 500'
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def finished
|
61
|
+
@handle.close
|
62
|
+
end
|
63
|
+
|
64
|
+
def Setup.choice(cnp_env)
|
65
|
+
if cnp_env == "sandbox\n"
|
66
|
+
return 'https://www.testvantivcnp.com/spring/services/chargebacks'
|
67
|
+
elsif cnp_env == "prelive\n"
|
68
|
+
return 'https://payments.vantivprelive.com/services/chargebacks'
|
69
|
+
else
|
70
|
+
return 'https://www.testvantivcnp.com/spring/chargebacks'
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
#
|
76
|
+
#
|
77
|
+
# Optionally enable the configuration to reside in a custom location
|
78
|
+
# if the $CNP_CB_CONFIG_DIR directory is set
|
79
|
+
#
|
80
|
+
|
81
|
+
# make the config.yml file in the CNP_CB_CONFIG_DIR directory or HOME directory
|
82
|
+
if !(ENV['CNP_CB_CONFIG_DIR'].nil?)
|
83
|
+
path = ENV['CNP_CB_CONFIG_DIR']
|
84
|
+
else
|
85
|
+
path = ENV['HOME']
|
86
|
+
end
|
87
|
+
|
88
|
+
# make the config.yml file hidden
|
89
|
+
# create a config file contain all the configuration data
|
90
|
+
config_file = path + '/.cnp_chargeback_config.yml'
|
91
|
+
f = Setup.new(config_file)
|
92
|
+
|
93
|
+
# return the path of the config file and the path file
|
94
|
+
@path = File.expand_path(config_file)
|
95
|
+
puts 'The Vantiv eCommerce configuration file has been generated, the file is located at: ' + @path
|
96
|
+
f.finished
|
97
|
+
|
@@ -0,0 +1,67 @@
|
|
1
|
+
=begin
|
2
|
+
Copyright (c) 2017 Vantiv eCommerce
|
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
|
+
require_relative 'Configuration'
|
26
|
+
|
27
|
+
#
|
28
|
+
# This class handles sending the Cnp online request
|
29
|
+
#
|
30
|
+
module CnpOnline
|
31
|
+
|
32
|
+
class ChargebackDocument
|
33
|
+
def initialize
|
34
|
+
@config_hash = Configuration.new.config
|
35
|
+
end
|
36
|
+
|
37
|
+
def retrieve_document(case_id:, document_id:, document_path:, config: @config_hash)
|
38
|
+
request_url = config['url'] + "/retrieve/" + case_id.to_s + "/" + document_id.to_s
|
39
|
+
Communications.http_get_document_request(request_url, document_path, config)
|
40
|
+
end
|
41
|
+
|
42
|
+
def upload_document(case_id:, document_path:, config: @config_hash)
|
43
|
+
document_id = document_path.split("/")[-1]
|
44
|
+
request_url = config['url'] + "/upload/" + case_id + "/" + document_id
|
45
|
+
response_xml = Communications.http_post_document_request(request_url, document_path, config)
|
46
|
+
return XMLObject.new(response_xml)
|
47
|
+
end
|
48
|
+
|
49
|
+
def replace_document(case_id:, document_id:, document_path:, config: @config_hash)
|
50
|
+
request_url = config['url'] + "/replace/" + case_id + "/" + document_id
|
51
|
+
response_xml = Communications.http_put_document_request(request_url, document_path, config)
|
52
|
+
return XMLObject.new(response_xml)
|
53
|
+
end
|
54
|
+
|
55
|
+
def delete_document(case_id:, document_id:, config: @config_hash)
|
56
|
+
request_url = config['url'] + "/delete/" + case_id + "/" + document_id
|
57
|
+
response_xml = Communications.http_delete_document_request(request_url, config)
|
58
|
+
return XMLObject.new(response_xml)
|
59
|
+
end
|
60
|
+
|
61
|
+
def list_documents(case_id:, config: @config_hash)
|
62
|
+
request_url = config['url'] + "/list/" + case_id
|
63
|
+
response_xml = Communications.http_get_document_list_request(request_url, config)
|
64
|
+
return XMLObject.new(response_xml)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,85 @@
|
|
1
|
+
=begin
|
2
|
+
Copyright (c) 2017 Vantiv eCommerce
|
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
|
+
require_relative 'Configuration'
|
26
|
+
|
27
|
+
#
|
28
|
+
# This class handles sending the Cnp online request
|
29
|
+
#
|
30
|
+
module CnpOnline
|
31
|
+
|
32
|
+
class ChargebackRetrieval
|
33
|
+
def initialize
|
34
|
+
@config_hash = Configuration.new.config
|
35
|
+
end
|
36
|
+
|
37
|
+
def get_chargebacks_by_date(activity_date:, config: @config_hash)
|
38
|
+
return _get_retrieval_response({date: activity_date}, config)
|
39
|
+
end
|
40
|
+
|
41
|
+
def get_chargebacks_by_financial_impact(activity_date:, financial_impact:, config: @config_hash)
|
42
|
+
return _get_retrieval_response({date: activity_date, financialOnly: financial_impact}, config)
|
43
|
+
end
|
44
|
+
|
45
|
+
def get_actionable_chargebacks(actionable:, config: @config_hash)
|
46
|
+
return _get_retrieval_response({actionable: actionable}, config)
|
47
|
+
end
|
48
|
+
|
49
|
+
def get_chargeback_by_case_id(case_id:, config: @config_hash)
|
50
|
+
return _get_retrieval_response({}, config, case_id)
|
51
|
+
end
|
52
|
+
|
53
|
+
def get_chargebacks_by_token(token:, config: @config_hash)
|
54
|
+
return _get_retrieval_response({token: token}, config)
|
55
|
+
end
|
56
|
+
|
57
|
+
def get_chargebacks_by_card_number(card_number:, expiration_date:, config: @config_hash)
|
58
|
+
return _get_retrieval_response({cardNumber: card_number, expirationDate: expiration_date}, config)
|
59
|
+
end
|
60
|
+
|
61
|
+
def get_chargebacks_by_arn(arn:, config: @config_hash)
|
62
|
+
return _get_retrieval_response({arn: arn}, config)
|
63
|
+
end
|
64
|
+
|
65
|
+
private
|
66
|
+
|
67
|
+
def _get_retrieval_response(parameters, config, endpoint=nil)
|
68
|
+
request_url = config['url']
|
69
|
+
prefix = "?"
|
70
|
+
|
71
|
+
if endpoint
|
72
|
+
request_url += "/" + endpoint
|
73
|
+
end
|
74
|
+
|
75
|
+
parameters.each_key do |name|
|
76
|
+
request_url += prefix + name.to_s + "=" + parameters[name]
|
77
|
+
prefix = "&"
|
78
|
+
end
|
79
|
+
|
80
|
+
response_xml = Communications.http_get_retrieval_request(request_url, config)
|
81
|
+
return XMLObject.new(response_xml)
|
82
|
+
end
|
83
|
+
|
84
|
+
end
|
85
|
+
end
|