smulube-activemerchant 1.5.1.4 → 1.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (211) hide show
  1. data.tar.gz.sig +0 -0
  2. data/CHANGELOG +9 -0
  3. data/CONTRIBUTORS +5 -1
  4. data/gem-public_cert.pem +18 -18
  5. data/lib/active_merchant.rb +9 -9
  6. data/lib/active_merchant/billing/gateways/braintree.rb +11 -11
  7. data/lib/active_merchant/billing/gateways/braintree/braintree_common.rb +9 -0
  8. data/lib/active_merchant/billing/gateways/braintree_blue.rb +210 -0
  9. data/lib/active_merchant/billing/gateways/braintree_orange.rb +17 -0
  10. data/lib/active_merchant/billing/gateways/payflow_nvp_uk.rb +10 -5
  11. data/lib/active_merchant/billing/integrations/action_view_helper.rb +1 -1
  12. data/lib/active_merchant/common.rb +14 -0
  13. data/lib/active_merchant/{lib → common}/connection.rb +2 -5
  14. data/lib/active_merchant/{lib → common}/country.rb +1 -1
  15. data/lib/active_merchant/common/error.rb +26 -0
  16. data/lib/active_merchant/common/post_data.rb +24 -0
  17. data/lib/active_merchant/{lib → common}/posts_data.rb +0 -0
  18. data/lib/active_merchant/{lib → common}/requires_parameters.rb +0 -0
  19. data/lib/active_merchant/{lib → common}/utils.rb +0 -0
  20. data/lib/active_merchant/{lib → common}/validateable.rb +0 -0
  21. data/lib/active_merchant/version.rb +1 -1
  22. data/lib/active_merchant/version.rb.orig +7 -0
  23. data/lib/activemerchant.rb +1 -0
  24. data/lib/support/outbound_hosts.rb +25 -0
  25. metadata +175 -493
  26. metadata.gz.sig +0 -0
  27. data/.gitignore +0 -7
  28. data/Rakefile +0 -85
  29. data/generators/gateway/USAGE +0 -5
  30. data/generators/gateway/gateway_generator.rb +0 -61
  31. data/generators/gateway/templates/gateway.rb +0 -77
  32. data/generators/gateway/templates/gateway_test.rb +0 -49
  33. data/generators/gateway/templates/remote_gateway_test.rb +0 -57
  34. data/generators/integration/USAGE +0 -5
  35. data/generators/integration/integration_generator.rb +0 -68
  36. data/generators/integration/templates/helper.rb +0 -34
  37. data/generators/integration/templates/helper_test.rb +0 -54
  38. data/generators/integration/templates/integration.rb +0 -18
  39. data/generators/integration/templates/module_test.rb +0 -9
  40. data/generators/integration/templates/notification.rb +0 -100
  41. data/generators/integration/templates/notification_test.rb +0 -41
  42. data/init.rb +0 -3
  43. data/lib/active_merchant/lib/error.rb +0 -4
  44. data/lib/active_merchant/lib/post_data.rb +0 -22
  45. data/script/destroy +0 -14
  46. data/script/generate +0 -14
  47. data/test/fixtures.yml +0 -360
  48. data/test/remote/gateways/remote_authorize_net_cim_test.rb +0 -460
  49. data/test/remote/gateways/remote_authorize_net_test.rb +0 -145
  50. data/test/remote/gateways/remote_beanstream_interac_test.rb +0 -53
  51. data/test/remote/gateways/remote_beanstream_test.rb +0 -150
  52. data/test/remote/gateways/remote_braintree_test.rb +0 -147
  53. data/test/remote/gateways/remote_card_stream_test.rb +0 -148
  54. data/test/remote/gateways/remote_cyber_source_test.rb +0 -146
  55. data/test/remote/gateways/remote_data_cash_test.rb +0 -356
  56. data/test/remote/gateways/remote_efsnet_test.rb +0 -81
  57. data/test/remote/gateways/remote_elavon_test.rb +0 -66
  58. data/test/remote/gateways/remote_eway_test.rb +0 -74
  59. data/test/remote/gateways/remote_exact_test.rb +0 -60
  60. data/test/remote/gateways/remote_first_pay_test.rb +0 -87
  61. data/test/remote/gateways/remote_garanti_test.rb +0 -58
  62. data/test/remote/gateways/remote_instapay_test.rb +0 -61
  63. data/test/remote/gateways/remote_jetpay_test.rb +0 -103
  64. data/test/remote/gateways/remote_linkpoint_test.rb +0 -121
  65. data/test/remote/gateways/remote_merchant_e_solutions_test.rb +0 -173
  66. data/test/remote/gateways/remote_merchant_ware_test.rb +0 -113
  67. data/test/remote/gateways/remote_modern_payments_cim_test.rb +0 -58
  68. data/test/remote/gateways/remote_modern_payments_test.rb +0 -57
  69. data/test/remote/gateways/remote_moneris_test.rb +0 -82
  70. data/test/remote/gateways/remote_net_registry_test.rb +0 -85
  71. data/test/remote/gateways/remote_netbilling_test.rb +0 -70
  72. data/test/remote/gateways/remote_ogone_test.rb +0 -115
  73. data/test/remote/gateways/remote_pay_junction_test.rb +0 -143
  74. data/test/remote/gateways/remote_pay_secure_test.rb +0 -39
  75. data/test/remote/gateways/remote_payflow_express_test.rb +0 -50
  76. data/test/remote/gateways/remote_payflow_nvp_uk_test.rb +0 -57
  77. data/test/remote/gateways/remote_payflow_test.rb +0 -237
  78. data/test/remote/gateways/remote_payflow_uk_test.rb +0 -173
  79. data/test/remote/gateways/remote_payment_express_test.rb +0 -136
  80. data/test/remote/gateways/remote_paypal_express_test.rb +0 -49
  81. data/test/remote/gateways/remote_paypal_test.rb +0 -191
  82. data/test/remote/gateways/remote_plugnpay_test.rb +0 -72
  83. data/test/remote/gateways/remote_psigate_test.rb +0 -50
  84. data/test/remote/gateways/remote_psl_card_test.rb +0 -123
  85. data/test/remote/gateways/remote_quickpay_test.rb +0 -190
  86. data/test/remote/gateways/remote_realex_test.rb +0 -224
  87. data/test/remote/gateways/remote_sage_bankcard_test.rb +0 -109
  88. data/test/remote/gateways/remote_sage_pay_test.rb +0 -219
  89. data/test/remote/gateways/remote_sage_test.rb +0 -87
  90. data/test/remote/gateways/remote_sage_virtual_check_test.rb +0 -62
  91. data/test/remote/gateways/remote_sallie_mae_test.rb +0 -51
  92. data/test/remote/gateways/remote_secure_pay_au_test.rb +0 -40
  93. data/test/remote/gateways/remote_secure_pay_tech_test.rb +0 -37
  94. data/test/remote/gateways/remote_secure_pay_test.rb +0 -28
  95. data/test/remote/gateways/remote_skipjack_test.rb +0 -105
  96. data/test/remote/gateways/remote_trans_first_test.rb +0 -34
  97. data/test/remote/gateways/remote_transax_test.rb +0 -112
  98. data/test/remote/gateways/remote_trust_commerce_test.rb +0 -152
  99. data/test/remote/gateways/remote_usa_epay_test.rb +0 -46
  100. data/test/remote/gateways/remote_verifi_test.rb +0 -107
  101. data/test/remote/gateways/remote_viaklix_test.rb +0 -43
  102. data/test/remote/gateways/remote_wirecard_test.rb +0 -111
  103. data/test/remote/integrations/remote_gestpay_integration_test.rb +0 -37
  104. data/test/remote/integrations/remote_paypal_integration_test.rb +0 -26
  105. data/test/test_helper.rb +0 -184
  106. data/test/unit/avs_result_test.rb +0 -59
  107. data/test/unit/base_test.rb +0 -54
  108. data/test/unit/check_test.rb +0 -88
  109. data/test/unit/connection_test.rb +0 -137
  110. data/test/unit/country_code_test.rb +0 -33
  111. data/test/unit/country_test.rb +0 -64
  112. data/test/unit/credit_card_formatting_test.rb +0 -19
  113. data/test/unit/credit_card_methods_test.rb +0 -192
  114. data/test/unit/credit_card_test.rb +0 -318
  115. data/test/unit/cvv_result_test.rb +0 -33
  116. data/test/unit/expiry_date_test.rb +0 -32
  117. data/test/unit/gateways/authorize_net_cim_test.rb +0 -676
  118. data/test/unit/gateways/authorize_net_test.rb +0 -290
  119. data/test/unit/gateways/beanstream_interac_test.rb +0 -51
  120. data/test/unit/gateways/beanstream_test.rb +0 -144
  121. data/test/unit/gateways/bogus_test.rb +0 -58
  122. data/test/unit/gateways/braintree_test.rb +0 -118
  123. data/test/unit/gateways/card_stream_test.rb +0 -90
  124. data/test/unit/gateways/cyber_source_test.rb +0 -188
  125. data/test/unit/gateways/data_cash_test.rb +0 -133
  126. data/test/unit/gateways/efsnet_test.rb +0 -123
  127. data/test/unit/gateways/elavon_test.rb +0 -139
  128. data/test/unit/gateways/eway_test.rb +0 -118
  129. data/test/unit/gateways/exact_test.rb +0 -156
  130. data/test/unit/gateways/first_pay_test.rb +0 -125
  131. data/test/unit/gateways/garanti_test.rb +0 -86
  132. data/test/unit/gateways/gateway_test.rb +0 -48
  133. data/test/unit/gateways/instapay_test.rb +0 -102
  134. data/test/unit/gateways/jetpay_test.rb +0 -185
  135. data/test/unit/gateways/linkpoint_test.rb +0 -197
  136. data/test/unit/gateways/merchant_e_solutions_test.rb +0 -169
  137. data/test/unit/gateways/merchant_ware_test.rb +0 -188
  138. data/test/unit/gateways/modern_payments_cim_test.rb +0 -162
  139. data/test/unit/gateways/moneris_test.rb +0 -158
  140. data/test/unit/gateways/net_registry_test.rb +0 -416
  141. data/test/unit/gateways/netbilling_test.rb +0 -54
  142. data/test/unit/gateways/ogone_test.rb +0 -319
  143. data/test/unit/gateways/pay_junction_test.rb +0 -123
  144. data/test/unit/gateways/pay_secure_test.rb +0 -71
  145. data/test/unit/gateways/payflow_express_test.rb +0 -173
  146. data/test/unit/gateways/payflow_express_uk_test.rb +0 -86
  147. data/test/unit/gateways/payflow_nvp_uk_test.rb +0 -205
  148. data/test/unit/gateways/payflow_test.rb +0 -305
  149. data/test/unit/gateways/payflow_uk_test.rb +0 -30
  150. data/test/unit/gateways/payment_express_test.rb +0 -195
  151. data/test/unit/gateways/paypal_express_test.rb +0 -389
  152. data/test/unit/gateways/paypal_test.rb +0 -569
  153. data/test/unit/gateways/plugnpay_test.rb +0 -86
  154. data/test/unit/gateways/psigate_test.rb +0 -169
  155. data/test/unit/gateways/psl_card_test.rb +0 -64
  156. data/test/unit/gateways/quickpay_test.rb +0 -112
  157. data/test/unit/gateways/realex_test.rb +0 -151
  158. data/test/unit/gateways/sage_bankcard_test.rb +0 -196
  159. data/test/unit/gateways/sage_pay_test.rb +0 -139
  160. data/test/unit/gateways/sage_virtual_check_test.rb +0 -71
  161. data/test/unit/gateways/sallie_mae_test.rb +0 -53
  162. data/test/unit/gateways/secure_pay_au_test.rb +0 -207
  163. data/test/unit/gateways/secure_pay_tech_test.rb +0 -44
  164. data/test/unit/gateways/secure_pay_test.rb +0 -101
  165. data/test/unit/gateways/skip_jack_test.rb +0 -228
  166. data/test/unit/gateways/trans_first_test.rb +0 -112
  167. data/test/unit/gateways/trust_commerce_test.rb +0 -90
  168. data/test/unit/gateways/usa_epay_test.rb +0 -128
  169. data/test/unit/gateways/verifi_test.rb +0 -96
  170. data/test/unit/gateways/viaklix_test.rb +0 -78
  171. data/test/unit/gateways/wirecard_test.rb +0 -250
  172. data/test/unit/generators/test_gateway_generator.rb +0 -46
  173. data/test/unit/generators/test_generator_helper.rb +0 -20
  174. data/test/unit/generators/test_integration_generator.rb +0 -53
  175. data/test/unit/integrations/action_view_helper_test.rb +0 -50
  176. data/test/unit/integrations/bogus_module_test.rb +0 -20
  177. data/test/unit/integrations/chronopay_module_test.rb +0 -13
  178. data/test/unit/integrations/gestpay_module_test.rb +0 -14
  179. data/test/unit/integrations/helpers/bogus_helper_test.rb +0 -28
  180. data/test/unit/integrations/helpers/chronopay_helper_test.rb +0 -110
  181. data/test/unit/integrations/helpers/gestpay_helper_test.rb +0 -100
  182. data/test/unit/integrations/helpers/hi_trust_helper_test.rb +0 -16
  183. data/test/unit/integrations/helpers/nochex_helper_test.rb +0 -53
  184. data/test/unit/integrations/helpers/paypal_helper_test.rb +0 -171
  185. data/test/unit/integrations/helpers/quickpay_helper_test.rb +0 -40
  186. data/test/unit/integrations/helpers/two_checkout_helper_test.rb +0 -92
  187. data/test/unit/integrations/hi_trust_module_test.rb +0 -13
  188. data/test/unit/integrations/nochex_module_test.rb +0 -13
  189. data/test/unit/integrations/notifications/chronopay_notification_test.rb +0 -66
  190. data/test/unit/integrations/notifications/gestpay_notification_test.rb +0 -60
  191. data/test/unit/integrations/notifications/hi_trust_notification_test.rb +0 -59
  192. data/test/unit/integrations/notifications/nochex_notification_test.rb +0 -51
  193. data/test/unit/integrations/notifications/notification_test.rb +0 -54
  194. data/test/unit/integrations/notifications/paypal_notification_test.rb +0 -85
  195. data/test/unit/integrations/notifications/quickpay_notification_test.rb +0 -69
  196. data/test/unit/integrations/notifications/two_checkout_notification_test.rb +0 -55
  197. data/test/unit/integrations/paypal_module_test.rb +0 -28
  198. data/test/unit/integrations/quickpay_module_test.rb +0 -9
  199. data/test/unit/integrations/returns/chronopay_return_test.rb +0 -11
  200. data/test/unit/integrations/returns/gestpay_return_test.rb +0 -10
  201. data/test/unit/integrations/returns/hi_trust_return_test.rb +0 -24
  202. data/test/unit/integrations/returns/nochex_return_test.rb +0 -10
  203. data/test/unit/integrations/returns/paypal_return_test.rb +0 -10
  204. data/test/unit/integrations/returns/return_test.rb +0 -11
  205. data/test/unit/integrations/returns/two_checkout_return_test.rb +0 -24
  206. data/test/unit/integrations/two_checkout_module_test.rb +0 -13
  207. data/test/unit/post_data_test.rb +0 -55
  208. data/test/unit/posts_data_test.rb +0 -48
  209. data/test/unit/response_test.rb +0 -28
  210. data/test/unit/utils_test.rb +0 -7
  211. data/test/unit/validateable_test.rb +0 -60
