activemerchant 1.2.1 → 1.3.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 (206) hide show
  1. data.tar.gz.sig +0 -0
  2. data/CHANGELOG +310 -294
  3. data/CONTRIBUTERS +13 -0
  4. data/README +55 -31
  5. data/Rakefile +21 -13
  6. data/lib/active_merchant.rb +7 -0
  7. data/lib/active_merchant/billing/avs_result.rb +95 -0
  8. data/lib/active_merchant/billing/base.rb +8 -3
  9. data/lib/active_merchant/billing/check.rb +61 -0
  10. data/lib/active_merchant/billing/credit_card.rb +104 -80
  11. data/lib/active_merchant/billing/credit_card_formatting.rb +11 -8
  12. data/lib/active_merchant/billing/credit_card_methods.rb +76 -32
  13. data/lib/active_merchant/billing/cvv_result.rb +38 -0
  14. data/lib/active_merchant/billing/expiry_date.rb +28 -0
  15. data/lib/active_merchant/billing/gateway.rb +47 -111
  16. data/lib/active_merchant/billing/gateways/authorize_net.rb +508 -121
  17. data/lib/active_merchant/billing/gateways/bogus.rb +26 -32
  18. data/lib/active_merchant/billing/gateways/brain_tree.rb +82 -70
  19. data/lib/active_merchant/billing/gateways/card_stream.rb +43 -15
  20. data/lib/active_merchant/billing/gateways/cyber_source.rb +9 -29
  21. data/lib/active_merchant/billing/gateways/data_cash.rb +18 -38
  22. data/lib/active_merchant/billing/gateways/efsnet.rb +23 -50
  23. data/lib/active_merchant/billing/gateways/eway.rb +8 -19
  24. data/lib/active_merchant/billing/gateways/exact.rb +17 -25
  25. data/lib/active_merchant/billing/gateways/linkpoint.rb +18 -25
  26. data/lib/active_merchant/billing/gateways/moneris.rb +9 -39
  27. data/lib/active_merchant/billing/gateways/net_registry.rb +113 -182
  28. data/lib/active_merchant/billing/gateways/netbilling.rb +168 -0
  29. data/lib/active_merchant/billing/gateways/pay_junction.rb +52 -73
  30. data/lib/active_merchant/billing/gateways/pay_secure.rb +120 -0
  31. data/lib/active_merchant/billing/gateways/payflow.rb +13 -14
  32. data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +55 -37
  33. data/lib/active_merchant/billing/gateways/payflow/payflow_response.rb +4 -0
  34. data/lib/active_merchant/billing/gateways/payflow_express.rb +2 -4
  35. data/lib/active_merchant/billing/gateways/payment_express.rb +11 -30
  36. data/lib/active_merchant/billing/gateways/paypal.rb +3 -14
  37. data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +36 -16
  38. data/lib/active_merchant/billing/gateways/paypal_express.rb +1 -2
  39. data/lib/active_merchant/billing/gateways/plugnpay.rb +7 -15
  40. data/lib/active_merchant/billing/gateways/protx.rb +24 -25
  41. data/lib/active_merchant/billing/gateways/psigate.rb +34 -71
  42. data/lib/active_merchant/billing/gateways/psl_card.rb +24 -19
  43. data/lib/active_merchant/billing/gateways/quickpay.rb +10 -24
  44. data/lib/active_merchant/billing/gateways/realex.rb +7 -19
  45. data/lib/active_merchant/billing/gateways/secure_pay_tech.rb +113 -0
  46. data/lib/active_merchant/billing/gateways/skip_jack.rb +437 -0
  47. data/lib/active_merchant/billing/gateways/trans_first.rb +5 -14
  48. data/lib/active_merchant/billing/gateways/trust_commerce.rb +100 -39
  49. data/lib/active_merchant/billing/gateways/usa_epay.rb +60 -55
  50. data/lib/active_merchant/billing/gateways/verifi.rb +32 -39
  51. data/lib/active_merchant/billing/gateways/viaklix.rb +31 -37
  52. data/lib/active_merchant/billing/integrations.rb +2 -0
  53. data/lib/active_merchant/billing/integrations/bogus.rb +5 -0
  54. data/lib/active_merchant/billing/integrations/bogus/return.rb +10 -0
  55. data/lib/active_merchant/billing/integrations/chronopay.rb +5 -0
  56. data/lib/active_merchant/billing/integrations/chronopay/return.rb +10 -0
  57. data/lib/active_merchant/billing/integrations/gestpay.rb +5 -0
  58. data/lib/active_merchant/billing/integrations/gestpay/return.rb +10 -0
  59. data/lib/active_merchant/billing/integrations/hi_trust.rb +26 -0
  60. data/lib/active_merchant/billing/integrations/hi_trust/helper.rb +58 -0
  61. data/lib/active_merchant/billing/integrations/hi_trust/notification.rb +57 -0
  62. data/lib/active_merchant/billing/integrations/hi_trust/return.rb +67 -0
  63. data/lib/active_merchant/billing/integrations/nochex.rb +5 -0
  64. data/lib/active_merchant/billing/integrations/nochex/return.rb +10 -0
  65. data/lib/active_merchant/billing/integrations/paypal.rb +5 -0
  66. data/lib/active_merchant/billing/integrations/paypal/return.rb +10 -0
  67. data/lib/active_merchant/billing/integrations/return.rb +35 -0
  68. data/lib/active_merchant/billing/integrations/two_checkout.rb +5 -0
  69. data/lib/active_merchant/billing/integrations/two_checkout/return.rb +17 -0
  70. data/lib/active_merchant/billing/response.rb +12 -8
  71. data/lib/active_merchant/lib/posts_data.rb +39 -7
  72. data/lib/active_merchant/lib/requires_parameters.rb +2 -3
  73. data/lib/active_merchant/lib/utils.rb +18 -0
  74. data/lib/active_merchant/lib/validateable.rb +3 -3
  75. data/lib/support/gateway_support.rb +22 -9
  76. data/script/destroy +14 -0
  77. data/script/generate +7 -7
  78. data/test/fixtures.yml +25 -3
  79. data/test/remote/gateways/remote_authorize_net_test.rb +145 -0
  80. data/test/remote/gateways/remote_brain_tree_test.rb +118 -0
  81. data/test/{remote_tests → remote/gateways}/remote_card_stream_test.rb +56 -68
  82. data/test/{remote_tests → remote/gateways}/remote_cyber_source_test.rb +21 -32
  83. data/test/{remote_tests → remote/gateways}/remote_data_cash_test.rb +2 -2
  84. data/test/{remote_tests → remote/gateways}/remote_efsnet_test.rb +22 -34
  85. data/test/{remote_tests → remote/gateways}/remote_eway_test.rb +18 -15
  86. data/test/{remote_tests → remote/gateways}/remote_exact_test.rb +20 -19
  87. data/test/{remote_tests → remote/gateways}/remote_linkpoint_test.rb +31 -63
  88. data/test/remote/gateways/remote_moneris_test.rb +82 -0
  89. data/test/{remote_tests → remote/gateways}/remote_net_registry_test.rb +19 -54
  90. data/test/remote/gateways/remote_netbilling_test.rb +70 -0
  91. data/test/{remote_tests → remote/gateways}/remote_pay_junction_test.rb +41 -60
  92. data/test/remote/gateways/remote_pay_secure_test.rb +39 -0
  93. data/test/{remote_tests → remote/gateways}/remote_payflow_express_test.rb +2 -2
  94. data/test/{remote_tests → remote/gateways}/remote_payflow_test.rb +34 -38
  95. data/test/{remote_tests → remote/gateways}/remote_payflow_uk_test.rb +13 -12
  96. data/test/{remote_tests → remote/gateways}/remote_payment_express_test.rb +26 -36
  97. data/test/{remote_tests → remote/gateways}/remote_paypal_express_test.rb +3 -3
  98. data/test/{remote_tests → remote/gateways}/remote_paypal_test.rb +25 -21
  99. data/test/{remote_tests → remote/gateways}/remote_plugnpay_test.rb +18 -16
  100. data/test/{remote_tests → remote/gateways}/remote_protx_test.rb +33 -33
  101. data/test/remote/gateways/remote_psigate_test.rb +50 -0
  102. data/test/{remote_tests → remote/gateways}/remote_psl_card_test.rb +27 -26
  103. data/test/{remote_tests → remote/gateways}/remote_quickpay_test.rb +48 -48
  104. data/test/{remote_tests → remote/gateways}/remote_realex_test.rb +30 -33
  105. data/test/remote/gateways/remote_secure_pay_tech_test.rb +37 -0
  106. data/test/remote/gateways/remote_secure_pay_test.rb +28 -0
  107. data/test/remote/gateways/remote_skipjack_test.rb +105 -0
  108. data/test/{remote_tests → remote/gateways}/remote_trans_first_test.rb +7 -10
  109. data/test/remote/gateways/remote_trust_commerce_test.rb +152 -0
  110. data/test/{remote_tests → remote/gateways}/remote_usa_epay_test.rb +11 -22
  111. data/test/{remote_tests → remote/gateways}/remote_verifi_test.rb +27 -27
  112. data/test/{remote_tests → remote/gateways}/remote_viaklix_test.rb +8 -18
  113. data/test/{remote_tests → remote/integrations}/remote_gestpay_integration_test.rb +1 -1
  114. data/test/{remote_tests → remote/integrations}/remote_paypal_integration_test.rb +1 -1
  115. data/test/test_helper.rb +102 -61
  116. data/test/unit/avs_result_test.rb +59 -0
  117. data/test/unit/base_test.rb +33 -39
  118. data/test/unit/check_test.rb +76 -0
  119. data/test/unit/credit_card_formatting_test.rb +10 -15
  120. data/test/unit/credit_card_methods_test.rb +132 -17
  121. data/test/unit/credit_card_test.rb +157 -228
  122. data/test/unit/cvv_result_test.rb +33 -0
  123. data/test/unit/expiry_date_test.rb +21 -0
  124. data/test/unit/gateways/authorize_net_test.rb +180 -40
  125. data/test/unit/gateways/bogus_test.rb +2 -3
  126. data/test/unit/gateways/brain_tree_test.rb +63 -29
  127. data/test/unit/gateways/card_stream_test.rb +59 -6
  128. data/test/unit/gateways/cyber_source_test.rb +59 -40
  129. data/test/unit/gateways/data_cash_test.rb +82 -1
  130. data/test/unit/gateways/efsnet_test.rb +97 -44
  131. data/test/unit/gateways/eway_test.rb +55 -42
  132. data/test/unit/gateways/exact_test.rb +93 -55
  133. data/test/unit/gateways/gateway_test.rb +7 -0
  134. data/test/unit/gateways/linkpoint_test.rb +60 -58
  135. data/test/unit/gateways/moneris_test.rb +67 -76
  136. data/test/unit/gateways/net_registry_test.rb +351 -419
  137. data/test/unit/gateways/netbilling_test.rb +54 -0
  138. data/test/unit/gateways/pay_junction_test.rb +108 -46
  139. data/test/unit/gateways/pay_secure_test.rb +71 -0
  140. data/test/unit/gateways/payflow_express_test.rb +0 -8
  141. data/test/unit/gateways/payflow_test.rb +136 -65
  142. data/test/unit/gateways/payflow_uk_test.rb +0 -38
  143. data/test/unit/gateways/payment_express_test.rb +31 -51
  144. data/test/unit/gateways/paypal_express_test.rb +8 -2
  145. data/test/unit/gateways/paypal_test.rb +213 -54
  146. data/test/unit/gateways/plugnpay_test.rb +39 -32
  147. data/test/unit/gateways/protx_test.rb +45 -33
  148. data/test/unit/gateways/psigate_test.rb +146 -87
  149. data/test/unit/gateways/psl_card_test.rb +37 -24
  150. data/test/unit/gateways/quickpay_test.rb +33 -46
  151. data/test/unit/gateways/realex_test.rb +32 -31
  152. data/test/unit/gateways/secure_pay_tech_test.rb +44 -0
  153. data/test/unit/gateways/secure_pay_test.rb +35 -26
  154. data/test/unit/gateways/skip_jack_test.rb +125 -0
  155. data/test/unit/gateways/trans_first_test.rb +24 -37
  156. data/test/unit/gateways/trust_commerce_test.rb +47 -26
  157. data/test/unit/gateways/usa_epay_test.rb +52 -41
  158. data/test/unit/gateways/verifi_test.rb +41 -35
  159. data/test/unit/gateways/viaklix_test.rb +38 -32
  160. data/test/unit/generators/test_gateway_generator.rb +46 -0
  161. data/test/unit/generators/test_generator_helper.rb +20 -0
  162. data/test/unit/generators/test_integration_generator.rb +53 -0
  163. data/test/unit/integrations/action_view_helper_test.rb +7 -14
  164. data/test/unit/integrations/bogus_module_test.rb +4 -0
  165. data/test/unit/integrations/chronopay_module_test.rb +4 -0
  166. data/test/unit/integrations/gestpay_module_test.rb +4 -0
  167. data/test/unit/integrations/helpers/hi_trust_helper_test.rb +16 -0
  168. data/test/unit/integrations/hi_trust_module_test.rb +13 -0
  169. data/test/unit/integrations/nochex_module_test.rb +4 -0
  170. data/test/unit/integrations/notifications/hi_trust_notification_test.rb +38 -0
  171. data/test/unit/integrations/paypal_module_test.rb +4 -0
  172. data/test/unit/integrations/returns/chronopay_return_test.rb +11 -0
  173. data/test/unit/integrations/returns/gestpay_return_test.rb +10 -0
  174. data/test/unit/integrations/returns/hi_trust_return_test.rb +24 -0
  175. data/test/unit/integrations/returns/nochex_return_test.rb +10 -0
  176. data/test/unit/integrations/returns/paypal_return_test.rb +10 -0
  177. data/test/unit/integrations/returns/return_test.rb +11 -0
  178. data/test/unit/integrations/returns/two_checkout_return_test.rb +24 -0
  179. data/test/unit/integrations/two_checkout_module_test.rb +4 -0
  180. data/test/unit/posts_data_test.rb +86 -0
  181. data/test/unit/response_test.rb +15 -1
  182. data/test/unit/utils_test.rb +7 -0
  183. data/test/unit/validateable_test.rb +10 -6
  184. metadata +180 -142
  185. metadata.gz.sig +0 -0
  186. data/lib/active_merchant/billing/gateways/paypal/api_cert_chain.crt +0 -35
  187. data/script/generator/base.rb +0 -45
  188. data/script/generator/generator.rb +0 -24
  189. data/script/generator/generators/gateway/gateway_generator.rb +0 -14
  190. data/script/generator/generators/gateway/templates/gateway.rb +0 -73
  191. data/script/generator/generators/gateway/templates/gateway_test.rb +0 -41
  192. data/script/generator/generators/gateway/templates/remote_gateway_test.rb +0 -56
  193. data/script/generator/generators/integration/integration_generator.rb +0 -25
  194. data/script/generator/generators/integration/templates/helper.rb +0 -34
  195. data/script/generator/generators/integration/templates/helper_test.rb +0 -54
  196. data/script/generator/generators/integration/templates/integration.rb +0 -18
  197. data/script/generator/generators/integration/templates/module_test.rb +0 -9
  198. data/script/generator/generators/integration/templates/notification.rb +0 -100
  199. data/script/generator/generators/integration/templates/notification_test.rb +0 -41
  200. data/script/generator/manifest.rb +0 -20
  201. data/test/remote_tests/remote_authorize_net_test.rb +0 -113
  202. data/test/remote_tests/remote_brain_tree_test.rb +0 -78
  203. data/test/remote_tests/remote_moneris_test.rb +0 -110
  204. data/test/remote_tests/remote_psigate_test.rb +0 -87
  205. data/test/remote_tests/remote_secure_pay_test.rb +0 -36
  206. data/test/remote_tests/remote_trust_commerce_test.rb +0 -136
