activemerchant-paymentech-orbital 0.1.0 → 0.2.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.
Files changed (31) hide show
  1. data/.gitignore +3 -1
  2. data/Rakefile +8 -2
  3. data/VERSION +1 -1
  4. data/activemerchant-paymentech-orbital.gemspec +38 -19
  5. data/config/gateway.yml.example +6 -0
  6. data/lib/active_merchant/billing/{paymentech_orbital.rb → paymentech_orbital/gateway.rb} +5 -2
  7. data/lib/active_merchant/billing/paymentech_orbital/request.rb +12 -5
  8. data/lib/active_merchant/billing/paymentech_orbital/request/end_of_day.rb +4 -0
  9. data/lib/active_merchant/billing/paymentech_orbital/request/new_order.rb +20 -1
  10. data/lib/active_merchant/billing/paymentech_orbital/request/profile_management.rb +29 -2
  11. data/lib/active_merchant/billing/paymentech_orbital/request/void.rb +6 -0
  12. data/lib/active_merchant/billing/paymentech_orbital/response.rb +57 -4
  13. data/lib/activemerchant-paymentech-orbital.rb +1 -1
  14. data/test/factories.rb +55 -4
  15. data/test/remote/auth_capture_test.rb +101 -0
  16. data/test/remote/auth_test.rb +42 -0
  17. data/test/remote/existing_profile_test.rb +137 -0
  18. data/test/remote/profile_test.rb +72 -0
  19. data/test/remote/recurring_test.rb +160 -0
  20. data/test/remote/refund_test.rb +87 -0
  21. data/test/remote/retry_test.rb +51 -0
  22. data/test/remote_helper.rb +28 -0
  23. data/test/test_helper.rb +0 -1
  24. data/test/unit_helper.rb +2 -0
  25. data/test/{payment_orbital → units/paymentech_orbital}/gateway_test.rb +1 -1
  26. data/test/{payment_orbital → units/paymentech_orbital}/request/end_of_day_test.rb +1 -1
  27. data/test/{payment_orbital → units/paymentech_orbital}/request/new_order_test.rb +1 -1
  28. data/test/{payment_orbital → units/paymentech_orbital}/request/profile_management_test.rb +6 -2
  29. data/test/{payment_orbital → units/paymentech_orbital}/request/void_test.rb +1 -1
  30. data/test/{payment_orbital → units/paymentech_orbital}/request_test.rb +1 -1
  31. metadata +53 -23
data/.gitignore CHANGED
@@ -1,5 +1,7 @@
1
1
  *.sw?
2
2
  .DS_Store
3
+ certification.csv
4
+ config/gateway.yml
3
5
  coverage
4
- rdoc
5
6
  pkg
7
+ rdoc
data/Rakefile CHANGED
@@ -5,7 +5,7 @@ begin
5
5
  Jeweler::Tasks.new do |gem|
6
6
  gem.name = "activemerchant-paymentech-orbital"
7
7
  gem.summary = "A gem to provide a ruby interface for Chase Paymentech Orbital payment gateway."
8
- gem.description = "A gem to provide a ruby interface for Chase Paymentech Orbital payment gateway."
8
+ gem.description = "A gem to provide a ruby interface for Chase Paymentech Orbital payment gateway. It has been development thus far to meet specific ends, so not all functionality is present."
9
9
  gem.email = "john@mintdigital.com"
10
10
  gem.homepage = "http://github.com/johnideal/activemerchant-paymentech-orbital"
11
11
  gem.authors = ["John Corrigan"]
@@ -19,7 +19,13 @@ end
19
19
  require 'rake/testtask'
20
20
  Rake::TestTask.new(:test) do |test|
21
21
  test.libs << 'test'
22
- test.pattern = 'test/**/*_test.rb'
22
+ test.pattern = 'test/units/**/*_test.rb'
23
+ test.verbose = true
24
+ end
25
+
26
+ Rake::TestTask.new(:remote) do |test|
27
+ test.libs << 'test'
28
+ test.pattern = 'test/remote/**/*_test.rb'
23
29
  test.verbose = true