data.tar.gz.sig CHANGED
Binary file
data/CHANGELOG CHANGED
@@ -1,5 +1,14 @@
1
1
  = ActiveMerchant CHANGELOG
2
2
 
3
+ * Pull in only the necessary components of Active Support. Enables use of ActiveMerchant with Rails 3 [railsjedi]
4
+
5
+ == Version 1.7.0 (July 9, 2010)
6
+
7
+ * Add support for new Braintree Blue Gateway (using the braintree gem) [Braintree]
8
+
9
+ == Version 1.6.0 (July 6, 2010)
10
+
11
+ * Add a task rake gateways:hosts to get a list of all outbound hosts and ports [cody]
3
12
  * Fix test failure in chronopay helper in Ruby 1.9.1 [cody]
4
13
  * Fix timezone issue in credit card test. [cody]
5
14
  * Fix failing unit test for Garanti gateway [cody]
data/CONTRIBUTORS CHANGED
@@ -135,4 +135,8 @@ SallieMae (October 2, 2009)
135
135
 
136
136
  Garanti (May 05, 2010)
137
137
 
138
- * Selem Delul (moon@mac.home)
138
+ * Selem Delul (moon@mac.home)
139
+
140
+ Braintree Blue Gateway (May 19th, 2010)
141
+
142
+ * Braintree (code@getbraintree.com)
data/gem-public_cert.pem CHANGED
@@ -1,20 +1,20 @@
1
1
  -----BEGIN CERTIFICATE-----