@@ -4,7 +4,7 @@ module ActiveMerchant #:nodoc:
4
4
  module Billing #:nodoc:
5
5
  class VerifiGateway < Gateway
6
6
  class VerifiPostData < PostData
7
- # Fields that will be send even if they are blank
7
+ # Fields that will be sent even if they are blank
8
8
  self.required_fields = [ :amount, :type, :ccnumber, :ccexp, :firstname, :lastname,
9
9
  :company, :address1, :address2, :city, :state, :zip, :country, :phone ]
10
10
  end
@@ -62,23 +62,19 @@ module ActiveMerchant #:nodoc:
62
62
  self.supported_cardtypes = [:visa, :master, :american_express, :discover]
63
63
  self.homepage_url = 'http://www.verifi.com/'
64
64
  self.display_name = 'Verifi'
65
-
66
- attr_reader :url
67
- attr_reader :response
68
- attr_reader :options
69
-
65
+
70
66
  def initialize(options = {})
71
67
  requires!(options, :login, :password)
72
68
  @options = options
73
69
  super
74
70
  end
75
71
 
76
- def purchase(money, creditcard, options = {})
77
- sale_authorization_or_credit_template(:purchase, money, creditcard, options)
72
+ def purchase(money, credit_card, options = {})
73
+ sale_authorization_or_credit_template(:purchase, money, credit_card, options)
78
74
  end
