merchant_e_solutions 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 35998008dbdf12b863aa699240c8857aaeba469a
4
- data.tar.gz: a5165942271e73270c351152e3f5e67e463f50b9
3
+ metadata.gz: 84550333afd6acc5e0b4f4eaca679cdf55a0ec41
4
+ data.tar.gz: 92d3ae4bc28465a85d3f109f938533b8aa8c4b7f
5
5
  SHA512:
6
- metadata.gz: f234059d25c33dba5f2a7e19f88300f5bf034b4a0bd0b2921bae344cbbc69dfc3928dc4f7ec7bf413cf4f63c26a3d3e4445e73a2ae000fee397214ceb9d6fd20
7
- data.tar.gz: 7aa4a3f42ca41833b94d254f71dd18c0efa642e59d924c4ac4ebfb2ea54af7b73935455c9e1c0578f8cffdcfa54028b0c4f2a2ed223be7453a00dbcc84325159
6
+ metadata.gz: 9f01b2763eaa5abbdc14b72fb1994083444faba8bccb95d4e9429d337b3e5ee91f4c31f5eacbf5c161ff24a1868b70634b96410134854596ed7cb7498daee577
7
+ data.tar.gz: 2226690b22c075426736a8ce4007296459a04c778efd28b3ea836ab599d447bfc3dd3b52b3183e98e34381ac11b7ac9b1f735204afec729e76b59cae94433e2f
@@ -1,9 +1,10 @@
1
1
  require 'merchant_e_solutions/configuration'
2
2
  require 'merchant_e_solutions/report'
3
3
  require 'merchant_e_solutions/request'
4
- require 'merchant_e_solutions/deposit_report'
4
+ require 'merchant_e_solutions/adjustment_report'
5
5
  require 'merchant_e_solutions/batch_detail_report'
6
6
  require 'merchant_e_solutions/batch_summary_report'
7
+ require 'merchant_e_solutions/deposit_report'
7
8
  require 'merchant_e_solutions/settlement_detail_report'
8
9
  require 'merchant_e_solutions/settlement_summary_report'
9
10
 
@@ -33,6 +34,10 @@ module MerchantESolutions
33
34
  def deposit_report(options = {})
34
35
  DepositReport.new(options)
35
36
  end
37
+
38
+ def adjustment_report(options = {})
39
+ AdjustmentReport.new(options)
40
+ end
36
41
  end
37
42
 
38
43
  end
@@ -0,0 +1,31 @@
1
+ require 'merchant_e_solutions/record'
2
+
3
+ module MerchantESolutions
4
+ class AdjustmentRecord < Record
5
+
6
+ attr_reader :organization_id, :organization_name, :control_number, :incoming_date,
7
+ :card_number, :reference_id, :transaction_date, :transaction_amount,
8
+ :authorization_code, :adjustment_date, :adjustment_reference_number,
9
+ :reason, :first_time, :reason_code, :cb_reference_number, :terminal_id
10
+
11
+
12
+ def initialize(row)
13
+ @organization_id = row[0]
14
+ @organization_name = row[1]
15
+ @control_number = row[2]
16
+ @incoming_date = parse_date(row[3])
17
+ @card_number = row[4]
18
+ @reference_id = row[5]
19
+ @transaction_date = parse_date(row[6])
20
+ @transaction_amount = row[7]
21
+ @authorization_code = row[8]
22
+ @adjustment_date = parse_date(row[9])
23
+ @adjustment_reference_number = row[10]
24
+ @reason = row[11]
25
+ @first_time = parse_boolean(row[12])
26
+ @reason_code = row[13]
27
+ @cb_reference_number = row[14]
28
+ @terminal_id = row[15]
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,21 @@
1
+ require 'merchant_e_solutions/adjustment_record'
2
+
3
+ module MerchantESolutions
4
+ class AdjustmentReport < Report
5
+
6
+
7
+ private
8
+
9
+ def report_id
10
+ 5
11
+ end
12
+
13
+ def report_type
14
+ 1
15
+ end
16
+
17
+ def record_class
18
+ AdjustmentRecord
19
+ end
20
+ end
21
+ end
@@ -5,7 +5,13 @@ module MerchantESolutions
5
5
  private
6
6
 
7
7
  def parse_date(date)
8
- Date.strptime(date, "%m/%d/%Y") if date
8
+ if date && !date.empty?
9
+ Date.strptime(date, "%m/%d/%Y")
10
+ end
11
+ end
12
+
13
+ def parse_boolean(string)
14
+ ['y', 'yes'].include? string.downcase
9
15
  end
10
16
 
11
17
  end
@@ -5,7 +5,7 @@ module MerchantESolutions
5
5
  attr_reader :records, :request
6
6
 
7
7
  def initialize(params = {})
8
- self.options = params
8
+ self.options = parse_params(params)
9
9
  @request = Request.new(request_params)
10
10
  parse_records(request.body)
11
11
  end
@@ -47,5 +47,23 @@ module MerchantESolutions
47
47
  records << record_class.new(csv)
48
48
  end