2
- MIIDNjCCAh6gAwIBAgIBADANBgkqhkiG9w0BAQUFADBBMRMwEQYDVQQDDApjb2R5
3
- ZmF1c2VyMRUwEwYKCZImiZPyLGQBGRYFZ21haWwxEzARBgoJkiaJk/IsZAEZFgNj
4
- b20wHhcNMDcwMjIyMTcyMTI3WhcNMDgwMjIyMTcyMTI3WjBBMRMwEQYDVQQDDApj
5
- b2R5ZmF1c2VyMRUwEwYK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-----END CERTIFICATE-----
@@ -24,19 +24,19 @@
24
24
  $:.unshift File.dirname(__FILE__)
25
25
 
26
26
  require 'active_support'
27
+ require 'active_support/core_ext/hash/indifferent_access'
28
+ require 'active_support/core_ext/class/inheritable_attributes'
29
+ require 'active_support/core_ext/class/attribute_accessors'
30
+ require 'active_support/core_ext/class/delegating_attributes'
31
+ require 'active_support/core_ext/module/attribute_accessors'
32
+ require 'active_support/core_ext/kernel/requires'
33
+ require 'active_support/inflector'
34
+
27
35
  require 'builder'
28
36
  require 'cgi'
29
37
  require 'rexml/document'