24
30
  end
25
31
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.2.0
@@ -5,12 +5,12 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{activemerchant-paymentech-orbital}
8
- s.version = "0.1.0"
8
+ s.version = "0.2.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["John Corrigan"]
12
- s.date = %q{2009-12-03}
13
- s.description = %q{A gem to provide a ruby interface for Chase Paymentech Orbital payment gateway.}
12
+ s.date = %q{2010-03-24}
13
+ s.description = %q{A gem to provide a ruby interface for Chase Paymentech Orbital payment gateway. It has been development thus far to meet specific ends, so not all functionality is present.}
14
14
  s.email = %q{john@mintdigital.com}
15
15
  s.extra_rdoc_files = [
16
16
  "LICENSE",
@@ -24,7 +24,8 @@ Gem::Specification.new do |s|
24
24
  "Rakefile",
25
25
  "VERSION",
26
26
  "activemerchant-paymentech-orbital.gemspec",
27
- "lib/active_merchant/billing/paymentech_orbital.rb",
27
+ "config/gateway.yml.example",
28
+ "lib/active_merchant/billing/paymentech_orbital/gateway.rb",
28
29
  "lib/active_merchant/billing/paymentech_orbital/request.rb",
29
30
  "lib/active_merchant/billing/paymentech_orbital/request/end_of_day.rb",
30
31
  "lib/active_merchant/billing/paymentech_orbital/request/new_order.rb",
@@ -36,31 +37,49 @@ Gem::Specification.new do |s|
36
37
  "test/factories.rb",
37
38
  "test/mocks/active_merchant/billing/gateway.rb",
38
39
  "test/options.rb",
39
- "test/payment_orbital/gateway_test.rb",
40
- "test/payment_orbital/request/end_of_day_test.rb",
41
- "test/payment_orbital/request/new_order_test.rb",
42
- "test/payment_orbital/request/profile_management_test.rb",
43
- "test/payment_orbital/request/void_test.rb",
44
- "test/payment_orbital/request_test.rb",
45
- "test/test_helper.rb"
40
+ "test/remote/auth_capture_test.rb",
41
+ "test/remote/auth_test.rb",
42
+ "test/remote/existing_profile_test.rb",
43
+ "test/remote/profile_test.rb",
44
+ "test/remote/recurring_test.rb",
45
+ "test/remote/refund_test.rb",
46
+ "test/remote/retry_test.rb",
47
+ "test/remote_helper.rb",
48
+ "test/test_helper.rb",
49
+ "test/unit_helper.rb",
50
+ "test/units/paymentech_orbital/gateway_test.rb",
51
+ "test/units/paymentech_orbital/request/end_of_day_test.rb",
52
+ "test/units/paymentech_orbital/request/new_order_test.rb",
53
+ "test/units/paymentech_orbital/request/profile_management_test.rb",
54
+ "test/units/paymentech_orbital/request/void_test.rb",
55
+ "test/units/paymentech_orbital/request_test.rb"
46
56
  ]