79
75
 
80
- def authorize(money, creditcard, options = {})
81
- sale_authorization_or_credit_template(:authorization, money, creditcard, options)
76
+ def authorize(money, credit_card, options = {})
77
+ sale_authorization_or_credit_template(:authorization, money, credit_card, options)
82
78
  end
83
79
 
84
80
  def capture(money, authorization, options = {})
@@ -89,20 +85,20 @@ module ActiveMerchant #:nodoc:
89
85
  capture_void_or_refund_template(:void, 0, authorization, options)
90
86
  end
91
87
 
92
- def credit(money, creditcard_or_authorization, options = {})
93
- if creditcard_or_authorization.is_a?(String)
94
- capture_void_or_refund_template(:refund, money, creditcard_or_authorization, options)
88
+ def credit(money, credit_card_or_authorization, options = {})
89
+ if credit_card_or_authorization.is_a?(String)
90
+ capture_void_or_refund_template(:refund, money, credit_card_or_authorization, options)
95
91
  else
96
- sale_authorization_or_credit_template(:credit, money, creditcard_or_authorization, options)
92
+ sale_authorization_or_credit_template(:credit, money, credit_card_or_authorization, options)
97
93
  end
98
94
  end
99
95
 
100
96
  private
101
97
 
102
- def sale_authorization_or_credit_template(trx_type, money, creditcard, options = {})
98
+ def sale_authorization_or_credit_template(trx_type, money, credit_card, options = {})
103
99
  post = VerifiPostData.new
