activemerchant 1.2.1 → 1.3.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 +310 -294
- data/CONTRIBUTERS +13 -0
- data/README +55 -31
- data/Rakefile +21 -13
- data/lib/active_merchant.rb +7 -0
- data/lib/active_merchant/billing/avs_result.rb +95 -0
- data/lib/active_merchant/billing/base.rb +8 -3
- data/lib/active_merchant/billing/check.rb +61 -0
- data/lib/active_merchant/billing/credit_card.rb +104 -80
- data/lib/active_merchant/billing/credit_card_formatting.rb +11 -8
- data/lib/active_merchant/billing/credit_card_methods.rb +76 -32
- data/lib/active_merchant/billing/cvv_result.rb +38 -0
- data/lib/active_merchant/billing/expiry_date.rb +28 -0
- data/lib/active_merchant/billing/gateway.rb +47 -111
- data/lib/active_merchant/billing/gateways/authorize_net.rb +508 -121
- data/lib/active_merchant/billing/gateways/bogus.rb +26 -32
- data/lib/active_merchant/billing/gateways/brain_tree.rb +82 -70
- data/lib/active_merchant/billing/gateways/card_stream.rb +43 -15
- data/lib/active_merchant/billing/gateways/cyber_source.rb +9 -29
- data/lib/active_merchant/billing/gateways/data_cash.rb +18 -38
- data/lib/active_merchant/billing/gateways/efsnet.rb +23 -50
- data/lib/active_merchant/billing/gateways/eway.rb +8 -19
- data/lib/active_merchant/billing/gateways/exact.rb +17 -25
- data/lib/active_merchant/billing/gateways/linkpoint.rb +18 -25
- data/lib/active_merchant/billing/gateways/moneris.rb +9 -39
- data/lib/active_merchant/billing/gateways/net_registry.rb +113 -182
- data/lib/active_merchant/billing/gateways/netbilling.rb +168 -0
- data/lib/active_merchant/billing/gateways/pay_junction.rb +52 -73
- data/lib/active_merchant/billing/gateways/pay_secure.rb +120 -0
- data/lib/active_merchant/billing/gateways/payflow.rb +13 -14
- data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +55 -37
- data/lib/active_merchant/billing/gateways/payflow/payflow_response.rb +4 -0
- data/lib/active_merchant/billing/gateways/payflow_express.rb +2 -4
- data/lib/active_merchant/billing/gateways/payment_express.rb +11 -30
- data/lib/active_merchant/billing/gateways/paypal.rb +3 -14
- data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +36 -16
- data/lib/active_merchant/billing/gateways/paypal_express.rb +1 -2
- data/lib/active_merchant/billing/gateways/plugnpay.rb +7 -15
- data/lib/active_merchant/billing/gateways/protx.rb +24 -25
- data/lib/active_merchant/billing/gateways/psigate.rb +34 -71
- data/lib/active_merchant/billing/gateways/psl_card.rb +24 -19
- data/lib/active_merchant/billing/gateways/quickpay.rb +10 -24
- data/lib/active_merchant/billing/gateways/realex.rb +7 -19
- data/lib/active_merchant/billing/gateways/secure_pay_tech.rb +113 -0
- data/lib/active_merchant/billing/gateways/skip_jack.rb +437 -0
- data/lib/active_merchant/billing/gateways/trans_first.rb +5 -14
- data/lib/active_merchant/billing/gateways/trust_commerce.rb +100 -39
- data/lib/active_merchant/billing/gateways/usa_epay.rb +60 -55
- data/lib/active_merchant/billing/gateways/verifi.rb +32 -39
- data/lib/active_merchant/billing/gateways/viaklix.rb +31 -37
- data/lib/active_merchant/billing/integrations.rb +2 -0
- data/lib/active_merchant/billing/integrations/bogus.rb +5 -0
- data/lib/active_merchant/billing/integrations/bogus/return.rb +10 -0
- data/lib/active_merchant/billing/integrations/chronopay.rb +5 -0
- data/lib/active_merchant/billing/integrations/chronopay/return.rb +10 -0
- data/lib/active_merchant/billing/integrations/gestpay.rb +5 -0
- data/lib/active_merchant/billing/integrations/gestpay/return.rb +10 -0
- data/lib/active_merchant/billing/integrations/hi_trust.rb +26 -0
- data/lib/active_merchant/billing/integrations/hi_trust/helper.rb +58 -0
- data/lib/active_merchant/billing/integrations/hi_trust/notification.rb +57 -0
- data/lib/active_merchant/billing/integrations/hi_trust/return.rb +67 -0
- data/lib/active_merchant/billing/integrations/nochex.rb +5 -0
- data/lib/active_merchant/billing/integrations/nochex/return.rb +10 -0
- data/lib/active_merchant/billing/integrations/paypal.rb +5 -0
- data/lib/active_merchant/billing/integrations/paypal/return.rb +10 -0
- data/lib/active_merchant/billing/integrations/return.rb +35 -0
- data/lib/active_merchant/billing/integrations/two_checkout.rb +5 -0
- data/lib/active_merchant/billing/integrations/two_checkout/return.rb +17 -0
- data/lib/active_merchant/billing/response.rb +12 -8
- data/lib/active_merchant/lib/posts_data.rb +39 -7
- data/lib/active_merchant/lib/requires_parameters.rb +2 -3
- data/lib/active_merchant/lib/utils.rb +18 -0
- data/lib/active_merchant/lib/validateable.rb +3 -3
- data/lib/support/gateway_support.rb +22 -9
- data/script/destroy +14 -0
- data/script/generate +7 -7
- data/test/fixtures.yml +25 -3
- data/test/remote/gateways/remote_authorize_net_test.rb +145 -0
- data/test/remote/gateways/remote_brain_tree_test.rb +118 -0
- data/test/{remote_tests → remote/gateways}/remote_card_stream_test.rb +56 -68
- data/test/{remote_tests → remote/gateways}/remote_cyber_source_test.rb +21 -32
- data/test/{remote_tests → remote/gateways}/remote_data_cash_test.rb +2 -2
- data/test/{remote_tests → remote/gateways}/remote_efsnet_test.rb +22 -34
- data/test/{remote_tests → remote/gateways}/remote_eway_test.rb +18 -15
- data/test/{remote_tests → remote/gateways}/remote_exact_test.rb +20 -19
- data/test/{remote_tests → remote/gateways}/remote_linkpoint_test.rb +31 -63
- data/test/remote/gateways/remote_moneris_test.rb +82 -0
- data/test/{remote_tests → remote/gateways}/remote_net_registry_test.rb +19 -54
- data/test/remote/gateways/remote_netbilling_test.rb +70 -0
- data/test/{remote_tests → remote/gateways}/remote_pay_junction_test.rb +41 -60
- data/test/remote/gateways/remote_pay_secure_test.rb +39 -0
- data/test/{remote_tests → remote/gateways}/remote_payflow_express_test.rb +2 -2
- data/test/{remote_tests → remote/gateways}/remote_payflow_test.rb +34 -38
- data/test/{remote_tests → remote/gateways}/remote_payflow_uk_test.rb +13 -12
- data/test/{remote_tests → remote/gateways}/remote_payment_express_test.rb +26 -36
- data/test/{remote_tests → remote/gateways}/remote_paypal_express_test.rb +3 -3
- data/test/{remote_tests → remote/gateways}/remote_paypal_test.rb +25 -21
- data/test/{remote_tests → remote/gateways}/remote_plugnpay_test.rb +18 -16
- data/test/{remote_tests → remote/gateways}/remote_protx_test.rb +33 -33
- data/test/remote/gateways/remote_psigate_test.rb +50 -0
- data/test/{remote_tests → remote/gateways}/remote_psl_card_test.rb +27 -26
- data/test/{remote_tests → remote/gateways}/remote_quickpay_test.rb +48 -48
- data/test/{remote_tests → remote/gateways}/remote_realex_test.rb +30 -33
- data/test/remote/gateways/remote_secure_pay_tech_test.rb +37 -0
- data/test/remote/gateways/remote_secure_pay_test.rb +28 -0
- data/test/remote/gateways/remote_skipjack_test.rb +105 -0
- data/test/{remote_tests → remote/gateways}/remote_trans_first_test.rb +7 -10
- data/test/remote/gateways/remote_trust_commerce_test.rb +152 -0
- data/test/{remote_tests → remote/gateways}/remote_usa_epay_test.rb +11 -22
- data/test/{remote_tests → remote/gateways}/remote_verifi_test.rb +27 -27
- data/test/{remote_tests → remote/gateways}/remote_viaklix_test.rb +8 -18
- data/test/{remote_tests → remote/integrations}/remote_gestpay_integration_test.rb +1 -1
- data/test/{remote_tests → remote/integrations}/remote_paypal_integration_test.rb +1 -1
- data/test/test_helper.rb +102 -61
- data/test/unit/avs_result_test.rb +59 -0
- data/test/unit/base_test.rb +33 -39
- data/test/unit/check_test.rb +76 -0
- data/test/unit/credit_card_formatting_test.rb +10 -15
- data/test/unit/credit_card_methods_test.rb +132 -17
- data/test/unit/credit_card_test.rb +157 -228
- data/test/unit/cvv_result_test.rb +33 -0
- data/test/unit/expiry_date_test.rb +21 -0
- data/test/unit/gateways/authorize_net_test.rb +180 -40
- data/test/unit/gateways/bogus_test.rb +2 -3
- data/test/unit/gateways/brain_tree_test.rb +63 -29
- data/test/unit/gateways/card_stream_test.rb +59 -6
- data/test/unit/gateways/cyber_source_test.rb +59 -40
- data/test/unit/gateways/data_cash_test.rb +82 -1
- data/test/unit/gateways/efsnet_test.rb +97 -44
- data/test/unit/gateways/eway_test.rb +55 -42
- data/test/unit/gateways/exact_test.rb +93 -55
- data/test/unit/gateways/gateway_test.rb +7 -0
- data/test/unit/gateways/linkpoint_test.rb +60 -58
- data/test/unit/gateways/moneris_test.rb +67 -76
- data/test/unit/gateways/net_registry_test.rb +351 -419
- data/test/unit/gateways/netbilling_test.rb +54 -0
- data/test/unit/gateways/pay_junction_test.rb +108 -46
- data/test/unit/gateways/pay_secure_test.rb +71 -0
- data/test/unit/gateways/payflow_express_test.rb +0 -8
- data/test/unit/gateways/payflow_test.rb +136 -65
- data/test/unit/gateways/payflow_uk_test.rb +0 -38
- data/test/unit/gateways/payment_express_test.rb +31 -51
- data/test/unit/gateways/paypal_express_test.rb +8 -2
- data/test/unit/gateways/paypal_test.rb +213 -54
- data/test/unit/gateways/plugnpay_test.rb +39 -32
- data/test/unit/gateways/protx_test.rb +45 -33
- data/test/unit/gateways/psigate_test.rb +146 -87
- data/test/unit/gateways/psl_card_test.rb +37 -24
- data/test/unit/gateways/quickpay_test.rb +33 -46
- data/test/unit/gateways/realex_test.rb +32 -31
- data/test/unit/gateways/secure_pay_tech_test.rb +44 -0
- data/test/unit/gateways/secure_pay_test.rb +35 -26
- data/test/unit/gateways/skip_jack_test.rb +125 -0
- data/test/unit/gateways/trans_first_test.rb +24 -37
- data/test/unit/gateways/trust_commerce_test.rb +47 -26
- data/test/unit/gateways/usa_epay_test.rb +52 -41
- data/test/unit/gateways/verifi_test.rb +41 -35
- data/test/unit/gateways/viaklix_test.rb +38 -32
- data/test/unit/generators/test_gateway_generator.rb +46 -0
- data/test/unit/generators/test_generator_helper.rb +20 -0
- data/test/unit/generators/test_integration_generator.rb +53 -0
- data/test/unit/integrations/action_view_helper_test.rb +7 -14
- data/test/unit/integrations/bogus_module_test.rb +4 -0
- data/test/unit/integrations/chronopay_module_test.rb +4 -0
- data/test/unit/integrations/gestpay_module_test.rb +4 -0
- data/test/unit/integrations/helpers/hi_trust_helper_test.rb +16 -0
- data/test/unit/integrations/hi_trust_module_test.rb +13 -0
- data/test/unit/integrations/nochex_module_test.rb +4 -0
- data/test/unit/integrations/notifications/hi_trust_notification_test.rb +38 -0
- data/test/unit/integrations/paypal_module_test.rb +4 -0
- data/test/unit/integrations/returns/chronopay_return_test.rb +11 -0
- data/test/unit/integrations/returns/gestpay_return_test.rb +10 -0
- data/test/unit/integrations/returns/hi_trust_return_test.rb +24 -0
- data/test/unit/integrations/returns/nochex_return_test.rb +10 -0
- data/test/unit/integrations/returns/paypal_return_test.rb +10 -0
- data/test/unit/integrations/returns/return_test.rb +11 -0
- data/test/unit/integrations/returns/two_checkout_return_test.rb +24 -0
- data/test/unit/integrations/two_checkout_module_test.rb +4 -0
- data/test/unit/posts_data_test.rb +86 -0
- data/test/unit/response_test.rb +15 -1
- data/test/unit/utils_test.rb +7 -0
- data/test/unit/validateable_test.rb +10 -6
- metadata +180 -142
- metadata.gz.sig +0 -0
- data/lib/active_merchant/billing/gateways/paypal/api_cert_chain.crt +0 -35
- data/script/generator/base.rb +0 -45
- data/script/generator/generator.rb +0 -24
- data/script/generator/generators/gateway/gateway_generator.rb +0 -14
- data/script/generator/generators/gateway/templates/gateway.rb +0 -73
- data/script/generator/generators/gateway/templates/gateway_test.rb +0 -41
- data/script/generator/generators/gateway/templates/remote_gateway_test.rb +0 -56
- data/script/generator/generators/integration/integration_generator.rb +0 -25
- data/script/generator/generators/integration/templates/helper.rb +0 -34
- data/script/generator/generators/integration/templates/helper_test.rb +0 -54
- data/script/generator/generators/integration/templates/integration.rb +0 -18
- data/script/generator/generators/integration/templates/module_test.rb +0 -9
- data/script/generator/generators/integration/templates/notification.rb +0 -100
- data/script/generator/generators/integration/templates/notification_test.rb +0 -41
- data/script/generator/manifest.rb +0 -20
- data/test/remote_tests/remote_authorize_net_test.rb +0 -113
- data/test/remote_tests/remote_brain_tree_test.rb +0 -78
- data/test/remote_tests/remote_moneris_test.rb +0 -110
- data/test/remote_tests/remote_psigate_test.rb +0 -87
- data/test/remote_tests/remote_secure_pay_test.rb +0 -36
- data/test/remote_tests/remote_trust_commerce_test.rb +0 -136
data/CONTRIBUTERS
CHANGED
@@ -46,7 +46,20 @@ Viaklix Gateway (Sep 3, 2007)
|
|
46
46
|
Braintree Gateway (Sep 4, 2007)
|
47
47
|
|
48
48
|
* Originally contributed by Michael J. Mangino
|
49
|
+
* Portions of the BrainTree gateway by Jeremy Voorhis
|
49
50
|
|
50
51
|
Concord Efsnet Gateway (Sep 7, 2007)
|
51
52
|
|
52
53
|
* Originally contributed by snacktime
|
54
|
+
|
55
|
+
SecurePayTech Gateway (Oct 23, 2007)
|
56
|
+
|
57
|
+
* Originally contributed by Jasper Bryant-Greene
|
58
|
+
|
59
|
+
SkipJack Gateway (Nov 29, 2007)
|
60
|
+
|
61
|
+
* Originally contributed by Bill Bereza - http://atomicobject.com
|
62
|
+
|
63
|
+
HiTRUST Gateway (Dec 10, 2007)
|
64
|
+
|
65
|
+
* Jaded Pixel
|
data/README
CHANGED
@@ -1,14 +1,16 @@
|
|
1
1
|
= Active Merchant
|
2
2
|
|
3
|
-
This library is supposed to aid in creating e-commerce software in Ruby.
|
4
|
-
In the future we want to support all "good" payment gateways.
|
3
|
+
This library is supposed to aid in creating e-commerce software in Ruby.
|
4
|
+
In the future we want to support all "good" payment gateways.
|
5
5
|
|
6
|
-
This library is the foundation of commerce for http://www.shopify.com.
|
6
|
+
This library is the foundation of commerce for http://www.shopify.com.
|
7
7
|
|
8
|
-
Please visit the {ActiveMerchant homepage}[http://activemerchant.org] for more resources, tutorials and other information about this project.
|
8
|
+
Please visit the {ActiveMerchant homepage}[http://activemerchant.org] for more resources, tutorials and other information about this project.
|
9
9
|
|
10
10
|
== Supported Direct Payment Gateways
|
11
11
|
|
12
|
+
The {ActiveMerchant Wiki}[http://code.google.com/p/activemerchant/wiki] contains a {table of features supported by each gateway}[http://code.google.com/p/activemerchant/wiki/SupportedGatewayPaymentOperations].
|
13
|
+
|
12
14
|
* {Authorize.net}[http://www.authorize.net/] - US
|
13
15
|
* {Braintree}[http://www.braintreepaymentsolutions.com] - US
|
14
16
|
* {CardStream}[http://www.cardstream.com/] - GB
|
@@ -20,7 +22,9 @@ Please visit the {ActiveMerchant homepage}[http://activemerchant.org] for more r
|
|
20
22
|
* {LinkPoint}[http://www.linkpoint.com/] - US
|
21
23
|
* {Moneris}[http://www.moneris.com/] - CA
|
22
24
|
* {NetRegistry}[http://www.netregistry.com.au] - AU
|
25
|
+
* {NETbilling}[http://www.netbilling.com] - US
|
23
26
|
* {PayJunction}[http://www.payjunction.com/] - US
|
27
|
+
* {PaySecure}[http://www.commsecure.com.au/paysecure.shtml] - AU
|
24
28
|
* {PayPal Express Checkout}[https://www.paypal.com/cgi-bin/webscr?cmd=xpt/merchant/ExpressCheckoutIntro-outside] - US, CA, SG, AU
|
25
29
|
* {PayPal Express Checkout (UK)}[https://www.paypal.com/uk/cgi-bin/webscr?cmd=_additional-payment-overview-outside] - GB
|
26
30
|
* {PayPal Payflow Pro}[https://www.paypal.com/cgi-bin/webscr?cmd=_payflow-pro-overview-outside] - US, CA, SG, AU
|
@@ -35,26 +39,29 @@ Please visit the {ActiveMerchant homepage}[http://activemerchant.org] for more r
|
|
35
39
|
* {Quickpay}[http://quickpay.dk/] - DK
|
36
40
|
* {Realex}[http://www.realexpayments.com/] - IE, GB
|
37
41
|
* {SecurePay}[http://www.securepay.com/] - US
|
42
|
+
* {SecurePayTech}[http://www.securepaytech.com/] - NZ
|
43
|
+
* {SkipJack}[http://www.skipjack.com/] - US, CA
|
38
44
|
* {TransFirst}[http://www.transfirst.com/] - US
|
39
45
|
* {TrustCommerce}[http://www.trustcommerce.com/] - US
|
40
|
-
* {USA ePay}[http://www.
|
46
|
+
* {USA ePay}[http://www.usaepay.com/] - US
|
41
47
|
* {Verifi}[http://www.verifi.com/] - US
|
42
48
|
* {ViaKLIX}[http://viaklix.com] - US
|
43
49
|
|
44
50
|
== Supported Offsite Payment Gateways
|
45
|
-
|
51
|
+
|
46
52
|
* {PayPal Website Payments Standard}[https://www.paypal.com/cgi-bin/webscr?cmd=_wp-standard-overview-outside]
|
47
53
|
* Chronopay[http://www.chronopay.com]
|
48
54
|
* Nochex[http://www.nochex.com]
|
49
55
|
* {Banca Sella GestPay}[https://www.sella.it/banca/ecommerce/gestpay/gestpay.jsp]
|
50
56
|
* {2 Checkout}[http://www.2checkout.com]
|
51
|
-
|
57
|
+
* {HiTRUST}[http://www.hitrust.com.hk/]
|
58
|
+
|
52
59
|
== Download
|
53
60
|
|
54
61
|
Currently this library is available with svn from:
|
55
62
|
|
56
|
-
|
57
|
-
|
63
|
+
http://activemerchant.googlecode.com/svn/trunk/active_merchant
|
64
|
+
|
58
65
|
== Installation
|
59
66
|
|
60
67
|
=== From Subversion
|
@@ -73,31 +80,48 @@ ActiveMerchant includes an init.rb file. This means that Rails will automaticall
|
|
73
80
|
|
74
81
|
Installation from RubyGems
|
75
82
|
|
76
|
-
> gem install activemerchant
|
83
|
+
> gem install activemerchant
|
77
84
|
|
78
85
|
== Sample Usage
|
86
|
+
require 'rubygems'
|
87
|
+
require 'active_merchant'
|
88
|
+
|
89
|
+
# Use the TrustCommerce test servers
|
90
|
+
ActiveMerchant::Billing::Base.mode = :test
|
91
|
+
|
92
|
+
# ActiveMerchant accepts all amounts as Integer values in cents
|
93
|
+
# $10.00
|
94
|
+
amount = 1000
|
95
|
+
|
96
|
+
# The card verification value is also known as CVV2, CVC2, or CID
|
97
|
+
credit_card = ActiveMerchant::Billing::CreditCard.new(
|
98
|
+
:first_name => 'Bob',
|
99
|
+
:last_name => 'Bobsen',
|
100
|
+
:number => '4242424242424242',
|
101
|
+
:month => '8',
|
102
|
+
:year => '2012',
|
103
|
+
:verification_value => '123'
|
104
|
+
)
|
105
|
+
|
106
|
+
# Validating the card automatically detects the card type
|
107
|
+
if credit_card.valid?
|
108
|
+
|
109
|
+
# Create a gateway object for the TrustCommerce service
|
110
|
+
gateway = ActiveMerchant::Billing::TrustCommerceGateway.new(
|
111
|
+
:login => 'TestMerchant',
|
112
|
+
:password => 'password'
|
113
|
+
)
|
114
|
+
|
115
|
+
# Authorize for the amount
|
116
|
+
response = gateway.purchase(amount, credit_card)
|
79
117
|
|
80
|
-
# 10 dollars in cents
|
81
|
-
ten_dollars = 1000
|
82
|
-
|
83
|
-
credit_card = CreditCard.new(
|
84
|
-
:number => '4242424242424242',
|
85
|
-
:month => 8,
|
86
|
-
:year => 2006,
|
87
|
-
:name => 'Tobias Luetke',
|
88
|
-
:type => 'visa'
|
89
|
-
)
|
90
|
-
|
91
|
-
if creditcard.valid?
|
92
|
-
gateway = ActiveMerchant::Billing::AuthorizeNetGateway.new(
|
93
|
-
:login => 'LOGIN_ID',
|
94
|
-
:password => 'TRANSACTION_KEY'
|
95
|
-
)
|
96
|
-
response = gateway.purchase(ten_dollars, credit_card)
|
97
|
-
|
98
118
|
if response.success?
|
99
|
-
|
119
|
+
puts "Successfully charged $#{sprintf("%.2f", amount / 100)} to the credit card #{credit_card.display_number}"
|
100
120
|
else
|
101
|
-
raise StandardError
|
121
|
+
raise StandardError, response.message
|
102
122
|
end
|
103
|
-
end
|
123
|
+
end
|
124
|
+
|
125
|
+
== Contributing
|
126
|
+
|
127
|
+
Please see the {ActiveMerchant Guide to Contributing}[http://code.google.com/p/activemerchant/wiki/Contributing] for information on adding a new gateway to ActiveMerchant.
|
data/Rakefile
CHANGED
@@ -8,7 +8,7 @@ require File.dirname(__FILE__) + '/lib/tasks/cia'
|
|
8
8
|
require File.dirname(__FILE__) + '/lib/support/gateway_support'
|
9
9
|
|
10
10
|
|
11
|
-
PKG_VERSION = "1.
|
11
|
+
PKG_VERSION = "1.3.0"
|
12
12
|
PKG_NAME = "activemerchant"
|
13
13
|
PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"
|
14
14
|
|
@@ -30,7 +30,7 @@ namespace :test do
|
|
30
30
|
end
|
31
31
|
|
32
32
|
Rake::TestTask.new(:remote) do |t|
|
33
|
-
t.pattern = 'test/
|
33
|
+
t.pattern = 'test/remote/**/*_test.rb'
|
34
34
|
t.ruby_opts << '-rubygems'
|
35
35
|
t.verbose = true
|
36
36
|
end
|
@@ -129,22 +129,30 @@ task :upload_rdoc => :rdoc do
|
|
129
129
|
end
|
130
130
|
|
131
131
|
namespace :gateways do
|
132
|
-
desc 'Print the currently supported gateways in RDoc format'
|
133
|
-
task :print_support_rdoc do
|
134
|
-
support = GatewaySupport.new
|
135
|
-
support.to_rdoc
|
136
|
-
end
|
137
|
-
|
138
132
|
desc 'Print the currently supported gateways'
|
139
|
-
task :
|
133
|
+
task :print do
|
140
134
|
support = GatewaySupport.new
|
141
135
|
support.to_s
|
142
136
|
end
|
143
137
|
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
138
|
+
namespace :print do
|
139
|
+
desc 'Print the currently supported gateways in RDoc format'
|
140
|
+
task :rdoc do
|
141
|
+
support = GatewaySupport.new
|
142
|
+
support.to_rdoc
|
143
|
+
end
|
144
|
+
|
145
|
+
desc 'Print the currently supported gateways in Textile format'
|
146
|
+
task :textile do
|
147
|
+
support = GatewaySupport.new
|
148
|
+
support.to_textile
|
149
|
+
end
|
150
|
+
|
151
|
+
desc 'Print the gateway functionality supported by each gateway'
|
152
|
+
task :features do
|
153
|
+
support = GatewaySupport.new
|
154
|
+
support.features
|
155
|
+
end
|
148
156
|
end
|
149
157
|
end
|
150
158
|
|
data/lib/active_merchant.rb
CHANGED
@@ -40,6 +40,7 @@ end
|
|
40
40
|
|
41
41
|
require 'cgi'
|
42
42
|
|
43
|
+
require 'active_merchant/lib/utils'
|
43
44
|
require 'active_merchant/lib/error'
|
44
45
|
require 'active_merchant/lib/validateable'
|
45
46
|
require 'active_merchant/lib/posts_data'
|
@@ -49,6 +50,12 @@ require 'active_merchant/lib/requires_parameters'
|
|
49
50
|
# Require the country class
|
50
51
|
require 'active_merchant/lib/country'
|
51
52
|
|
53
|
+
# Address Verification
|
54
|
+
require 'active_merchant/billing/avs_result'
|
55
|
+
|
56
|
+
# Card Verfication Code
|
57
|
+
require 'active_merchant/billing/cvv_result'
|
58
|
+
|
52
59
|
# CreditCard Utility class.
|
53
60
|
require 'active_merchant/billing/credit_card_methods'
|
54
61
|
require 'active_merchant/billing/credit_card_formatting'
|
@@ -0,0 +1,95 @@
|
|
1
|
+
module ActiveMerchant
|
2
|
+
module Billing
|
3
|
+
# Implements the Address Verification System
|
4
|
+
# https://www.wellsfargo.com/downloads/pdf/biz/merchant/visa_avs.pdf
|
5
|
+
# http://en.wikipedia.org/wiki/Address_Verification_System
|
6
|
+
# http://apps.cybersource.com/library/documentation/dev_guides/CC_Svcs_IG/html/app_avs_cvn_codes.htm#app_AVS_CVN_codes_7891_48375
|
7
|
+
# http://imgserver.skipjack.com/imgServer/5293710/AVS%20and%20CVV2.pdf
|
8
|
+
# http://www.emsecommerce.net/avs_cvv2_response_codes.htm
|
9
|
+
class AVSResult
|
10
|
+
MESSAGES = {
|
11
|
+
'A' => 'Street address matches, but 5-digit and 9-digit postal code do not match.',
|
12
|
+
'B' => 'Street address matches, but postal code not verified.',
|
13
|
+
'C' => 'Street address and postal code do not match.',
|
14
|
+
'D' => 'Street address and postal code match.',
|
15
|
+
'E' => 'AVS data is invalid or AVS is not allowed for this card type.',
|
16
|
+
'F' => 'Card member’s name does not match, but billing postal code matches.',
|
17
|
+
'G' => 'Non-U.S. issuing bank does not support AVS.',
|
18
|
+
'H' => 'Card member’s name does not match. Street address and postal code match.',
|
19
|
+
'I' => 'Address not verified.',
|
20
|
+
'J' => 'Card member’s name, billing address, and postal code match. Shipping information verified and chargeback protection guaranteed through the Fraud Protection Program.',
|
21
|
+
'K' => 'Card member’s name matches but billing address and billing postal code do not match.',
|
22
|
+
'L' => 'Card member’s name and billing postal code match, but billing address does not match.',
|
23
|
+
'M' => 'Street address and postal code match.',
|
24
|
+
'N' => 'Street address and postal code do not match.',
|
25
|
+
'O' => 'Card member’s name and billing address match, but billing postal code does not match.',
|
26
|
+
'P' => 'Postal code matches, but street address not verified.',
|
27
|
+
'Q' => 'Card member’s name, billing address, and postal code match. Shipping information verified but chargeback protection not guaranteed.',
|
28
|
+
'R' => 'System unavailable.',
|
29
|
+
'S' => 'U.S.-issuing bank does not support AVS.',
|
30
|
+
'T' => 'Card member’s name does not match, but street address matches.',
|
31
|
+
'U' => 'Address information unavailable.',
|
32
|
+
'V' => 'Card member’s name, billing address, and billing postal code match.',
|
33
|
+
'W' => 'Street address does not match, but 9-digit postal code matches.',
|
34
|
+
'X' => 'Street address and 9-digit postal code match.',
|
35
|
+
'Y' => 'Street address and 5-digit postal code match.',
|
36
|
+
'Z' => 'Street address does not match, but 5-digit postal code matches.'
|
37
|
+
}
|
38
|
+
|
39
|
+
# Map vendor's AVS result code to a postal match code
|
40
|
+
POSTAL_MATCH_CODE = {
|
41
|
+
'Y' => %w( D H F H J L M P Q V W X Y Z ),
|
42
|
+
'N' => %w( A C K N O ),
|
43
|
+
'X' => %w( G S ),
|
44
|
+
nil => %w( B E I R T U )
|
45
|
+
}.inject({}) do |map, (type, codes)|
|
46
|
+
codes.each { |code| map[code] = type }
|
47
|
+
map
|
48
|
+
end
|
49
|
+
|
50
|
+
# Map vendor's AVS result code to a street match code
|
51
|
+
STREET_MATCH_CODE = {
|
52
|
+
'Y' => %w( A B D H J M O Q T V X Y ),
|
53
|
+
'N' => %w( C K L N P W Z ),
|
54
|
+
'X' => %w( G S ),
|
55
|
+
nil => %w( E F I R U )
|
56
|
+
}.inject({}) do |map, (type, codes)|
|
57
|
+
codes.each { |code| map[code] = type }
|
58
|
+
map
|
59
|
+
end
|
60
|
+
|
61
|
+
attr_reader :code, :message, :street_match, :postal_match
|
62
|
+
|
63
|
+
def self.messages
|
64
|
+
MESSAGES
|
65
|
+
end
|
66
|
+
|
67
|
+
def initialize(attrs)
|
68
|
+
attrs ||= {}
|
69
|
+
|
70
|
+
@code = attrs[:code].upcase unless attrs[:code].blank?
|
71
|
+
@message = self.class.messages[code]
|
72
|
+
|
73
|
+
if attrs[:street_match].blank?
|
74
|
+
@street_match = STREET_MATCH_CODE[code]
|
75
|
+
else
|
76
|
+
@street_match = attrs[:street_match].upcase
|
77
|
+
end
|
78
|
+
|
79
|
+
if attrs[:postal_match].blank?
|
80
|
+
@postal_match = POSTAL_MATCH_CODE[code]
|
81
|
+
else
|
82
|
+
@postal_match = attrs[:postal_match].upcase
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
def to_hash
|
87
|
+
{ 'code' => code,
|
88
|
+
'message' => message,
|
89
|
+
'street_match' => street_match,
|
90
|
+
'postal_match' => postal_match
|
91
|
+
}
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
@@ -31,7 +31,7 @@ module ActiveMerchant #:nodoc:
|
|
31
31
|
#
|
32
32
|
# ActiveMerchant::Billing::Base.gateway('moneris').new
|
33
33
|
def self.gateway(name)
|
34
|
-
|
34
|
+
Billing.const_get("#{name.to_s.downcase}_gateway".camelize)
|
35
35
|
end
|
36
36
|
|
37
37
|
|
@@ -45,8 +45,13 @@ module ActiveMerchant #:nodoc:
|
|
45
45
|
# notification = chronopay.notification(raw_post)
|
46
46
|
#
|
47
47
|
def self.integration(name)
|
48
|
-
|
49
|
-
end
|
48
|
+
Billing::Integrations.const_get("#{name.to_s.downcase}".camelize)
|
49
|
+
end
|
50
|
+
|
51
|
+
# A check to see if we're in test mode
|
52
|
+
def self.test?
|
53
|
+
self.gateway_mode == :test
|
54
|
+
end
|
50
55
|
end
|
51
56
|
end
|
52
57
|
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
module ActiveMerchant #:nodoc:
|
2
|
+
module Billing #:nodoc:
|
3
|
+
# The Check object is a plain old Ruby object, similar to CreditCard. It supports validation
|
4
|
+
# of necessary attributes such as checkholder's name, routing and account numbers, but it is
|
5
|
+
# not backed by any database.
|
6
|
+
#
|
7
|
+
# You may use Check in place of CreditCard with any gateway that supports it. Currently, only
|
8
|
+
# +BrainTreeGateway+ supports the Check object.
|
9
|
+
class Check
|
10
|
+
include Validateable
|
11
|
+
|
12
|
+
attr_accessor :name, :routing_number, :account_number, :account_holder_type, :account_type
|
13
|
+
|
14
|
+
def initialize(args={})
|
15
|
+
args = args.with_indifferent_access
|
16
|
+
self.name = args[:name]
|
17
|
+
self.routing_number = args[:routing_number]
|
18
|
+
self.account_number = args[:account_number]
|
19
|
+
self.account_holder_type = args[:account_holder_type]
|
20
|
+
self.account_type = args[:account_type]
|
21
|
+
end
|
22
|
+
|
23
|
+
def validate
|
24
|
+
for attr in [:name, :routing_number, :account_number]
|
25
|
+
errors.add(attr, "cannot be empty") if self.send(attr).blank?
|
26
|
+
end
|
27
|
+
|
28
|
+
errors.add(:routing_number, "is invalid") unless valid_routing_number?
|
29
|
+
|
30
|
+
errors.add(:account_holder_type, "must be personal or business") if
|
31
|
+
!account_holder_type.blank? && !%w[business personal].include?(account_holder_type.to_s)
|
32
|
+
|
33
|
+
errors.add(:account_type, "must be checking or savings") if
|
34
|
+
!account_type.blank? && !%w[checking savings].include?(account_type.to_s)
|
35
|
+
end
|
36
|
+
|
37
|
+
def type
|
38
|
+
'check'
|
39
|
+
end
|
40
|
+
|
41
|
+
# Routing numbers may be validated by calculating a checksum and dividing it by 10. The
|
42
|
+
# formula is:
|
43
|
+
# (3(d1 + d4 + d7) + 7(d2 + d5 + d8) + 1(d3 + d6 + d9))mod 10 = 0
|
44
|
+
# See http://en.wikipedia.org/wiki/Routing_transit_number#Internal_checksums
|
45
|
+
def valid_routing_number?
|
46
|
+
d = routing_number.to_s.split('').map(&:to_i).select { |d| (0..9).include?(d) }
|
47
|
+
case d.size
|
48
|
+
when 9 then
|
49
|
+
checksum = ((3 * (d[0] + d[3] + d[6])) +
|
50
|
+
(7 * (d[1] + d[4] + d[7])) +
|
51
|
+
(d[2] + d[5] + d[8])) % 10
|
52
|
+
case checksum
|
53
|
+
when 0 then true
|
54
|
+
else false
|
55
|
+
end
|
56
|
+
else false
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -1,111 +1,77 @@
|
|
1
1
|
require 'time'
|
2
2
|
require 'date'
|
3
|
+
require 'active_merchant/billing/expiry_date'
|
3
4
|
|
4
5
|
module ActiveMerchant #:nodoc:
|
5
6
|
module Billing #:nodoc:
|
7
|
+
# == Description
|
6
8
|
# This credit card object can be used as a stand alone object. It acts just like an ActiveRecord object
|
7
9
|
# but doesn't support the .save method as its not backed by a database.
|
10
|
+
#
|
11
|
+
# For testing purposes, use the 'bogus' credit card type. This card skips the vast majority of
|
12
|
+
# validations. This allows you to focus on your core concerns until you're ready to be more concerned
|
13
|
+
# with the details of particular creditcards or your gateway.
|
14
|
+
#
|
15
|
+
# == Testing With CreditCard
|
16
|
+
# Often when testing we don't care about the particulars of a given card type. When using the 'test'
|
17
|
+
# mode in your Gateway, there are six different valid card numbers: 1, 2, 3, 'success', 'fail',
|
18
|
+
# and 'error'.
|
19
|
+
#
|
20
|
+
#--
|
21
|
+
# For details, see CreditCardMethods#valid_number?
|
22
|
+
#++
|
23
|
+
#
|
24
|
+
# == Example Usage
|
25
|
+
# cc = CreditCard.new(
|
26
|
+
# :first_name => 'Steve',
|
27
|
+
# :last_name => 'Smith',
|
28
|
+
# :month => '9',
|
29
|
+
# :year => '2010',
|
30
|
+
# :type => 'visa',
|
31
|
+
# :number => '4242424242424242'
|
32
|
+
# )
|
33
|
+
#
|
34
|
+
# cc.valid? # => true
|
35
|
+
# cc.display_number # => XXXX-XXXX-XXXX-4242
|
36
|
+
#
|
8
37
|
class CreditCard
|
9
38
|
include CreditCardMethods
|
10
39
|
include Validateable
|
11
40
|
|
41
|
+
## Attributes
|
42
|
+
|
12
43
|
cattr_accessor :require_verification_value
|
13
|
-
self.require_verification_value =
|
44
|
+
self.require_verification_value = true
|
14
45
|
|
15
|
-
|
16
|
-
require_verification_value
|
17
|
-
end
|
18
|
-
|
19
|
-
class ExpiryDate #:nodoc:
|
20
|
-
attr_reader :month, :year
|
21
|
-
def initialize(month, year)
|
22
|
-
@month = month
|
23
|
-
@year = year
|
24
|
-
end
|
25
|
-
|
26
|
-
def expired? #:nodoc:
|
27
|
-
Time.now > expiration rescue true
|
28
|
-
end
|
29
|
-
|
30
|
-
def expiration #:nodoc:
|
31
|
-
Time.parse("#{month}/#{month_days}/#{year} 23:59:59") rescue Time.at(0)
|
32
|
-
end
|
33
|
-
|
34
|
-
private
|
35
|
-
def month_days
|
36
|
-
mdays = [nil,31,28,31,30,31,30,31,31,30,31,30,31]
|
37
|
-
mdays[2] = 29 if Date.leap?(year)
|
38
|
-
mdays[month]
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
# required
|
46
|
+
# Essential attributes for a valid, non-bogus creditcards
|
43
47
|
attr_accessor :number, :month, :year, :type, :first_name, :last_name
|
44
48
|
|
45
|
-
#
|
49
|
+
# Required for Switch / Solo cards
|
46
50
|
attr_accessor :start_month, :start_year, :issue_number
|
47
51
|
|
48
|
-
# Optional verification_value (CVV, CVV2 etc)
|
49
|
-
#
|
50
|
-
# Gateways will try their best to run validation on the passed in value if it is supplied
|
51
|
-
#
|
52
|
+
# Optional verification_value (CVV, CVV2 etc). Gateways will try their best to
|
53
|
+
# run validation on the passed in value if it is supplied
|
52
54
|
attr_accessor :verification_value
|
53
55
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
self.year = year.to_i
|
58
|
-
self.number.to_s.gsub!(/[^\d]/, "")
|
56
|
+
# Provides proxy access to an expiry date object
|
57
|
+
def expiry_date
|
58
|
+
ExpiryDate.new(@month, @year)
|
59
59
|
end
|
60
60
|
|
61
|
-
def validate
|
62
|
-
errors.add :year, "expired" if expired?
|
63
|
-
|
64
|
-
errors.add :first_name, "cannot be empty" if @first_name.blank?
|
65
|
-
errors.add :last_name, "cannot be empty" if @last_name.blank?
|
66
|
-
errors.add :month, "is not a valid month" unless valid_month?(@month)
|
67
|
-
errors.add :year, "is not a valid year" unless valid_expiry_year?(@year)
|
68
|
-
|
69
|
-
# Bogus card is pretty much for testing purposes. Lets just skip these extra tests if its used
|
70
|
-
|
71
|
-
return if type == 'bogus'
|
72
|
-
|
73
|
-
errors.add :number, "is not a valid credit card number" unless CreditCard.valid_number?(number)
|
74
|
-
errors.add :type, "is required" if type.blank?
|
75
|
-
errors.add :type, "is invalid" unless CreditCard.card_companies.keys.include?(type)
|
76
|
-
|
77
|
-
unless errors.on(:number) || errors.on(:type)
|
78
|
-
CreditCard.type?(number) == type or
|
79
|
-
errors.add :type, "is not the correct card type"
|
80
|
-
end
|
81
|
-
|
82
|
-
if CreditCard.requires_verification_value?
|
83
|
-
errors.add :verification_value, "is required" unless verification_value?
|
84
|
-
end
|
85
|
-
|
86
|
-
if [ 'switch', 'solo' ].include?(type)
|
87
|
-
unless valid_month?(@start_month) && valid_start_year?(@start_year) || valid_issue_number?(@issue_number)
|
88
|
-
errors.add :start_month, "is invalid" unless valid_month?(@start_month)
|
89
|
-
errors.add :start_year, "is invalid" unless valid_start_year?(@start_year)
|
90
|
-
errors.add :issue_number, "cannot be empty" unless valid_issue_number?(@issue_number)
|
91
|
-
end
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
61
|
def expired?
|
96
62
|
expiry_date.expired?
|
97
63
|
end
|
98
64
|
|
99
65
|
def name?
|
100
|
-
|
66
|
+
first_name? && last_name?
|
101
67
|
end
|
102
68
|
|
103
69
|
def first_name?
|
104
|
-
|
70
|
+
!@first_name.blank?
|
105
71
|
end
|
106
72
|
|
107
73
|
def last_name?
|
108
|
-
|
74
|
+
!@last_name.blank?
|
109
75
|
end
|
110
76
|
|
111
77
|
def name
|
@@ -118,15 +84,73 @@ module ActiveMerchant #:nodoc:
|
|
118
84
|
|
119
85
|
# Show the card number, with all but last 4 numbers replace with "X". (XXXX-XXXX-XXXX-4338)
|
120
86
|
def display_number
|
121
|
-
|
87
|
+
self.class.mask(number)
|
122
88
|
end
|
123
89
|
|
124
90
|
def last_digits
|
125
|
-
|
91
|
+
self.class.last_digits(number)
|
126
92
|
end
|
93
|
+
|
94
|
+
def validate
|
95
|
+
validate_essential_attributes
|
127
96
|
|
128
|
-
|
129
|
-
|
97
|
+
# Bogus card is pretty much for testing purposes. Lets just skip these extra tests if its used
|
98
|
+
return if type == 'bogus'
|
99
|
+
|
100
|
+
validate_card_type
|
101
|
+
validate_card_number
|
102
|
+
validate_verification_value
|
103
|
+
validate_switch_or_solo_attributes
|
104
|
+
end
|
105
|
+
|
106
|
+
def self.requires_verification_value?
|
107
|
+
require_verification_value
|
108
|
+
end
|
109
|
+
|
110
|
+
private
|
111
|
+
|
112
|
+
def before_validate #:nodoc:
|
113
|
+
self.month = month.to_i
|
114
|
+
self.year = year.to_i
|
115
|
+
self.number.to_s.gsub!(/[^\d]/, "")
|
116
|
+
self.type.downcase! if type.respond_to?(:downcase)
|
117
|
+
self.type = self.class.type?(number) if type.blank?
|
118
|
+
end
|
119
|
+
|
120
|
+
def validate_card_number #:nodoc:
|
121
|
+
errors.add :number, "is not a valid credit card number" unless CreditCard.valid_number?(number)
|
122
|
+
unless errors.on(:number) || errors.on(:type)
|
123
|
+
errors.add :type, "is not the correct card type" unless CreditCard.matching_type?(number, type)
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
def validate_card_type #:nodoc:
|
128
|
+
errors.add :type, "is required" if type.blank?
|
129
|
+
errors.add :type, "is invalid" unless CreditCard.card_companies.keys.include?(type)
|
130
|
+
end
|
131
|
+
|
132
|
+
def validate_essential_attributes #:nodoc:
|
133
|
+
errors.add :first_name, "cannot be empty" if @first_name.blank?
|
134
|
+
errors.add :last_name, "cannot be empty" if @last_name.blank?
|
135
|
+
errors.add :month, "is not a valid month" unless valid_month?(@month)
|
136
|
+
errors.add :year, "expired" if expired?
|
137
|
+
errors.add :year, "is not a valid year" unless valid_expiry_year?(@year)
|
138
|
+
end
|
139
|
+
|
140
|
+
def validate_switch_or_solo_attributes #:nodoc:
|
141
|
+
if %w[switch solo].include?(type)
|
142
|
+
unless valid_month?(@start_month) && valid_start_year?(@start_year) || valid_issue_number?(@issue_number)
|
143
|
+
errors.add :start_month, "is invalid" unless valid_month?(@start_month)
|
144
|
+
errors.add :start_year, "is invalid" unless valid_start_year?(@start_year)
|
145
|
+
errors.add :issue_number, "cannot be empty" unless valid_issue_number?(@issue_number)
|
146
|
+
end
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
def validate_verification_value #:nodoc:
|
151
|
+
if CreditCard.requires_verification_value?
|
152
|
+
errors.add :verification_value, "is required" unless verification_value?
|
153
|
+
end
|
130
154
|
end
|
131
155
|
end
|
132
156
|
end
|