30
38
 
31
- require 'active_merchant/lib/utils'
32
- require 'active_merchant/lib/error'
33
- require 'active_merchant/lib/validateable'
34
- require 'active_merchant/lib/connection'
35
- require 'active_merchant/lib/posts_data'
36
- require 'active_merchant/lib/post_data'
37
- require 'active_merchant/lib/requires_parameters'
38
- require 'active_merchant/lib/country'
39
-
39
+ require 'active_merchant/common'
40
40
  require 'active_merchant/billing'
41
41
  require 'active_merchant/version'
42
42
 
@@ -1,17 +1,17 @@
1
- require File.join(File.dirname(__FILE__),'smart_ps.rb')
1
+ require File.dirname(__FILE__) + '/braintree/braintree_common'
2
+
2
3
  module ActiveMerchant #:nodoc:
3
4
  module Billing #:nodoc:
4
- class BraintreeGateway < SmartPs
5
- def api_url
6
- 'https://secure.braintreepaymentgateway.com/api/transact.php'
5
+ class BraintreeGateway < Gateway
6
+ include BraintreeCommon
7
+
8
+ def self.new(options={})
9
+ if options.has_key?(:login)
10
+ BraintreeOrangeGateway.new(options)
11
+ else
12
+ BraintreeBlueGateway.new(options)
13
+ end
7
14
  end