104
100
  add_security_key_data(post, options, money)
105
- add_creditcard(post, creditcard)
101
+ add_credit_card(post, credit_card)
106
102
  add_addresses(post, options)
107
103
  add_customer_data(post, options)
108
104
  add_invoice_data(post, options)
@@ -117,17 +113,17 @@ module ActiveMerchant #:nodoc:
117
113
  commit(trx_type, money, post)
118
114
  end
119
115
 
120
- def add_creditcard(post, creditcard)
121
- post[:ccnumber] = creditcard.number
122
- post[:ccexp] = expdate(creditcard)
123
- post[:firstname] = creditcard.first_name
124
- post[:lastname] = creditcard.last_name
125
- post[:cvv] = creditcard.verification_value
116
+ def add_credit_card(post, credit_card)
117
+ post[:ccnumber] = credit_card.number
118
+ post[:ccexp] = expdate(credit_card)
119
+ post[:firstname] = credit_card.first_name
120
+ post[:lastname] = credit_card.last_name
121
+ post[:cvv] = credit_card.verification_value
126
122
  end
127
123
 
128
- def expdate(creditcard)
129
- year = sprintf("%.4i", creditcard.year)
130
- month = sprintf("%.2i", creditcard.month)
124
+ def expdate(credit_card)
125
+ year = sprintf("%.4i", credit_card.year)
126
+ month = sprintf("%.2i", credit_card.month)
131
127
 
