global_collect 0.4.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.0
1
+ 0.5.0
@@ -70,15 +70,14 @@ puts "This is a multi-stage example. Please read the source for instructions."
70
70
  # response = client.make_request(
71
71
  # GlobalCollect::Requests::DoPayment.new(
72
72
  # [
73
- # GlobalCollect::RequestModels::DoPayment::RecurringPayment.new(
73
+ # GlobalCollect::RequestModels::DoPayment::RecurringCreditCardOnlinePayment.new(
74
74
  # "MERCHANTREFERENCE" => "1231147777",
75
75
  # "ORDERID" => "7777",
76
76
  # "EFFORTID" => "2", # increment implied EFFORTID of 1 from IOWP
77
- # "PAYMENTPRODUCTID" => "3",
78
- # "AMOUNT" => "50",
79
- # "CURRENCYCODE" => "GBP"
77
+ # "AMOUNT" => "1400",
78
+ # "CURRENCYCODE" => "USD"
80
79
  # ),
81
- # GlobalCollect::Builders::DoPayment::RecurringPayment
80
+ # GlobalCollect::Builders::DoPayment::RecurringCreditCardOnlinePayment
82
81
  # ]
83
82
  # )
84
83
  # )
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{global_collect}
8
- s.version = "0.4.0"
8
+ s.version = "0.5.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Timon Karnezos"]
12
- s.date = %q{2010-09-23}
12
+ s.date = %q{2010-09-27}
13
13
  s.description = %q{Gives minimally intrusive access to Global Collect's payment processing API.
14
14
  Currently implements a very small segment of the full API but is built with
15
15
  extensibility in mind.
@@ -41,6 +41,7 @@ extensibility in mind.
41
41
  "lib/global_collect.rb",
42
42
  "lib/global_collect/api_client.rb",
43
43
  "lib/global_collect/builders/do_payment/payment.rb",
44
+ "lib/global_collect/builders/do_payment/recurring_credit_card_online_payment.rb",
44
45
  "lib/global_collect/builders/do_payment/recurring_payment.rb",
45
46
  "lib/global_collect/builders/do_refund/credit_card_payment.rb",
46
47
  "lib/global_collect/builders/do_refund/payment.rb",
@@ -64,6 +65,7 @@ extensibility in mind.
64
65
  "lib/global_collect/log_parsing/payment_report/report_file.rb",
65
66
  "lib/global_collect/request_models/base.rb",
66
67
  "lib/global_collect/request_models/do_payment/payment.rb",
68
+ "lib/global_collect/request_models/do_payment/recurring_credit_card_online_payment.rb",
67
69
  "lib/global_collect/request_models/do_payment/recurring_payment.rb",
68
70
  "lib/global_collect/request_models/do_refund/credit_card_payment.rb",
69
71
  "lib/global_collect/request_models/do_refund/payment.rb",
@@ -118,6 +120,7 @@ extensibility in mind.
118
120
  "spec/log_parsing/payment_report/parser_spec.rb",
119
121
  "spec/log_parsing/payment_report/report_file_spec.rb",
120
122
  "spec/request_models/base_spec.rb",
123
+ "spec/request_models/do_payment/recurring_credit_card_online_payment_spec.rb",
121
124
  "spec/request_models/do_payment/recurring_payment_spec.rb",
122
125
  "spec/request_models/do_refund/paypal_payment_spec.rb",
123
126
  "spec/request_models/insert_order_with_payment/hosted_credit_card_online_payment_spec.rb",
@@ -185,6 +188,7 @@ extensibility in mind.
185
188
  "spec/log_parsing/payment_report/parser_spec.rb",
186
189
  "spec/log_parsing/payment_report/report_file_spec.rb",
187
190
  "spec/request_models/base_spec.rb",
191
+ "spec/request_models/do_payment/recurring_credit_card_online_payment_spec.rb",
188
192
  "spec/request_models/do_payment/recurring_payment_spec.rb",
189
193
  "spec/request_models/do_refund/paypal_payment_spec.rb",
190
194
  "spec/request_models/insert_order_with_payment/hosted_credit_card_online_payment_spec.rb",
@@ -0,0 +1,4 @@
1
+ module GlobalCollect::Builders::DoPayment
2
+ class RecurringCreditCardOnlinePayment < RecurringPayment
3
+ end
4
+ end
@@ -0,0 +1,22 @@
1
+ module GlobalCollect::RequestModels::DoPayment
2
+ class RecurringCreditCardOnlinePayment < RecurringPayment
3
+ def initialize(attributes)
4
+ super(attributes)
5
+ @attributes["CVVINDICATOR"] = "8"
6
+ end
7
+ def suggested_response_mixins
8
+ super + [GlobalCollect::Responses::DoPayment::CreditCardResponseMethods]
9
+ end
10
+ def fields
11
+ #
12
+ # Per # WDL §5.13 "Create Additional Payments" section, the CVVINDICATOR
13
+ # must be 8 for recurring payments.
14
+ #
15
+ super.merge({
16
+ "CVVINDICATOR" => ["N1", "R"]
17
+ })
18
+ end
19
+ end
20
+ end
21
+
22
+
@@ -1,13 +1,15 @@
1
1
  module GlobalCollect::RequestModels::DoPayment
2
2
  class RecurringPayment < Payment
3
- def suggested_response_mixins
4
- super + [GlobalCollect::Responses::DoPayment::CreditCardResponseMethods]
5
- end
6
3
  def fields
7
4
  # A recurring payment will never have the default EFFORTID of '1', hence
8
5
  # it is a required field.
6
+ #
7
+ # Also, a recurring payment recalls the existing payment information on
8
+ # the order, thus does not require a PAYMENTPRODUCTID, per # WDL §5.13
9
+ # "Variable amount recurring order payments" section.
9
10
  super.merge({
10
- "EFFORTID" => ["N5", "R"]
11
+ "EFFORTID" => ["N5", "R"],
12
+ "PAYMENTPRODUCTID" => ["N5", "O"]
11
13
  })
12
14
  end
13
15
  end
@@ -4,6 +4,14 @@ module GlobalCollect::RequestModels::InsertOrderWithPayment
4
4
  super(attributes)
5
5
  # WDL Appendix F specifies the recurring order type as '4'
6
6
  @attributes["ORDERTYPE"] = "4"
7
+ # WDL Appendix F specifies the recurring order should have STEPMONTH
8
+ # set to a filler value. They say a default of "120" is fine.
9
+ @attributes["STEPMONTH"] ||= "120"
10
+ end
11
+ def fields
12
+ super.merge({
13
+ "STEPMONTH" => ["N5", "R"]
14
+ })
7
15
  end
8
16
  end
9
17
  end
@@ -18,6 +18,7 @@ lib_dir = File.dirname(__FILE__)
18
18
  %w[api_client] ,
19
19
  %w[builders do_payment payment] ,
20
20
  %w[builders do_payment recurring_payment] ,
21
+ %w[builders do_payment recurring_credit_card_online_payment] ,
21
22
  %w[builders do_refund payment] ,
22
23
  %w[builders do_refund credit_card_payment] ,
23
24
  %w[builders insert_order_with_payment order] ,
@@ -47,6 +48,7 @@ lib_dir = File.dirname(__FILE__)
47
48
  %w[request_models insert_order_with_payment recurring_hosted_credit_card_online_payment],
48
49
  %w[request_models do_payment payment] ,
49
50
  %w[request_models do_payment recurring_payment] ,
51
+ %w[request_models do_payment recurring_credit_card_online_payment] ,
50
52
  %w[request_models do_refund payment] ,
51
53
  %w[request_models do_refund credit_card_payment] ,
52
54
  %w[request_models do_refund paypal_payment] ,
@@ -0,0 +1,39 @@
1
+ require File.join(File.dirname(__FILE__), '..', '..', 'spec_helper')
2
+
3
+ describe "the DO_PAYMENT recurring credit card online payment model" do
4
+ it "should force CVVINDICATOR to '8' when not provided" do
5
+ model = GlobalCollect::RequestModels::DoPayment::RecurringCreditCardOnlinePayment.new({
6
+ "MERCHANTREFERENCE" => "aasfd",
7
+ "ORDERID" => "123",
8
+ "PAYMENTPRODUCTID" => "1",
9
+ "AMOUNT" => "123",
10
+ "EFFORTID" => "2",
11
+ "CURRENCYCODE" => "USD"
12
+ })
13
+ model['CVVINDICATOR'].should == "8"
14
+ end
15
+ it "should force CVVINDICATOR to '8' when something invalid is provided" do
16
+ model = GlobalCollect::RequestModels::DoPayment::RecurringCreditCardOnlinePayment.new({
17
+ "MERCHANTREFERENCE" => "aasfd",
18
+ "ORDERID" => "123",
19
+ "PAYMENTPRODUCTID" => "1",
20
+ "AMOUNT" => "123",
21
+ "EFFORTID" => "2",
22
+ "CURRENCYCODE" => "USD",
23
+ "CVVINDICATOR" => "11111111111111"
24
+ })
25
+ model['CVVINDICATOR'].should == "8"
26
+ end
27
+ it "should force CVVINDICATOR to '8' when something wrong is provided" do
28
+ model = GlobalCollect::RequestModels::DoPayment::RecurringCreditCardOnlinePayment.new({
29
+ "MERCHANTREFERENCE" => "aasfd",
30
+ "ORDERID" => "123",
31
+ "PAYMENTPRODUCTID" => "1",
32
+ "AMOUNT" => "123",
33
+ "EFFORTID" => "2",
34
+ "CURRENCYCODE" => "USD",
35
+ "CVVINDICATOR" => "1"
36
+ })
37
+ model['CVVINDICATOR'].should == "8"
38
+ end
39
+ end
@@ -1,7 +1,7 @@
1
1
  require File.join(File.dirname(__FILE__), '..', '..', 'spec_helper')
2
2
 
3
3
  describe "the DO_PAYMENT recurring payment model" do
4
- it "should not allow blank EFFORT_ID" do
4
+ it "should not allow blank EFFORTID" do
5
5
  GlobalCollect::RequestModels::DoPayment::RecurringPayment.new({
6
6
  "MERCHANTREFERENCE" => "aasfd",
7
7
  "ORDERID" => "123",
@@ -10,4 +10,13 @@ describe "the DO_PAYMENT recurring payment model" do
10
10
  "CURRENCYCODE" => "USD"
11
11
  }).validate.should be_false
12
12
  end
13
+ it "should allow blank PAYMENTPRODUCTID" do
14
+ GlobalCollect::RequestModels::DoPayment::RecurringPayment.new({
15
+ "MERCHANTREFERENCE" => "aasfd",
16
+ "ORDERID" => "123",
17
+ "EFFORTID" => "2",
18
+ "AMOUNT" => "123",
19
+ "CURRENCYCODE" => "USD"
20
+ }).validate.should be_true
21
+ end
13
22
  end
@@ -35,4 +35,27 @@ describe GlobalCollect::RequestModels::InsertOrderWithPayment::RecurringOrder do
35
35
  )