8
-
9
- self.supported_countries = ['US']
10
- self.supported_cardtypes = [:visa, :master, :american_express, :discover]
11
- self.homepage_url = 'http://www.braintreepaymentsolutions.com'
12
- self.display_name = 'Braintree'
13
- self.default_currency = 'USD'
14
15
  end
15
16
  end
16
17
  end
17
-
@@ -0,0 +1,9 @@
1
+ module BraintreeCommon
2
+ def self.included(base)
3
+ base.supported_countries = ['US']
4
+ base.supported_cardtypes = [:visa, :master, :american_express, :discover, :jcb]
5
+ base.homepage_url = 'http://www.braintreepaymentsolutions.com'
6
+ base.display_name = 'Braintree'
7
+ base.default_currency = 'USD'
8
+ end
9
+ end
@@ -0,0 +1,210 @@
1
+ require File.dirname(__FILE__) + '/braintree/braintree_common'
2
+
3
+ begin
4
+ require "braintree"
5
+ rescue LoadError
6
+ raise "Could not load the braintree gem. Use `gem install braintree` to install it."
7
+ end
8
+
9
+ raise "Need braintree gem 2.x.y. Run `gem install braintree --version '~>2.0'` to get the correct version." unless Braintree::Version::Major == 2
10
+
11
+ module ActiveMerchant #:nodoc:
12
+ module Billing #:nodoc:
13
+ class BraintreeBlueGateway < Gateway
14
+ include BraintreeCommon
15
+
16
+ self.display_name = 'Braintree (Blue Platform)'
17
+
18
+ def initialize(options = {})
19
+ requires!(options, :merchant_id, :public_key, :private_key)
20
+ @options = options
21
+ Braintree::Configuration.merchant_id = options[:merchant_id]
22
+ Braintree::Configuration.public_key = options[:public_key]
23
+ Braintree::Configuration.private_key = options[:private_key]
24
+ Braintree::Configuration.environment = test? ? :sandbox : :production
25
+ Braintree::Configuration.logger.level = Logger::ERROR#DEBUG
26
+ Braintree::Configuration.custom_user_agent = "ActiveMerchant #{ActiveMerchant::VERSION}"
27
+ super
28
+ end
29
+
30
+ def authorize(money, credit_card_or_vault_id, options = {})
31
+ create_transaction(:sale, money, credit_card_or_vault_id, options)
32
+ end
33
+
34
+ def capture(money, authorization, options = {})
35
+ commit do
36
+ result = Braintree::Transaction.submit_for_settlement(authorization, amount(money).to_s)
37
+ Response.new(result.success?, message_from_result(result))
38
+ end
39
+ end
40
+
41
+ def purchase(money, credit_card_or_vault_id, options = {})
42
+ authorize(money, credit_card_or_vault_id, options.merge(:submit_for_settlement => true))
43
+ end
44
+
45
+ def credit(money, credit_card_or_vault_id, options = {})
46
+ create_transaction(:credit, money, credit_card_or_vault_id, options)
47
+ end
48
+
49
+ def refund(transaction_id, options = {})
50
+ commit do
51
+ result = Braintree::Transaction.find(transaction_id).refund
52
+ Response.new(result.success?, message_from_result(result))
53
+ end
54
+ end
55
+
56
+ def void(authorization, options = {})
57
+ commit do
58
+ result = Braintree::Transaction.void(authorization)
59
+ Response.new(result.success?, message_from_result(result),
60
+ :braintree_transaction => (result.transaction if result.success?)
61
+ )
62
+ end
63
+ end
64
+
65
+ def store(creditcard, options = {})
66
+ commit do
67
+ result = Braintree::Customer.create(
68
+ :first_name => creditcard.first_name,
69
+ :last_name => creditcard.last_name,
70
+ :email => options[:email],
71
+ :credit_card => {
72
+ :number => creditcard.number,
73
+ :cvv => creditcard.verification_value,
74
+ :expiration_month => creditcard.month.to_s.rjust(2, "0"),
75
+ :expiration_year => creditcard.year.to_s
76
+ }
77
+ )
78
+ Response.new(result.success?, message_from_result(result),
79
+ {
80
+ :braintree_customer => (result.customer if result.success?),
81
+ :customer_vault_id => (result.customer.id if result.success?)
82
+ }
83
+ )
84
+ end
85
+ end
86
+
87
+ def update(vault_id, creditcard, options = {})
88
+ braintree_credit_card = nil
89
+ customer_update_result = commit do
90
+ braintree_credit_card = Braintree::Customer.find(vault_id).credit_cards.detect { |cc| cc.default? }
91
+ return Response.new(false, 'Braintree::NotFoundError') if braintree_credit_card.nil?
92
+ result = Braintree::Customer.update(vault_id,
93
+ :first_name => creditcard.first_name,
94
+ :last_name => creditcard.last_name,
95
+ :email => options[:email]
96
+ )
97
+ Response.new(result.success?, message_from_result(result),
98
+ :braintree_customer => (Braintree::Customer.find(vault_id) if result.success?)
99
+ )
100
+ end
101
+ return customer_update_result unless customer_update_result.success?
102
+ credit_card_update_result = commit do
103
+ result = Braintree::CreditCard.update(braintree_credit_card.token,
104
+ :number => creditcard.number,
105
+ :expiration_month => creditcard.month.to_s.rjust(2, "0"),
106
+ :expiration_year => creditcard.year.to_s
107
+ )
108
+ Response.new(result.success?, message_from_result(result),
109
+ :braintree_customer => (Braintree::Customer.find(vault_id) if result.success?)
110
+ )
111
+ end
112
+ end
113
+
114
+ def unstore(customer_vault_id)
115
+ commit do
116
+ Braintree::Customer.delete(customer_vault_id)
117
+ Response.new(true, "OK")
118
+ end
119
+ end
120
+ alias_method :delete, :unstore
121
+
122
+ private
123
+
124
+ def map_address(address)
125
+ return {} if address.nil?
126
+ {
127
+ :street_address => address[:address1],
128
+ :extended_address => address[:address2],
129
+ :company => address[:company],
130
+ :locality => address[:city],
131
+ :region => address[:state],
132
+ :postal_code => address[:zip],
133
+ :country_name => address[:country]
134
+ }
135
+ end
136
+
137
+ def commit(&block)
138
+ yield
139
+ rescue Braintree::BraintreeError => ex
140
+ Response.new(false, ex.class.to_s)
141
+ end
142
+
143
+ def message_from_result(result)
144
+ if result.success?
145
+ "OK"
146
+ else
147
+ result.errors.map { |e| "#{e.message} (#{e.code})" }.join(" ")
148
+ end
149
+ end
150
+
151
+ def create_transaction(transaction_type, money, credit_card_or_vault_id, options)
152
+ parameters = {
153
+ :amount => amount(money).to_s,
154
+ :order_id => options[:order_id],
155
+ :customer => {
156
+ :id => options[:store] == true ? "" : options[:store],
157
+ :email => options[:email]
158
+ },
159
+ :options => {
160
+ :store_in_vault => options[:store] ? true : false,
161
+ :submit_for_settlement => options[:submit_for_settlement]
162
+ }
163
+ }
164
+ if credit_card_or_vault_id.is_a?(String) || credit_card_or_vault_id.is_a?(Integer)
165
+ parameters[:customer_id] = credit_card_or_vault_id
166
+ else
167
+ parameters[:customer].merge!(
168
+ :first_name => credit_card_or_vault_id.first_name,
169
+ :last_name => credit_card_or_vault_id.last_name
170
+ )
171
+ parameters[:credit_card] = {
172
+ :number => credit_card_or_vault_id.number,
173
+ :cvv => credit_card_or_vault_id.verification_value,
174
+ :expiration_month => credit_card_or_vault_id.month.to_s.rjust(2, "0"),
175
+ :expiration_year => credit_card_or_vault_id.year.to_s
176
+ }
177
+ end
178
+ parameters[:billing] = map_address(options[:billing_address]) if options[:billing_address]
179
+ parameters[:shipping] = map_address(options[:shipping_address]) if options[:shipping_address]
180
+ commit do
181
+ result = Braintree::Transaction.send(transaction_type, parameters)
182
+ response_params, response_options, avs_result, cvv_result = {}, {}, {}, {}
183
+ if result.success?
184
+ response_params[:braintree_transaction] = result.transaction
185
+ response_params[:customer_vault_id] = result.transaction.customer_details.id
186
+ response_options[:authorization] = result.transaction.id
187
+ end
188
+ if result.transaction
189
+ avs_result = {
190
+ 'code' => '', 'message' => '',
191
+ 'street_match' => result.transaction.avs_street_address_response_code == 'M',
192
+ 'postal_match' => result.transaction.avs_postal_code_response_code == 'M'
193
+ }
194
+ cvv_result = {
195
+ 'code' => result.transaction.cvv_response_code, 'message' => ''
196
+ }
197
+ message = result.transaction.processor_response_code + " " + result.transaction.processor_response_text
198
+ else
199
+ message = message_from_result(result)
200
+ end
201
+ response = Response.new(result.success?, message, response_params, response_options)
202
+ response.instance_variable_set("@avs_result", avs_result)
203
+ response.instance_variable_set("@cvv_result", cvv_result)
204
+ response
205
+ end
206
+ end
207
+ end
208
+ end
209
+ end
210
+
@@ -0,0 +1,17 @@
1
+ require File.dirname(__FILE__) + '/smart_ps.rb'
2
+ require File.dirname(__FILE__) + '/braintree/braintree_common'
3
+
4
+ module ActiveMerchant #:nodoc:
5
+ module Billing #:nodoc:
6
+ class BraintreeOrangeGateway < SmartPs
7
+ include BraintreeCommon
8
+
9
+ self.display_name = 'Braintree (Orange Platform)'
10
+
11
+ def api_url
12
+ 'https://secure.braintreepaymentgateway.com/api/transact.php'
13
+ end
14
+ end
15
+ end
16
+ end
17
+
@@ -308,14 +308,19 @@ module ActiveMerchant #:nodoc:
308
308
  end