49
49
  end
50
+
51
+ def parse_params(params)
52
+ parse_out_date(params, "begin")
53
+ parse_out_date(params, "end")
54
+
55
+ params
56
+ end
57
+
58
+ def parse_out_date(params, type)
59
+ key = "#{type}_date"
60
+ if date = params.delete(key) || params.delete(key.to_sym)
61
+ params.merge!({
62
+ "#{type}Date.day" => date.day,
63
+ "#{type}Date.month" => (date.month - 1),
64
+ "#{type}Date.year" => date.year,
65
+ })
66
+ end
67
+ end
50
68
  end
51
69
  end
@@ -1,3 +1,3 @@
1
1
  module MerchantESolutions
2
- VERSION = "0.3.0"
2
+ VERSION = "0.4.0"
3
3
  end
@@ -0,0 +1,3 @@
1
+ "Merchant Id","DBA Name","Control Number","Incoming Date","Card Number","Reference Number","Tran Date","Tran Amount","Auth Code","Adj Date","Adj Ref Num","Reason","First Time","Reason Code","CB Ref Num","Terminal ID"
2
+ 44,"Hamazon",224,08/11/2014,654321xxxxxx1234,'1176620,07/27/2014,15.0,,"08/10/2013-","1176538","Fraud - Card Not Present Transaction",Y,UA02,802061219,""
3
+ 44,"Hamazon",248,10/13/2014,123456xxxxxx4321,'16768007605410284,10/10/2014,40.0,03500P,"10/10/2013-","00001471124","No Cardholder Authorization",Y,4837,319290029,""
@@ -0,0 +1,39 @@
1
+ require 'spec_helper'
2
+
3
+ describe MerchantESolutions::AdjustmentRecord do
4
+ describe "#initialize" do
5
+ subject { MerchantESolutions::AdjustmentRecord.new(csv_row) }
6
+
7
+ #"Merchant Id","DBA Name","Control Number","Incoming Date","Card Number","Reference Number","Tran Date","Tran Amount","Auth Code","Adj Date","Adj Ref Num","Reason","First Time","Reason Code","CB Ref Num","Terminal ID"
8
+ let(:csv_row) { [44, "Hamazon", 224, "08/11/2014", "654321xxxxxx1234", "'1176620", "07/27/2014", 15.0, 'aaa', "08/10/2013-", "1176538", "Fraud - Card Not Present Transaction", "Y", "UA02", 802061219, "b"] }
9
+
10
+ its(:organization_id) { should == 44 }
11
+ its(:organization_name) { should == "Hamazon" }
12
+ its(:control_number) { should == 224 }
13
+ it "parses out the incoming date" do
14
+ subject.incoming_date.day.should == 11
15
+ subject.incoming_date.month.should == 8
16
+ subject.incoming_date.year.should == 2014
17
+ end
18
+ its(:card_number) { "654321xxxxxx1234" }
19
+ its(:reference_id) { "1176620" }
20
+ it "parses out the transaction date" do
21
+ subject.transaction_date.day.should == 27
22
+ subject.transaction_date.month.should == 7
23
+ subject.transaction_date.year.should == 2014
24
+ end
25
+ its(:transaction_amount) { should == 15.0 }
26
+ its(:authorization_code) { 'aaa' }
27
+ it "parses out the adjustment date" do
28
+ subject.adjustment_date.day.should == 10
29
+ subject.adjustment_date.month.should == 8
30
+ subject.adjustment_date.year.should == 2013
31
+ end
32
+ its(:adjustment_reference_number) { should == '1176538' }
33
+ its(:reason) { should == "Fraud - Card Not Present Transaction" }
34
+ its(:first_time) { should == true }
35
+ its(:reason_code) { should == "UA02" }
36
+ its(:cb_reference_number) { should == 802061219 }
37
+ its(:terminal_id) { should == "b" }
38
+ end
39
+ end
@@ -0,0 +1,41 @@
1
+ require 'spec_helper'
2
+
3
+ describe MerchantESolutions::AdjustmentReport do
4
+ before { stub_net_http_requests }
5
+
6
+ describe "#initialize" do
7
+ let(:request) { double(:request, body: request_fixture('adjustment_report')) }
8
+ before { MerchantESolutions::Request.stub(:new).and_return(request) }
9
+
10
+ it "parses the body of the request as a CSV" do
11
+ report = MerchantESolutions::AdjustmentReport.new
12
+
13
+ report.records.size.should be > 0
14
+
15
+ report.records.each do |record|
16
+ record.should be_a MerchantESolutions::AdjustmentRecord
17
+ end
18
+ end
19
+ end
20
+
21
+ describe "#request_params" do
22
+ let(:request_params) { MerchantESolutions::AdjustmentReport.new(options).request_params }
23
+ let(:options) { Hash.new }
24
+
25
+ it "knows its dsReportId" do
26
+ request_params[:dsReportId].should == 5
27
+ end
28
+
29
+ it "knows its reportType" do
30
+ request_params[:reportType].should == 1
31
+ end
32
+
33
+ context "when options are passed in" do
34
+ let(:options) { {test: 'params'} }
35
+
36
+ it "merges in the options" do
37
+ request_params[:test].should == 'params'
38
+ end
39
+ end
40
+ end
41
+ end
@@ -4,7 +4,7 @@ describe MerchantESolutions::DepositReport do
4
4
  before { stub_net_http_requests }