47
57
  s.homepage = %q{http://github.com/johnideal/activemerchant-paymentech-orbital}
48
58
  s.rdoc_options = ["--charset=UTF-8"]
49
59
  s.require_paths = ["lib"]
50
- s.rubygems_version = %q{1.3.5}
60
+ s.rubygems_version = %q{1.3.6}
51
61
  s.summary = %q{A gem to provide a ruby interface for Chase Paymentech Orbital payment gateway.}
52
62
  s.test_files = [
53
63
  "test/activemerchant-paymentech-orbital_test.rb",
54
64
  "test/factories.rb",
55
65
  "test/mocks/active_merchant/billing/gateway.rb",
56
66
  "test/options.rb",
57
- "test/payment_orbital/gateway_test.rb",
58
- "test/payment_orbital/request/end_of_day_test.rb",
59
- "test/payment_orbital/request/new_order_test.rb",
60
- "test/payment_orbital/request/profile_management_test.rb",
61
- "test/payment_orbital/request/void_test.rb",
62
- "test/payment_orbital/request_test.rb",
63
- "test/test_helper.rb"
67
+ "test/remote/auth_capture_test.rb",
68
+ "test/remote/auth_test.rb",
69
+ "test/remote/existing_profile_test.rb",
70
+ "test/remote/profile_test.rb",
71
+ "test/remote/recurring_test.rb",
72
+ "test/remote/refund_test.rb",
73
+ "test/remote/retry_test.rb",
74
+ "test/remote_helper.rb",
75
+ "test/test_helper.rb",
76
+ "test/unit_helper.rb",
77
+ "test/units/paymentech_orbital/gateway_test.rb",
78
+ "test/units/paymentech_orbital/request/end_of_day_test.rb",
79
+ "test/units/paymentech_orbital/request/new_order_test.rb",
80
+ "test/units/paymentech_orbital/request/profile_management_test.rb",
81
+ "test/units/paymentech_orbital/request/void_test.rb",
82
+ "test/units/paymentech_orbital/request_test.rb"
64
83
  ]
65
84
 
66
85
  if s.respond_to? :specification_version then
@@ -0,0 +1,6 @@
1
+ gateway:
2
+ login: "login"
3
+ password: "password"
4
+ bin: "bin"
5
+ terminal_id: "terminal"
6
+ merchant_id: "merchant"
@@ -89,12 +89,16 @@ module ActiveMerchant #:nodoc:
89
89
 
90
90
  commit('end of day', @request)
91
91
  end
92
+
93
+ def to_a
94
+ request.to_a + response.to_a
95
+ end
92
96
 
93
97
  private
94
98
  def commit(action, request)
95
99
  resp = ssl_post(endpoint_url, request.to_xml, headers)
96
100
 
97
- @response ||= Response.new(resp, request.request_type, {
101
+ @response = Response.new(resp, request.request_type, {
98
102
  :test => test?
99
103
  })
100
104
  end
@@ -110,4 +114,3 @@ module ActiveMerchant #:nodoc:
110
114
  end
111
115
  end
112
116
  end
113
-
@@ -20,20 +20,27 @@ module ActiveMerchant
20
20
  @_headers ||= options.headers || {}
21
21
  end
22
22
 
23
- private
24
- delegate :login, :password, :merchant_id,
25
- :bin, :terminal_id, :currency_code,
26
- :currency_exponent, :customer_ref_num,
27
- :order_id, :to => :options
23
+ def to_a
24
+ [ to_s, Time.now, merchant_id, order_id, industry_type,
25
+ money, currency_code, customer_ref_num, address[:phone],
26
+ address[:name], full_street_address ]
27
+ end
28
28
 
29
29
  def address
30
30
  @_address ||= options.billing_address || options.address || {}
31
31
  end
32
32
 
33
+ delegate :login, :password, :merchant_id,
34
+ :bin, :terminal_id, :currency_code,
35
+ :currency_exponent, :customer_ref_num,
36
+ :order_id, :to => :options
37
+
33
38
  def full_street_address
34
39
  "#{address[:address1]} #{address[:address2]}".strip
35
40
  end
36
41
 
42
+ private
43
+
37
44
  # Implement me. I should be the parent tag for the request.
38
45
  def request_type; "RequestType"; end
39
46
 
@@ -5,6 +5,10 @@ module ActiveMerchant
5
5
  class EndOfDay < PaymentechOrbital::Request::Base
6
6
  def request_type; "EndOfDay"; end
7
7
 
8
+ def to_s
9
+ "End of day"
10
+ end
11
+
8
12
  private
9
13
  def request_body(xml)
10
14
  add_meta_info(xml)
@@ -20,6 +20,16 @@ module ActiveMerchant
20
20
 
21
21
  def request_type; "NewOrder"; end
22
22
 
23
+ def to_s
24
+ "#{self.class.message_map[@message_type]}: Credit Card (#{credit_card.type if credit_card})"
25
+ end
26
+
27
+ def self.message_map
28
+ { "A" => "Auth",
29
+ "AC" => "Auth/Capture",
30
+ "R" => "Refund" }
31
+ end
32
+
23
33
  def recurring?
24
34
  industry_type == "RC"
25
35
  end
@@ -56,6 +66,15 @@ module ActiveMerchant
56
66
  add_currency(xml)
57
67
  end
58
68
  end
69
+
70
+ def card_sec_val_ind
71
+ return "" unless credit_card
72
+ if credit_card.type == "amex"
73
+ ""
74
+ else
75
+ "1"
76
+ end
77
+ end
59
78
 
60
79
  def add_currency(xml)
61
80
  xml.tag! "CurrencyCode", currency_code
@@ -108,7 +127,7 @@ module ActiveMerchant
108
127
  xml.tag! "MBOrderIdGenerationMethod", "DI"
109
128
  xml.tag! "MBRecurringStartDate", recurring_start_date || (Date.today + 1).strftime("%m%d%Y")
110
129
  xml.tag! "MBRecurringEndDate", recurring_end_date
111
- xml.tag! "MBRecurringNoEndDateFlag", recurring_end_date_flag || (recurring_end_date ? "N" : "Y")
130
+ xml.tag! "MBRecurringNoEndDateFlag", recurring_end_date_flag # || (recurring_end_date ? "N" : "Y")
112
131
  xml.tag! "MBRecurringMaxBillings", recurring_max_billings
113
132
  xml.tag! "MBRecurringFrequency", recurring_frequency
114
133
  xml.tag! "MBDeferredBillDate", deferred_bill_date
@@ -21,7 +21,19 @@ module ActiveMerchant
21
21
 
22
22
  def request_type; "Profile"; end
23
23
 
24
+ def to_s
25
+ "Profile #{@action}"
26
+ end
27
+
28
+ def industry_type; nil; end
29
+ def money; nil; end
30
+
24
31
  private
32
+ delegate :mb_type, :mb_order_id_generation_method, :mb_recurring_start_date,
33
+ :mb_recurring_end_date, :mb_recurring_max_billings,
34
+ :mb_recurring_frequency, :mb_deferred_bill_date, :mb_cancel_date,
35
+ :mb_restore_billing_date, :mb_remove_flag, :mb_recurring_no_end_date_flag, :to => :options
36
+
25
37
  def customer_profile_action
26
38
  self.class.action_map[action.downcase.to_s]
27
39
  end
@@ -39,6 +51,7 @@ module ActiveMerchant
39
51
  add_customer_profile_management_options(xml)
40
52
  add_account_info(xml) if writing?
41
53
  add_credit_card_info(xml) if writing? && credit_card
54
+ add_managed_billing_info(xml)
42
55
  end
43
56
 
44
57
  def add_meta_info(xml)
@@ -68,15 +81,29 @@ module ActiveMerchant
68
81
 
69
82
  def add_account_info(xml)
70
83
  xml.tag! "CustomerAccountType", "CC"
71
- xml.tag! "Status", options[:status] || "A"
84
+ xml.tag! "Status", options.status || "A"
72
85
  end
73
86
 
74
87
  def add_credit_card_info(xml)
75
88
  xml.tag! "CCAccountNum", credit_card.number
76
89
  xml.tag! "CCExpireDate", "#{credit_card.month}#{credit_card.year}"
77
90
  end
91
+
92
+ def add_managed_billing_info(xml)
93
+ xml.tag! "MBType", mb_type if mb_type
94
+ xml.tag! "MBOrderIdGenerationMethod", mb_order_id_generation_method if mb_order_id_generation_method
95
+ xml.tag! "MBRecurringStartDate", mb_recurring_start_date if mb_recurring_start_date
96
+ xml.tag! "MBRecurringEndDate", mb_recurring_end_date if mb_recurring_end_date
97
+ xml.tag! "MBRecurringNoEndDateFlag", mb_recurring_no_end_date_flag if mb_recurring_no_end_date_flag
98
+ xml.tag! "MBRecurringMaxBillings", mb_recurring_max_billings if mb_recurring_max_billings
99
+ xml.tag! "MBRecurringFrequency", mb_recurring_frequency if mb_recurring_frequency
100
+ xml.tag! "MBDeferredBillDate", mb_deferred_bill_date if mb_deferred_bill_date
101
+ xml.tag! "MBCancelDate", mb_cancel_date if mb_cancel_date
102
+ xml.tag! "MBRestoreBillingDate", mb_restore_billing_date if mb_restore_billing_date
103
+ xml.tag! "MBRemoveFlag", mb_remove_flag if mb_remove_flag
104
+ end
78
105
  end
79
106
  end
80
107
  end
81
108
  end
82
- end
109
+ end
@@ -14,6 +14,12 @@ module ActiveMerchant
14
14
 
15
15
  def request_type; "Reversal"; end
16
16
 
17
+ def to_s
18
+ "Void: #{tx_ref_num}"
19
+ end
20
+
21
+ def industry_type; nil; end
22
+
17
23
  private
18
24
  def request_body(xml)
19
25
  add_transaction_info(xml)
@@ -9,13 +9,17 @@ module ActiveMerchant
9
9
  :industry_type, :message_type, :merchant_id,
10
10
  :terminal_id, :card_brand, :account_num,
11
11
  :order_id, :tx_ref_num, :tx_ref_idx, :proc_status,
12
- :approval_status, :resp_code, :avs_resp_code,
13
- :cvv2_resp_code, :auth_code, :status_msg, :resp_msg,
12
+ :approval_status, :resp_code, :AVSRespCode,
13
+ :CVV2RespCode, :auth_code, :status_msg, :resp_msg,
14
14
  :customer_ref_num, :customer_name, :profile_proc_status,
15
15
  :customer_profile_message, :resp_time, :batch_seq_num,
16
16
  :CCAccountNum, :customer_address_1, :customer_address_2,
17
17
  :customer_city, :CustomerZIP, :customer_state,
18
- :CCExpireDate
18
+ :CCExpireDatem, :MBRecurringNoEndDateFlag,
19
+ :MBCancelDate, :MBType, :MBOrderIdGenerationMethod,
20
+ :MBRecurringStartDate, :MBRecurringFrequency,
21
+ :MBRecurringEndDate, :MBRecurringMaxBillings,
22
+ :MBRemoveFlag
19
23
  ]
20
24
 
21
25
  def initialize(doc, request_type, options={})
@@ -62,7 +66,51 @@ module ActiveMerchant
62
66
  end
63
67
 
64
68
  def cvv_result
65
- @cvv_result ||= CVVResult.new({:code => cvv2_result_code})
69
+ @cvv_result ||= CVVResult.new({:code => cvv2_resp_code})
70
+ end
71
+
72
+ def avs_resp_code
73
+ send(:AVSRespCode)
74
+ end
75
+
76
+ def cvv2_resp_code
77
+ send(:CVV2RespCode)
78
+ end
79
+
80
+ def mb_cancel_date
81
+ send(:MBCancelDate)
82
+ end
83
+
84
+ def mb_recurring_no_end_date_flag
85
+ send(:MBRecurringNoEndDateFlag)
86
+ end
87
+
88
+ def mb_type
89
+ send(:MBType)
90
+ end
91
+
92
+ def mb_order_id_generation_method
93
+ send(:MBOrderIdGenerationMethod)
94
+ end
95
+
96
+ def mb_recurring_start_date
97
+ send(:MBRecurringStartDate)
98
+ end
99
+
100
+ def mb_recurring_frequency
101
+ send(:MBRecurringFrequency)
102
+ end
103
+
104
+ def mb_recurring_end_date
105
+ send(:MBRecurringEndDate)
106
+ end
107
+
108
+ def mb_recurring_max_billings
109
+ send(:MBRecurringMaxBillings)
110
+ end
111
+
112
+ def mb_remove_flag
113
+ send(:MBRemoveFlag)
66
114
  end
67
115
 
68
116
  def to_xml
@@ -72,6 +120,11 @@ module ActiveMerchant
72
120
  end
73
121
  @_xml
74
122
  end
123
+
124
+ def to_a
125
+ [ auth_code, avs_resp_code, cvv2_resp_code, tx_ref_num,
126
+ customer_ref_num, profile_proc_status ]
127
+ end
75
128
 
76
129
  private
77
130
  def tagify(s)
@@ -1,6 +1,6 @@
1
1
  require 'active_merchant'
2
2
 
3
- require 'active_merchant/billing/paymentech_orbital'
3
+ require 'active_merchant/billing/paymentech_orbital/gateway'
4
4
  require 'active_merchant/billing/paymentech_orbital/request'
5
5
  require 'active_merchant/billing/paymentech_orbital/request/end_of_day'
6
6
  require 'active_merchant/billing/paymentech_orbital/request/new_order'
@@ -2,13 +2,50 @@ Factory.define :credit_card, {
2
2
  :class => ActiveMerchant::Billing::CreditCard,
3
3
  :default_strategy => :build
4
4
  } do |f|
5
- f.number "4242424242424242"
6
- f.month 9
7
- f.year Time.now.year + 1
5
+ f.month 10
6
+ f.year 12
8
7
  f.first_name 'Joe'
9
8
  f.last_name 'Smith'
9
+ end
10
+
11
+ Factory.define :amex, {
12
+ :class => ActiveMerchant::Billing::CreditCard,
13
+ :default_strategy => :build,
14
+ :parent => :credit_card
15
+ } do |f|
16
+ f.number "371449635398431"
17
+ f.add_attribute :type, 'AX'
18
+ f.verification_value '1234'
19
+ end
20
+
21
+ Factory.define :discover, {
22
+ :class => ActiveMerchant::Billing::CreditCard,
23
+ :default_strategy => :build,
24
+ :parent => :credit_card
25
+ } do |f|
26
+ f.number "6011000995500000"
27
+ f.add_attribute :type, 'DI'
28
+ f.verification_value '123'
29
+ end
30
+
31
+ Factory.define :master_card, {
32
+ :class => ActiveMerchant::Billing::CreditCard,
33
+ :default_strategy => :build,
34
+ :parent => :credit_card
35
+ } do |f|
36
+ f.number "5454545454545454"
37
+ f.add_attribute :type, 'MC'
38
+ f.verification_value '123'
39
+ end
40
+
41
+ Factory.define :visa, {
42
+ :class => ActiveMerchant::Billing::CreditCard,
43
+ :default_strategy => :build,
44
+ :parent => :credit_card
45
+ } do |f|
46
+ f.number "4444444444444448"
47
+ f.add_attribute :type, 'VI'
10
48
  f.verification_value '123'
11
- f.add_attribute :type, 'visa'
12
49
  end
13
50
 
14
51
  # Option factories
@@ -60,6 +97,20 @@ def gateway(options={})
60
97
  ActiveMerchant::Billing::PaymentechOrbital::Gateway.new(Options(:gateway_auth, options))
61
98
  end
62
99
 
100
+ def gateway_config
101
+ @_gateway_config ||= YAML.load_file("config/gateway.yml")["gateway"]
102
+ end
103
+
104
+ def remote_gateway(options={})
105
+ ActiveMerchant::Billing::PaymentechOrbital::Gateway.new({
106
+ :login => gateway_config["login"],
107
+ :password => gateway_config["password"],
108
+ :bin => gateway_config["bin"],
109
+ :terminal_id => gateway_config["terminal_id"],
110
+ :merchant_id => gateway_config["merchant_id"]
111
+ })
112
+ end
113
+
63
114
  def base_request(options={})
64
115
  ActiveMerchant::Billing::PaymentechOrbital::Request::Base.new(
65
116
  Options(:request_options, options)