309
309
 
310
310
  def add_recurring_info(post, creditcard, options)
311
- post[:action] = options.has_key?(:profile_id) ? RECURRING_ACTIONS[:modify] : RECURRING_ACTIONS[:create]
312
- post[:start] = format_date(options[:starting_at])
311
+ if options.has_key?(:profile_id)
312
+ post[:action] = RECURRING_ACTIONS[:modify]
313
+ post[:origprofileid] = options[:profile_id]
314
+ else
315
+ post[:action] = RECURRING_ACTIONS[:create]
316
+ end
317
+ post[:start] = format_date(options[:starting_at]) unless options[:starting_at].nil?
313
318
  post[:term] = options[:payments] unless options[:payments].nil?
314
- post[:payperiod] = PERIODS[options[:periodicity]]
319
+ post[:payperiod] = PERIODS[options[:periodicity]] unless options[:periodicity].nil?
315
320
  post[:desc] = options[:comment] unless options[:comment].nil?
316
321
  post[:maxfailpayments] = options[:max_failed_payments] unless options[:max_failed_payments].nil?
317
- post[:profilename] = (options[:name] || creditcard.name).to_s.slice(0,128)
318
- post[:desc] = options[:description]
322
+ post[:profilename] = (options[:name] || creditcard.name).to_s.slice(0,128) unless options[:name].nil? && creditcard.nil?
323
+ post[:desc] = options[:description] unless options[:description].nil?
319
324
  end