36
36
  model["ORDERTYPE"].should == "4"
37
37
  end
38
+
39
+ it "should set STEPMONTH to '120' when not provided" do
40
+ model = GlobalCollect::RequestModels::InsertOrderWithPayment::RecurringOrder.new(
41
+ "ORDERID" => "1",
42
+ "AMOUNT" => "1",
43
+ "CURRENCYCODE" => "USD",
44
+ "LANGUAGECODE" => "en",
45
+ "COUNTRYCODE" => "US"
46
+ )
47
+ model["STEPMONTH"].should == "120"
48
+ end
49
+
50
+ it "should not overwrite STEPMONTH whe provided" do
51
+ model = GlobalCollect::RequestModels::InsertOrderWithPayment::RecurringOrder.new(
52
+ "ORDERID" => "1",
53
+ "AMOUNT" => "1",
54
+ "CURRENCYCODE" => "USD",
55
+ "LANGUAGECODE" => "en",
56
+ "COUNTRYCODE" => "US",
57
+ "STEPMONTH" => "1"
58
+ )
59
+ model["STEPMONTH"].should == "1"
60
+ end
38
61
  end
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 4
7
+ - 5
8
8
  - 0
9
- version: 0.4.0
9
+ version: 0.5.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Timon Karnezos
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-09-23 00:00:00 -07:00
17
+ date: 2010-09-27 00:00:00 -07:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -118,6 +118,7 @@ files:
118
118
  - lib/global_collect.rb
