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.
- data.tar.gz.sig +0 -0
- data/CHANGELOG +9 -0
- data/CONTRIBUTORS +5 -1
- data/gem-public_cert.pem +18 -18
- data/lib/active_merchant.rb +9 -9
- data/lib/active_merchant/billing/gateways/braintree.rb +11 -11
- data/lib/active_merchant/billing/gateways/braintree/braintree_common.rb +9 -0
- data/lib/active_merchant/billing/gateways/braintree_blue.rb +210 -0
- data/lib/active_merchant/billing/gateways/braintree_orange.rb +17 -0
- data/lib/active_merchant/billing/gateways/payflow_nvp_uk.rb +10 -5
- data/lib/active_merchant/billing/integrations/action_view_helper.rb +1 -1
- data/lib/active_merchant/common.rb +14 -0
- data/lib/active_merchant/{lib → common}/connection.rb +2 -5
- data/lib/active_merchant/{lib → common}/country.rb +1 -1
- data/lib/active_merchant/common/error.rb +26 -0
- data/lib/active_merchant/common/post_data.rb +24 -0
- data/lib/active_merchant/{lib → common}/posts_data.rb +0 -0
- data/lib/active_merchant/{lib → common}/requires_parameters.rb +0 -0
- data/lib/active_merchant/{lib → common}/utils.rb +0 -0
- data/lib/active_merchant/{lib → common}/validateable.rb +0 -0
- data/lib/active_merchant/version.rb +1 -1
- data/lib/active_merchant/version.rb.orig +7 -0
- data/lib/activemerchant.rb +1 -0
- data/lib/support/outbound_hosts.rb +25 -0
- metadata +175 -493
- metadata.gz.sig +0 -0
- data/.gitignore +0 -7
- data/Rakefile +0 -85
- data/generators/gateway/USAGE +0 -5
- data/generators/gateway/gateway_generator.rb +0 -61
- data/generators/gateway/templates/gateway.rb +0 -77
- data/generators/gateway/templates/gateway_test.rb +0 -49
- data/generators/gateway/templates/remote_gateway_test.rb +0 -57
- data/generators/integration/USAGE +0 -5
- data/generators/integration/integration_generator.rb +0 -68
- data/generators/integration/templates/helper.rb +0 -34
- data/generators/integration/templates/helper_test.rb +0 -54
- data/generators/integration/templates/integration.rb +0 -18
- data/generators/integration/templates/module_test.rb +0 -9
- data/generators/integration/templates/notification.rb +0 -100
- data/generators/integration/templates/notification_test.rb +0 -41
- data/init.rb +0 -3
- data/lib/active_merchant/lib/error.rb +0 -4
- data/lib/active_merchant/lib/post_data.rb +0 -22
- data/script/destroy +0 -14
- data/script/generate +0 -14
- data/test/fixtures.yml +0 -360
- data/test/remote/gateways/remote_authorize_net_cim_test.rb +0 -460
- data/test/remote/gateways/remote_authorize_net_test.rb +0 -145
- data/test/remote/gateways/remote_beanstream_interac_test.rb +0 -53
- data/test/remote/gateways/remote_beanstream_test.rb +0 -150
- data/test/remote/gateways/remote_braintree_test.rb +0 -147
- data/test/remote/gateways/remote_card_stream_test.rb +0 -148
- data/test/remote/gateways/remote_cyber_source_test.rb +0 -146
- data/test/remote/gateways/remote_data_cash_test.rb +0 -356
- data/test/remote/gateways/remote_efsnet_test.rb +0 -81
- data/test/remote/gateways/remote_elavon_test.rb +0 -66
- data/test/remote/gateways/remote_eway_test.rb +0 -74
- data/test/remote/gateways/remote_exact_test.rb +0 -60
- data/test/remote/gateways/remote_first_pay_test.rb +0 -87
- data/test/remote/gateways/remote_garanti_test.rb +0 -58
- data/test/remote/gateways/remote_instapay_test.rb +0 -61
- data/test/remote/gateways/remote_jetpay_test.rb +0 -103
- data/test/remote/gateways/remote_linkpoint_test.rb +0 -121
- data/test/remote/gateways/remote_merchant_e_solutions_test.rb +0 -173
- data/test/remote/gateways/remote_merchant_ware_test.rb +0 -113
- data/test/remote/gateways/remote_modern_payments_cim_test.rb +0 -58
- data/test/remote/gateways/remote_modern_payments_test.rb +0 -57
- data/test/remote/gateways/remote_moneris_test.rb +0 -82
- data/test/remote/gateways/remote_net_registry_test.rb +0 -85
- data/test/remote/gateways/remote_netbilling_test.rb +0 -70
- data/test/remote/gateways/remote_ogone_test.rb +0 -115
- data/test/remote/gateways/remote_pay_junction_test.rb +0 -143
- data/test/remote/gateways/remote_pay_secure_test.rb +0 -39
- data/test/remote/gateways/remote_payflow_express_test.rb +0 -50
- data/test/remote/gateways/remote_payflow_nvp_uk_test.rb +0 -57
- data/test/remote/gateways/remote_payflow_test.rb +0 -237
- data/test/remote/gateways/remote_payflow_uk_test.rb +0 -173
- data/test/remote/gateways/remote_payment_express_test.rb +0 -136
- data/test/remote/gateways/remote_paypal_express_test.rb +0 -49
- data/test/remote/gateways/remote_paypal_test.rb +0 -191
- data/test/remote/gateways/remote_plugnpay_test.rb +0 -72
- data/test/remote/gateways/remote_psigate_test.rb +0 -50
- data/test/remote/gateways/remote_psl_card_test.rb +0 -123
- data/test/remote/gateways/remote_quickpay_test.rb +0 -190
- data/test/remote/gateways/remote_realex_test.rb +0 -224
- data/test/remote/gateways/remote_sage_bankcard_test.rb +0 -109
- data/test/remote/gateways/remote_sage_pay_test.rb +0 -219
- data/test/remote/gateways/remote_sage_test.rb +0 -87
- data/test/remote/gateways/remote_sage_virtual_check_test.rb +0 -62
- data/test/remote/gateways/remote_sallie_mae_test.rb +0 -51
- data/test/remote/gateways/remote_secure_pay_au_test.rb +0 -40
- data/test/remote/gateways/remote_secure_pay_tech_test.rb +0 -37
- data/test/remote/gateways/remote_secure_pay_test.rb +0 -28
- data/test/remote/gateways/remote_skipjack_test.rb +0 -105
- data/test/remote/gateways/remote_trans_first_test.rb +0 -34
- data/test/remote/gateways/remote_transax_test.rb +0 -112
- data/test/remote/gateways/remote_trust_commerce_test.rb +0 -152
- data/test/remote/gateways/remote_usa_epay_test.rb +0 -46
- data/test/remote/gateways/remote_verifi_test.rb +0 -107
- data/test/remote/gateways/remote_viaklix_test.rb +0 -43
- data/test/remote/gateways/remote_wirecard_test.rb +0 -111
- data/test/remote/integrations/remote_gestpay_integration_test.rb +0 -37
- data/test/remote/integrations/remote_paypal_integration_test.rb +0 -26
- data/test/test_helper.rb +0 -184
- data/test/unit/avs_result_test.rb +0 -59
- data/test/unit/base_test.rb +0 -54
- data/test/unit/check_test.rb +0 -88
- data/test/unit/connection_test.rb +0 -137
- data/test/unit/country_code_test.rb +0 -33
- data/test/unit/country_test.rb +0 -64
- data/test/unit/credit_card_formatting_test.rb +0 -19
- data/test/unit/credit_card_methods_test.rb +0 -192
- data/test/unit/credit_card_test.rb +0 -318
- data/test/unit/cvv_result_test.rb +0 -33
- data/test/unit/expiry_date_test.rb +0 -32
- data/test/unit/gateways/authorize_net_cim_test.rb +0 -676
- data/test/unit/gateways/authorize_net_test.rb +0 -290
- data/test/unit/gateways/beanstream_interac_test.rb +0 -51
- data/test/unit/gateways/beanstream_test.rb +0 -144
- data/test/unit/gateways/bogus_test.rb +0 -58
- data/test/unit/gateways/braintree_test.rb +0 -118
- data/test/unit/gateways/card_stream_test.rb +0 -90
- data/test/unit/gateways/cyber_source_test.rb +0 -188
- data/test/unit/gateways/data_cash_test.rb +0 -133
- data/test/unit/gateways/efsnet_test.rb +0 -123
- data/test/unit/gateways/elavon_test.rb +0 -139
- data/test/unit/gateways/eway_test.rb +0 -118
- data/test/unit/gateways/exact_test.rb +0 -156
- data/test/unit/gateways/first_pay_test.rb +0 -125
- data/test/unit/gateways/garanti_test.rb +0 -86
- data/test/unit/gateways/gateway_test.rb +0 -48
- data/test/unit/gateways/instapay_test.rb +0 -102
- data/test/unit/gateways/jetpay_test.rb +0 -185
- data/test/unit/gateways/linkpoint_test.rb +0 -197
- data/test/unit/gateways/merchant_e_solutions_test.rb +0 -169
- data/test/unit/gateways/merchant_ware_test.rb +0 -188
- data/test/unit/gateways/modern_payments_cim_test.rb +0 -162
- data/test/unit/gateways/moneris_test.rb +0 -158
- data/test/unit/gateways/net_registry_test.rb +0 -416
- data/test/unit/gateways/netbilling_test.rb +0 -54
- data/test/unit/gateways/ogone_test.rb +0 -319
- data/test/unit/gateways/pay_junction_test.rb +0 -123
- data/test/unit/gateways/pay_secure_test.rb +0 -71
- data/test/unit/gateways/payflow_express_test.rb +0 -173
- data/test/unit/gateways/payflow_express_uk_test.rb +0 -86
- data/test/unit/gateways/payflow_nvp_uk_test.rb +0 -205
- data/test/unit/gateways/payflow_test.rb +0 -305
- data/test/unit/gateways/payflow_uk_test.rb +0 -30
- data/test/unit/gateways/payment_express_test.rb +0 -195
- data/test/unit/gateways/paypal_express_test.rb +0 -389
- data/test/unit/gateways/paypal_test.rb +0 -569
- data/test/unit/gateways/plugnpay_test.rb +0 -86
- data/test/unit/gateways/psigate_test.rb +0 -169
- data/test/unit/gateways/psl_card_test.rb +0 -64
- data/test/unit/gateways/quickpay_test.rb +0 -112
- data/test/unit/gateways/realex_test.rb +0 -151
- data/test/unit/gateways/sage_bankcard_test.rb +0 -196
- data/test/unit/gateways/sage_pay_test.rb +0 -139
- data/test/unit/gateways/sage_virtual_check_test.rb +0 -71
- data/test/unit/gateways/sallie_mae_test.rb +0 -53
- data/test/unit/gateways/secure_pay_au_test.rb +0 -207
- data/test/unit/gateways/secure_pay_tech_test.rb +0 -44
- data/test/unit/gateways/secure_pay_test.rb +0 -101
- data/test/unit/gateways/skip_jack_test.rb +0 -228
- data/test/unit/gateways/trans_first_test.rb +0 -112
- data/test/unit/gateways/trust_commerce_test.rb +0 -90
- data/test/unit/gateways/usa_epay_test.rb +0 -128
- data/test/unit/gateways/verifi_test.rb +0 -96
- data/test/unit/gateways/viaklix_test.rb +0 -78
- data/test/unit/gateways/wirecard_test.rb +0 -250
- data/test/unit/generators/test_gateway_generator.rb +0 -46
- data/test/unit/generators/test_generator_helper.rb +0 -20
- data/test/unit/generators/test_integration_generator.rb +0 -53
- data/test/unit/integrations/action_view_helper_test.rb +0 -50
- data/test/unit/integrations/bogus_module_test.rb +0 -20
- data/test/unit/integrations/chronopay_module_test.rb +0 -13
- data/test/unit/integrations/gestpay_module_test.rb +0 -14
- data/test/unit/integrations/helpers/bogus_helper_test.rb +0 -28
- data/test/unit/integrations/helpers/chronopay_helper_test.rb +0 -110
- data/test/unit/integrations/helpers/gestpay_helper_test.rb +0 -100
- data/test/unit/integrations/helpers/hi_trust_helper_test.rb +0 -16
- data/test/unit/integrations/helpers/nochex_helper_test.rb +0 -53
- data/test/unit/integrations/helpers/paypal_helper_test.rb +0 -171
- data/test/unit/integrations/helpers/quickpay_helper_test.rb +0 -40
- data/test/unit/integrations/helpers/two_checkout_helper_test.rb +0 -92
- data/test/unit/integrations/hi_trust_module_test.rb +0 -13
- data/test/unit/integrations/nochex_module_test.rb +0 -13
- data/test/unit/integrations/notifications/chronopay_notification_test.rb +0 -66
- data/test/unit/integrations/notifications/gestpay_notification_test.rb +0 -60
- data/test/unit/integrations/notifications/hi_trust_notification_test.rb +0 -59
- data/test/unit/integrations/notifications/nochex_notification_test.rb +0 -51
- data/test/unit/integrations/notifications/notification_test.rb +0 -54
- data/test/unit/integrations/notifications/paypal_notification_test.rb +0 -85
- data/test/unit/integrations/notifications/quickpay_notification_test.rb +0 -69
- data/test/unit/integrations/notifications/two_checkout_notification_test.rb +0 -55
- data/test/unit/integrations/paypal_module_test.rb +0 -28
- data/test/unit/integrations/quickpay_module_test.rb +0 -9
- data/test/unit/integrations/returns/chronopay_return_test.rb +0 -11
- data/test/unit/integrations/returns/gestpay_return_test.rb +0 -10
- data/test/unit/integrations/returns/hi_trust_return_test.rb +0 -24
- data/test/unit/integrations/returns/nochex_return_test.rb +0 -10
- data/test/unit/integrations/returns/paypal_return_test.rb +0 -10
- data/test/unit/integrations/returns/return_test.rb +0 -11
- data/test/unit/integrations/returns/two_checkout_return_test.rb +0 -24
- data/test/unit/integrations/two_checkout_module_test.rb +0 -13
- data/test/unit/post_data_test.rb +0 -55
- data/test/unit/posts_data_test.rb +0 -48
- data/test/unit/response_test.rb +0 -28
- data/test/unit/utils_test.rb +0 -7
- 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
data/gem-public_cert.pem
CHANGED
@@ -1,20 +1,20 @@
|
|
1
1
|
-----BEGIN CERTIFICATE-----
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
2
|
+
MIIDNjCCAh6gAwIBAgIBADANBgkqhkiG9w0BAQUFADBBMRMwEQYDVQQDDApzYW0u
|
3
|
+
bXVsdWJlMRUwEwYKCZImiZPyLGQBGRYFZ21haWwxEzARBgoJkiaJk/IsZAEZFgNj
|
4
|
+
b20wHhcNMTAwNzE0MjM1NTQzWhcNMTEwNzE0MjM1NTQzWjBBMRMwEQYDVQQDDApz
|
5
|
+
YW0ubXVsdWJlMRUwEwYKCZImiZPyLGQBGRYFZ21haWwxEzARBgoJkiaJk/IsZAEZ
|
6
|
+
FgNjb20wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC1S20wOTx1+MCv
|
7
|
+
8c/XMt8w+TgzIHkArMnmX0gb6ePapYYIk2kuW2sLeREqoBOjrMLJKKtdqTlp6jva
|
8
|
+
Xy/UP3dxh/jD1NDojv2HmCDP7ZFwLulLnsOgEPxM9bkwNAN3bgJNYOuQ0c41KqAO
|
9
|
+
F4A5apElftxZPmi7gobf+JiXwQKkw227gf0nwNMD3B1SIv34KiYIz4jLZm2lkGZf
|
10
|
+
tXT1GsRZTEwFDRMDoF9vxHJleCT0PbO8sw+IVWrP31sj5o4BR81N/y3uvXxiQUou
|
11
|
+
uy2LH4tNxukujkPapvmNxb/ElLkpCc4HDWH60IFQx6gkq0poJlkc8BrDQhA1yYYz
|
12
|
+
f2dA4XSxAgMBAAGjOTA3MAkGA1UdEwQCMAAwCwYDVR0PBAQDAgSwMB0GA1UdDgQW
|
13
|
+
BBSyF2LdgO72sQWoE6NRc02ZCeop1DANBgkqhkiG9w0BAQUFAAOCAQEALPXospc4
|
14
|
+
BO7pvZVz1kmSigS5dVaP/KubPjh+OLG6D83Iw4lzu2BrY/MMWaWUglRugj2y4giv
|
15
|
+
tgxZ6xZVHDDoaxbF3jf+iICgYCh1QnAWCqpHurcqbQrTWS9nNRUEIRyh2BNVLlR3
|
16
|
+
O5+kB0iyU0s/PEtPSLcAME7kwEugSU+CwRYohE3zBAa2STKKRLQk3Z/TBSmLX587
|
17
|
+
3tT9qmIz/NBeg8PJ3gbS3hrcm84s7htXoHfoKqeNnavTbDiZ9AJOIv3RniR0wo0K
|
18
|
+
dHld/h3mnLtULVKWxy1CkMLCLvKm7WN1IZMhmOBMtSfVvUHnBC2/DtIOvYmp4g8V
|
19
|
+
RGv1VYD5jSaHiQ==
|
20
20
|
-----END CERTIFICATE-----
|
data/lib/active_merchant.rb
CHANGED
@@ -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/
|
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.
|
1
|
+
require File.dirname(__FILE__) + '/braintree/braintree_common'
|
2
|
+
|
2
3
|
module ActiveMerchant #:nodoc:
|
3
4
|
module Billing #:nodoc:
|
4
|
-
class BraintreeGateway <
|
5
|
-
|
6
|
-
|
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
|
-
|
312
|
-
|
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
|