320
325
 
321
326
  def format_date(time)
@@ -71,7 +71,7 @@ module ActiveMerchant #:nodoc:
71
71
 
72
72
  private
73
73
  def ignore_binding?
74
- ActionPack::VERSION::MAJOR >= 2 && ActionPack::VERSION::MINOR >= 2
74
+ ActionPack::VERSION::MAJOR >= 3 || (ActionPack::VERSION::MAJOR >= 2 && ActionPack::VERSION::MINOR >= 2)
75
75
  end
76
76
  end
77
77
  end
@@ -0,0 +1,14 @@
1
+ module ActiveMerchant
2
+ autoload :Connection, 'active_merchant/common/connection'
3
+ autoload :Country, 'active_merchant/common/country'
4
+ autoload :ActiveMerchantError, 'active_merchant/common/error'
5
+ autoload :ConnectionError, 'active_merchant/common/error'
6
+ autoload :RetriableConnectionError, 'active_merchant/common/error'
7
+ autoload :ResponseError, 'active_merchant/common/error'
8
+ autoload :ClientCertificateError, 'active_merchant/common/error'
9
+ autoload :PostData, 'active_merchant/common/post_data'
10
+ autoload :PostsData, 'active_merchant/common/posts_data'
11
+ autoload :RequiresParameters, 'active_merchant/common/requires_parameters'
12
+ autoload :Utils, 'active_merchant/common/utils'
13
+ autoload :Validateable, 'active_merchant/common/validateable'
14
+ end
@@ -4,9 +4,6 @@ require 'net/https'
4
4
  require 'benchmark'