119
119
  - lib/global_collect/api_client.rb
120
120
  - lib/global_collect/builders/do_payment/payment.rb
121
+ - lib/global_collect/builders/do_payment/recurring_credit_card_online_payment.rb
121
122
  - lib/global_collect/builders/do_payment/recurring_payment.rb
122
123
  - lib/global_collect/builders/do_refund/credit_card_payment.rb
123
124
  - lib/global_collect/builders/do_refund/payment.rb
@@ -141,6 +142,7 @@ files:
141
142
  - lib/global_collect/log_parsing/payment_report/report_file.rb
142
143
  - lib/global_collect/request_models/base.rb
143
144
  - lib/global_collect/request_models/do_payment/payment.rb
145
+ - lib/global_collect/request_models/do_payment/recurring_credit_card_online_payment.rb
144
146
  - lib/global_collect/request_models/do_payment/recurring_payment.rb
145
147
  - lib/global_collect/request_models/do_refund/credit_card_payment.rb
146
148
  - lib/global_collect/request_models/do_refund/payment.rb
@@ -195,6 +197,7 @@ files:
195
197
  - spec/log_parsing/payment_report/parser_spec.rb
196
198
  - spec/log_parsing/payment_report/report_file_spec.rb
197
199
  - spec/request_models/base_spec.rb
200
+ - spec/request_models/do_payment/recurring_credit_card_online_payment_spec.rb
198
201
  - spec/request_models/do_payment/recurring_payment_spec.rb
199
202
  - spec/request_models/do_refund/paypal_payment_spec.rb
200
203
  - spec/request_models/insert_order_with_payment/hosted_credit_card_online_payment_spec.rb
@@ -286,6 +289,7 @@ test_files:
286
289
  - spec/log_parsing/payment_report/parser_spec.rb
287
290
  - spec/log_parsing/payment_report/report_file_spec.rb
288
291
  - spec/request_models/base_spec.rb
292
+ - spec/request_models/do_payment/recurring_credit_card_online_payment_spec.rb
289
293
  - spec/request_models/do_payment/recurring_payment_spec.rb
290
294
  - spec/request_models/do_refund/paypal_payment_spec.rb
291
295
  - spec/request_models/insert_order_with_payment/hosted_credit_card_online_payment_spec.rb