132
128
  "#{month}#{year[-2..-1]}"
133
129
  end
@@ -145,7 +141,7 @@ module ActiveMerchant #:nodoc:
145
141
  post[:fax] = billing_address[:fax]
146
142
  end
147
143
 
148
- if shipping_address = options[:shipping_address] || billing_address
144
+ if shipping_address = options[:shipping_address]
149
145
  post[:shipping_firstname] = shipping_address[:first_name]
150
146
  post[:shipping_lastname] = shipping_address[:last_name]
151
147
  post[:shipping_company] = shipping_address[:company]
@@ -197,24 +193,21 @@ module ActiveMerchant #:nodoc:
197
193
  end
198
194
 
199
195
  def commit(trx_type, money, post)
200
-
201
196
  post[:amount] = amount(money)
202
197
 
203
- if result = test_result_from_cc_number(post[:ccnumber])
204
- return result
205
- end
206
-
207
- data = ssl_post(URL, post_data(trx_type, post), 'Content-type' => "application/x-www-form-urlencoded")
208
- @response = parse(data)
209
-
210
- success = @response[:response].to_i == SUCCESS
211
- message = @response[:response_code_message] ? @response[:response_code_message] : ""
212
-
213
- Response.new(success, message, @response,
198
+ response = parse( ssl_post(URL, post_data(trx_type, post)) )
199
+
200
+ Response.new(response[:response].to_i == SUCCESS, message_from(response), response,
214
201
  :test => test?,
215
- :authorization => @response[:transactionid]
202
+ :authorization => response[:transactionid],
203
+ :avs_result => { :code => response[:avsresponse] },
204
+ :cvv_result => response[:cvvresponse]
216
205
  )
217
206
  end
207
+
208
+ def message_from(response)
209
+ response[:response_code_message] ? response[:response_code_message] : ""
210
+ end
218
211
 
219
212
  def parse(body)
220
213
  results = {}
@@ -42,7 +42,7 @@ module ActiveMerchant #:nodoc:
42
42
  # Viaklix does not support credits by reference. You must pass in the credit card
43
43
  def credit(money, creditcard, options = {})
44
44
  if creditcard.is_a?(String)
45
- raise ArgumentError, "Reference credits are not supported. Please supply the original credit card"
45
+ raise ArgumentError, "Reference credits are not supported. Please supply the original credit card"
46
46
  end
47
47
 
48
48
  form = {}
@@ -55,39 +55,39 @@ module ActiveMerchant #:nodoc:
55
55
 
56
56
  private
57
57
  def add_customer_data(form, options)
58
- form[:email] = options[:email] unless options[:email].blank?
58
+ form[:email] = options[:email].to_s.slice(0, 100) unless options[:email].blank?
59
59
  form[:customer_code] = options[:customer].to_s.slice(0, 17) unless options[:customer].blank?
60
60
  end
61
61
 
62
62
  def add_invoice(form,options)
63
- form[:invoice_number] = options[:order_id] || options[:invoice]
63
+ form[:invoice_number] = (options[:order_id] || options[:invoice]).to_s.slice(0, 10)
64
+ form[:description] = options[:description].to_s.slice(0, 255)
64
65
  end
65
66
 
66
67
  def add_address(form,options)
67
68
  billing_address = options[:billing_address] || options[:address]
68
69
 
69
70
  if billing_address
70
- form[:avs_address] = billing_address[:address1]
71
- form[:avs_zip] = billing_address[:zip]
72
- form[:city] = billing_address[:city]
73
- form[:state] = billing_address[:state]
74
- form[:company] = billing_address[:company]
75
- form[:phone] = billing_address[:phone]
76
- form[:country] = billing_address[:country]
71
+ form[:avs_address] = billing_address[:address1].to_s.slice(0, 30)
72
+ form[:address2] = billing_address[:address2].to_s.slice(0, 30)
73
+ form[:avs_zip] = billing_address[:zip].to_s.slice(0, 10)
74
+ form[:city] = billing_address[:city].to_s.slice(0, 30)
75
+ form[:state] = billing_address[:state].to_s.slice(0, 10)
76
+ form[:company] = billing_address[:company].to_s.slice(0, 50)
77
+ form[:phone] = billing_address[:phone].to_s.slice(0, 20)
78
+ form[:country] = billing_address[:country].to_s.slice(0, 50)
77
79
  end
78
-
79
- shipping_address = options[:shipping_address] || billing_address
80
-
81
- if shipping_address
80
+
81
+ if shipping_address = options[:shipping_address]
82
82
  first_name, last_name = parse_first_and_last_name(shipping_address[:name])
83
- form[:ship_to_first_name] = first_name
84
- form[:ship_to_last_name] = last_name
85
- form[:ship_to_address] = shipping_address[:address1]
86
- form[:ship_to_city] = shipping_address[:city]
87
- form[:ship_to_state] = shipping_address[:state]
88
- form[:ship_to_company] = shipping_address[:company]
89
- form[:ship_to_country] = shipping_address[:country]
90
- form[:ship_to_zip] = shipping_address[:zip]
83
+ form[:ship_to_first_name] = first_name.to_s.slice(0, 20)
84
+ form[:ship_to_last_name] = last_name.to_s.slice(0, 30)
85
+ form[:ship_to_address] = shipping_address[:address1].to_s.slice(0, 30)
86
+ form[:ship_to_city] = shipping_address[:city].to_s.slice(0, 30)
87
+ form[:ship_to_state] = shipping_address[:state].to_s.slice(0, 10)
88
+ form[:ship_to_company] = shipping_address[:company].to_s.slice(0, 50)
89
+ form[:ship_to_country] = shipping_address[:country].to_s.slice(0, 50)
90
+ form[:ship_to_zip] = shipping_address[:zip].to_s.slice(0, 10)
91
91
  end
92
92
  end
93
93
 
@@ -108,8 +108,8 @@ module ActiveMerchant #:nodoc:
108
108
  form[:cvv2] = 'present'
109
109
  end
110
110
 
111
- form[:first_name] = creditcard.first_name
112
- form[:last_name] = creditcard.last_name
111
+ form[:first_name] = creditcard.first_name.to_s.slice(0, 20)
112
+ form[:last_name] = creditcard.last_name.to_s.slice(0, 30)
113
113
  end
114
114
 
115
115
  def preamble
@@ -126,22 +126,16 @@ module ActiveMerchant #:nodoc:
126
126
  end
127
127
 
128
128
  def commit(action, money, parameters)
129
- if result = test_result_from_cc_number(parameters[:card_number])
130
- return result
131
- end
132
-
133
129
  parameters[:amount] = amount(money)
134
130
  parameters[:transaction_type] = action
135
131
 
136
- msg = ssl_post(test? ? TEST_URL : LIVE_URL, post_data(parameters))
137
-
138
- @response = parse(msg)
139
- success = @response['result'] == APPROVED
140
- message = @response['result_message']
141
-
142
- Response.new(success, message, @response,
132
+ response = parse( ssl_post(test? ? TEST_URL : LIVE_URL, post_data(parameters)) )
133
+
134
+ Response.new(response['result'] == APPROVED, response['result_message'], response,
143
135
  :test => @options[:test] || test?,
144
- :authorization => @response['txn_id']
136
+ :authorization => response['txn_id'],
137
+ :avs_result => { :code => response['avs_response'] },
138
+ :cvv_result => response['cvv2_response']
145
139
  )
146
140
  end
147
141
 
@@ -159,7 +153,7 @@ module ActiveMerchant #:nodoc:
159
153
 
160
154
  # Parse the response message
161
155
  def parse(msg)
162
- resp = Hash.new;
156
+ resp = {}
163
157
  msg.split("\r\n").collect{|li|
164
158
  key, value = li.split("=")
165
159
  resp[key.gsub(/^ssl_/, '')] = value.to_s.strip
@@ -1,11 +1,13 @@
1
1
  require 'active_merchant/billing/integrations/notification'
2
2
  require 'active_merchant/billing/integrations/helper'
3
+ require 'active_merchant/billing/integrations/return'
3
4
  require 'active_merchant/billing/integrations/bogus'
4
5
  require 'active_merchant/billing/integrations/chronopay'
5
6
  require 'active_merchant/billing/integrations/paypal'
6
7
  require 'active_merchant/billing/integrations/nochex'
7
8
  require 'active_merchant/billing/integrations/gestpay'
8
9
  require 'active_merchant/billing/integrations/two_checkout'
10
+ require 'active_merchant/billing/integrations/hi_trust'
9
11
 
10
12
  # make the bogus gateway be classified correctly by the inflector
11
13
  Inflector.inflections do |inflect|
@@ -1,5 +1,6 @@
1
1
  require 'active_merchant/billing/integrations/bogus/helper.rb'
2
2
  require 'active_merchant/billing/integrations/bogus/notification.rb'
3
+ require 'active_merchant/billing/integrations/bogus/return.rb'
3
4
 
4
5
  module ActiveMerchant #:nodoc:
5
6
  module Billing #:nodoc:
@@ -11,6 +12,10 @@ module ActiveMerchant #:nodoc:
11
12
  def self.notification(post)
12
13
  Notification.new(post)
13
14
  end
15
+
16
+ def self.return(query_string)
17
+ Return.new(query_string)
18
+ end
14
19
  end
15
20
  end
16
21
  end
@@ -0,0 +1,10 @@
1
+ module ActiveMerchant #:nodoc:
2
+ module Billing #:nodoc:
3
+ module Integrations #:nodoc:
4
+ module Bogus
5
+ class Return < ActiveMerchant::Billing::Integrations::Return
6
+ end
7
+ end
8
+ end
9
+ end
10
+ end
@@ -1,5 +1,6 @@
1
1
  require 'active_merchant/billing/integrations/chronopay/helper.rb'
2
2
  require 'active_merchant/billing/integrations/chronopay/notification.rb'
3
+ require 'active_merchant/billing/integrations/chronopay/return.rb'
3
4
 
4
5
  module ActiveMerchant #:nodoc:
5
6
  module Billing #:nodoc:
@@ -11,6 +12,10 @@ module ActiveMerchant #:nodoc:
11
12
  def self.notification(post)
12
13
  Notification.new(post)
13
14
  end
15
+
16
+ def self.return(query_string)
17
+ Return.new(query_string)
18
+ end
14
19
  end
15
20
  end
16
21
  end
@@ -0,0 +1,10 @@
1
+ module ActiveMerchant #:nodoc:
2
+ module Billing #:nodoc:
3
+ module Integrations #:nodoc:
4
+ module Chronopay
5
+ class Return < ActiveMerchant::Billing::Integrations::Return
6
+ end
7
+ end
8
+ end
9
+ end
10
+ end
@@ -3,6 +3,7 @@
3
3
  require File.dirname(__FILE__) + '/gestpay/common.rb'
4
4
  require File.dirname(__FILE__) + '/gestpay/helper.rb'
5
5
  require File.dirname(__FILE__) + '/gestpay/notification.rb'
6
+ require File.dirname(__FILE__) + '/gestpay/return.rb'
6
7
 
7
8
  module ActiveMerchant #:nodoc:
8
9
  module Billing #:nodoc:
@@ -15,6 +16,10 @@ module ActiveMerchant #:nodoc:
15
16
  def self.notification(post)
16
17
  Notification.new(post)
17
18
  end
19
+
20
+ def self.return(query_string)
21
+ Return.new(query_string)
22
+ end
18
23
  end
19
24
  end
20
25
  end
@@ -0,0 +1,10 @@
1
+ module ActiveMerchant #:nodoc:
2
+ module Billing #:nodoc:
3
+ module Integrations #:nodoc:
4
+ module Gestpay
5
+ class Return < ActiveMerchant::Billing::Integrations::Return
6
+ end
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,26 @@
1
+ require File.dirname(__FILE__) + '/hi_trust/helper.rb'
2
+ require File.dirname(__FILE__) + '/hi_trust/notification.rb'
3
+ require File.dirname(__FILE__) + '/hi_trust/return.rb'
4
+
5
+ module ActiveMerchant #:nodoc:
6
+ module Billing #:nodoc:
7
+ module Integrations #:nodoc:
8
+ module HiTrust
9
+ TEST_URL = 'https://testtrustlink.hitrust.com.tw/TrustLink/TrxReq'
10
+ LIVE_URL = 'https://trustlink.hitrust.com.tw/TrustLink/TrxReq'
11
+
12
+ def self.service_url
13
+ ActiveMerchant::Billing::Base.integration_mode == :test ? TEST_URL : LIVE_URL
14
+ end
15
+
16
+ def self.notification(post)
17
+ Notification.new(post)
18
+ end
19
+
20
+ def self.return(query_string)
21
+ Return.new(query_string)
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,58 @@
1
+ module ActiveMerchant #:nodoc:
2
+ module Billing #:nodoc:
3
+ module Integrations #:nodoc:
4
+ module HiTrust
5
+ class Helper < ActiveMerchant::Billing::Integrations::Helper
6
+
7
+ # Transaction types
8
+ # * Auth
9
+ # * AuthRe
10
+ # * Capture
11
+ # * CaptureRe
12
+ # * Refund
13
+ # * RefundRe
14
+ # * Query
15
+ def initialize(order, account, options = {})
16
+ super
17
+ # Perform an authorization by default
18
+ add_field('Type', 'Auth')
19
+
20
+ # Capture the payment right away
21
+ add_field('depositflag', '1')
22
+
23
+ # Disable auto query - who knows what it does?
24
+ add_field('queryflag', '1')
25
+
26
+ add_field('orderdesc', 'Store purchase')
27
+ end
28
+
29
+ mapping :account, 'storeid'
30
+ mapping :amount, 'amount'
31
+
32
+ def amount=(money)
33
+ cents = money.respond_to?(:cents) ? money.cents : money
34
+
35
+ if money.is_a?(String) or cents.to_i < 0
36
+ raise ArgumentError, 'money amount must be either a Money object or a positive integer in cents.'
37
+ end
38
+
39
+ add_field(mappings[:amount], cents)
40
+ end
41
+ # Supported currencies include:
42
+ # * CNY:Chinese Yuan (Renminbi)
43
+ # * TWD:New Taiwan Dollar
44
+ # * HKD:Hong Kong Dollar
45
+ # * USD:US Dollar
46
+ # * AUD:Austrian Dollar
47
+ mapping :currency, 'currency'
48
+
49
+ mapping :order, 'ordernumber'
50
+ mapping :description, 'orderdesc'
51
+
52
+ mapping :notify_url, 'merUpdateURL'
53
+ mapping :return_url, 'returnURL'
54
+ end
55
+ end
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,57 @@
1
+ require 'net/http'
2
+
3
+ module ActiveMerchant #:nodoc:
4
+ module Billing #:nodoc:
5
+ module Integrations #:nodoc:
6
+ module HiTrust
7
+ class Notification < ActiveMerchant::Billing::Integrations::Notification
8
+ SUCCESS = '00'
9
+
10
+ def complete?
11
+ status == 'Completed'
12
+ end
13
+
14
+ def transaction_id
15
+ params['authRRN']
16
+ end
17
+
18
+ def item_id
19
+ params['ordernumber']
20
+ end
21
+
22
+ def received_at
23
+ Time.parse(params['orderdate']) rescue nil
24
+ end
25
+
26
+ def currency
27
+ params['currency']
28
+ end
29
+
30
+ def gross
31
+ params['approveamount']
32
+ end
33
+
34
+ def gross_cents
35
+ gross.to_i
36
+ end
37
+
38
+ def account
39
+ params['storeid']
40
+ end
41
+
42
+ def status
43
+ params['retcode'] == SUCCESS ? 'Completed' : 'Failed'
44
+ end
45
+
46
+ def test?
47
+ ActiveMerchant::Billing::Base.integration_mode == :test
48
+ end
49
+
50
+ def acknowledge
51
+ true
52
+ end
53
+ end
54
+ end
55
+ end
56
+ end
57
+ end