5
5
 
6
6
  module ActiveMerchant
7
- class ClientCertificateError < ActiveMerchantError # :nodoc
8
- end
9
-
10
7
  class ConnectionError < ActiveMerchantError # :nodoc:
11
8
  end
12
9
 
@@ -83,10 +80,10 @@ module ActiveMerchant
83
80
  raise ConnectionError, "The remote server reset the connection"
84
81
  rescue Errno::ECONNREFUSED => e
85
82
  raise RetriableConnectionError, "The remote server refused the connection"
86
- rescue Timeout::Error, Errno::ETIMEDOUT => e
87
- raise ConnectionError, "The connection to the remote server timed out"
88
83
  rescue OpenSSL::X509::CertificateError => e
89
84
  raise ClientCertificateError, "The remote server did not accept the provided SSL certificate"
85
+ rescue Timeout::Error, Errno::ETIMEDOUT => e
86
+ raise ConnectionError, "The connection to the remote server timed out"
90
87
  end
91
88
  end
92
89
  end
@@ -46,7 +46,7 @@ module ActiveMerchant #:nodoc:
46
46
  end
47
47
 
48
48
  def code(format)
49
- @codes.find{|c| c.format == format}
49
+ @codes.select{|c| c.format == format}
50
50
  end
51
51
 
52
52
  def to_s