5
5
 
6
6
  describe "#initialize" do
7
- let(:request) { double(:request, body: request_fixture('detail_report')) }
7
+ let(:request) { double(:request, body: request_fixture('deposit_report')) }
8
8
  before { MerchantESolutions::Request.stub(:new).and_return(request) }
9
9
 
10
10
  it "parses the body of the request as a CSV" do
@@ -22,6 +22,21 @@ describe MerchantESolutions::Report do
22
22
 
23
23
  TestSubReport.new
24
24
  end
25
+
26
+ it "parses out a date into usable request params for start and end dates" do
27
+ begin_date = Date.parse('10/11/2012')
28
+ end_date = Date.parse('11/12/2013')
29
+
30
+ report = TestSubReport.new(begin_date: begin_date, end_date: end_date)
31
+
32
+ report.request_params["beginDate.day"].should == begin_date.day
33
+ report.request_params["beginDate.month"].should == (begin_date.month - 1)
34
+ report.request_params["beginDate.year"].should == begin_date.year
35
+
36
+ report.request_params["endDate.day"].should == end_date.day
37
+ report.request_params["endDate.month"].should == (end_date.month - 1)
38
+ report.request_params["endDate.year"].should == end_date.year
39
+ end
25
40
  end
26
41
 
27
42
  describe "#request_params" do
@@ -72,4 +72,18 @@ describe MerchantESolutions do
72
72
  MerchantESolutions.deposit_report(options)
73
73
  end
74
74
  end
75
+
76
+ describe ".adjustment_report" do
77
+ it "returns an Instance of MerchantESolution::SettlementReport" do
78
+ MerchantESolutions.adjustment_report.should be_a MerchantESolutions::AdjustmentReport
79
+ end
80
+
81
+ it "passes all options directly through to the new SettlementReport" do
82
+ options = {hash: "with", any: "keys", and: "values"}
83
+
84
+ MerchantESolutions::AdjustmentReport.should_receive(:new).with(options)
85
+
86
+ MerchantESolutions.adjustment_report(options)
87
+ end
88
+ end
75
89
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: merchant_e_solutions
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steve Ellis
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-10-10 00:00:00.000000000 Z
12
+ date: 2013-10-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -82,6 +82,8 @@ files:
82
82
  - README.md
83
83
  - Rakefile
84
84
  - lib/merchant_e_solutions.rb
85
+ - lib/merchant_e_solutions/adjustment_record.rb
86
+ - lib/merchant_e_solutions/adjustment_report.rb
85
87
  - lib/merchant_e_solutions/batch_detail_report.rb
86
88
  - lib/merchant_e_solutions/batch_summary_report.rb
87
89
  - lib/merchant_e_solutions/configuration.rb
@@ -96,10 +98,13 @@ files:
96
98
  - lib/merchant_e_solutions/summary_record.rb
97
99
  - lib/merchant_e_solutions/version.rb
98
100
  - merchant_e_solutions.gemspec
101
+ - spec/fixtures/adjustment_report.csv
99
102
  - spec/fixtures/batch_summary.csv
100
- - spec/fixtures/detail_report.csv
103
+ - spec/fixtures/deposit_report.csv
101
104
  - spec/fixtures/settlement_detail.csv
102
105
  - spec/fixtures/settlement_summary.csv
106
+ - spec/lib/merchant_e_solutions/adjustment_record_spec.rb
107
+ - spec/lib/merchant_e_solutions/adjustment_report_spec.rb
103
108
  - spec/lib/merchant_e_solutions/batch_detail_report_spec.rb
104
109
  - spec/lib/merchant_e_solutions/batch_summary_report_spec.rb
105
110
  - spec/lib/merchant_e_solutions/deposit_record_spec.rb
@@ -137,10 +142,13 @@ signing_key:
137
142
  specification_version: 4
138
143
  summary: Wrapper for the Settlement Report API
139
144
  test_files:
145
+ - spec/fixtures/adjustment_report.csv
140
146
  - spec/fixtures/batch_summary.csv
141
- - spec/fixtures/detail_report.csv
147
+ - spec/fixtures/deposit_report.csv
142
148
  - spec/fixtures/settlement_detail.csv
143
149
  - spec/fixtures/settlement_summary.csv
150
+ - spec/lib/merchant_e_solutions/adjustment_record_spec.rb
151
+ - spec/lib/merchant_e_solutions/adjustment_report_spec.rb
144
152
  - spec/lib/merchant_e_solutions/batch_detail_report_spec.rb
145
153
  - spec/lib/merchant_e_solutions/batch_summary_report_spec.rb
146
154
  - spec/lib/merchant_e_solutions/deposit_record_spec.rb