activemerchant-nsp 1.27.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +952 -0
- data/CONTRIBUTORS +347 -0
- data/MIT-LICENSE +20 -0
- data/README.md +204 -0
- data/gem-public_cert.pem +20 -0
- data/lib/active_merchant.rb +63 -0
- data/lib/active_merchant/billing.rb +9 -0
- data/lib/active_merchant/billing/avs_result.rb +98 -0
- data/lib/active_merchant/billing/base.rb +56 -0
- data/lib/active_merchant/billing/check.rb +68 -0
- data/lib/active_merchant/billing/credit_card.rb +274 -0
- data/lib/active_merchant/billing/credit_card_formatting.rb +21 -0
- data/lib/active_merchant/billing/credit_card_methods.rb +143 -0
- data/lib/active_merchant/billing/cvv_result.rb +38 -0
- data/lib/active_merchant/billing/expiry_date.rb +34 -0
- data/lib/active_merchant/billing/gateway.rb +176 -0
- data/lib/active_merchant/billing/gateways.rb +18 -0
- data/lib/active_merchant/billing/gateways/authorize_net.rb +695 -0
- data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +943 -0
- data/lib/active_merchant/billing/gateways/balanced.rb +462 -0
- data/lib/active_merchant/billing/gateways/barclays_epdq.rb +308 -0
- data/lib/active_merchant/billing/gateways/beanstream.rb +167 -0
- data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +389 -0
- data/lib/active_merchant/billing/gateways/beanstream_interac.rb +54 -0
- data/lib/active_merchant/billing/gateways/blue_pay.rb +492 -0
- data/lib/active_merchant/billing/gateways/bogus.rb +142 -0
- data/lib/active_merchant/billing/gateways/braintree.rb +19 -0
- data/lib/active_merchant/billing/gateways/braintree/braintree_common.rb +9 -0
- data/lib/active_merchant/billing/gateways/braintree_blue.rb +389 -0
- data/lib/active_merchant/billing/gateways/braintree_orange.rb +19 -0
- data/lib/active_merchant/billing/gateways/card_save.rb +23 -0
- data/lib/active_merchant/billing/gateways/card_stream.rb +230 -0
- data/lib/active_merchant/billing/gateways/certo_direct.rb +278 -0
- data/lib/active_merchant/billing/gateways/cyber_source.rb +576 -0
- data/lib/active_merchant/billing/gateways/data_cash.rb +597 -0
- data/lib/active_merchant/billing/gateways/efsnet.rb +235 -0
- data/lib/active_merchant/billing/gateways/elavon.rb +137 -0
- data/lib/active_merchant/billing/gateways/epay.rb +276 -0
- data/lib/active_merchant/billing/gateways/eway.rb +287 -0
- data/lib/active_merchant/billing/gateways/eway_managed.rb +265 -0
- data/lib/active_merchant/billing/gateways/exact.rb +227 -0
- data/lib/active_merchant/billing/gateways/fat_zebra.rb +152 -0
- data/lib/active_merchant/billing/gateways/federated_canada.rb +168 -0
- data/lib/active_merchant/billing/gateways/first_pay.rb +177 -0
- data/lib/active_merchant/billing/gateways/garanti.rb +262 -0
- data/lib/active_merchant/billing/gateways/ideal/ideal_base.rb +252 -0
- data/lib/active_merchant/billing/gateways/ideal/ideal_rabobank.pem +13 -0
- data/lib/active_merchant/billing/gateways/ideal/ideal_response.rb +29 -0
- data/lib/active_merchant/billing/gateways/ideal_rabobank.rb +55 -0
- data/lib/active_merchant/billing/gateways/inspire.rb +221 -0
- data/lib/active_merchant/billing/gateways/instapay.rb +164 -0
- data/lib/active_merchant/billing/gateways/iridium.rb +257 -0
- data/lib/active_merchant/billing/gateways/itransact.rb +450 -0
- data/lib/active_merchant/billing/gateways/jetpay.rb +276 -0
- data/lib/active_merchant/billing/gateways/linkpoint.rb +451 -0
- data/lib/active_merchant/billing/gateways/litle.rb +290 -0
- data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +157 -0
- data/lib/active_merchant/billing/gateways/merchant_ware.rb +289 -0
- data/lib/active_merchant/billing/gateways/metrics_global.rb +323 -0
- data/lib/active_merchant/billing/gateways/migs.rb +263 -0
- data/lib/active_merchant/billing/gateways/migs/migs_codes.rb +100 -0
- data/lib/active_merchant/billing/gateways/modern_payments.rb +38 -0
- data/lib/active_merchant/billing/gateways/modern_payments_cim.rb +220 -0
- data/lib/active_merchant/billing/gateways/moneris.rb +250 -0
- data/lib/active_merchant/billing/gateways/moneris_us.rb +211 -0
- data/lib/active_merchant/billing/gateways/nab_transact.rb +257 -0
- data/lib/active_merchant/billing/gateways/net_registry.rb +189 -0
- data/lib/active_merchant/billing/gateways/netaxept.rb +239 -0
- data/lib/active_merchant/billing/gateways/netbilling.rb +196 -0
- data/lib/active_merchant/billing/gateways/nmi.rb +13 -0
- data/lib/active_merchant/billing/gateways/ogone.rb +427 -0
- data/lib/active_merchant/billing/gateways/optimal_payment.rb +277 -0
- data/lib/active_merchant/billing/gateways/orbital.rb +351 -0
- data/lib/active_merchant/billing/gateways/orbital/orbital_soft_descriptors.rb +46 -0
- data/lib/active_merchant/billing/gateways/pay_gate_xml.rb +266 -0
- data/lib/active_merchant/billing/gateways/pay_junction.rb +397 -0
- data/lib/active_merchant/billing/gateways/pay_secure.rb +120 -0
- data/lib/active_merchant/billing/gateways/paybox_direct.rb +201 -0
- data/lib/active_merchant/billing/gateways/payflow.rb +268 -0
- data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +212 -0
- data/lib/active_merchant/billing/gateways/payflow/payflow_express_response.rb +39 -0
- data/lib/active_merchant/billing/gateways/payflow/payflow_response.rb +13 -0
- data/lib/active_merchant/billing/gateways/payflow_express.rb +224 -0
- data/lib/active_merchant/billing/gateways/payflow_express_uk.rb +15 -0
- data/lib/active_merchant/billing/gateways/payflow_uk.rb +21 -0
- data/lib/active_merchant/billing/gateways/payment_express.rb +282 -0
- data/lib/active_merchant/billing/gateways/paypal.rb +106 -0
- data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +653 -0
- data/lib/active_merchant/billing/gateways/paypal/paypal_express_response.rb +49 -0
- data/lib/active_merchant/billing/gateways/paypal/paypal_recurring_api.rb +245 -0
- data/lib/active_merchant/billing/gateways/paypal_ca.rb +13 -0
- data/lib/active_merchant/billing/gateways/paypal_digital_goods.rb +43 -0
- data/lib/active_merchant/billing/gateways/paypal_express.rb +178 -0
- data/lib/active_merchant/billing/gateways/paypal_express_common.rb +30 -0
- data/lib/active_merchant/billing/gateways/paystation.rb +201 -0
- data/lib/active_merchant/billing/gateways/payway.rb +214 -0
- data/lib/active_merchant/billing/gateways/plugnpay.rb +295 -0
- data/lib/active_merchant/billing/gateways/psigate.rb +219 -0
- data/lib/active_merchant/billing/gateways/psl_card.rb +304 -0
- data/lib/active_merchant/billing/gateways/qbms.rb +297 -0
- data/lib/active_merchant/billing/gateways/quantum.rb +282 -0
- data/lib/active_merchant/billing/gateways/quickpay.rb +298 -0
- data/lib/active_merchant/billing/gateways/realex.rb +313 -0
- data/lib/active_merchant/billing/gateways/sage.rb +148 -0
- data/lib/active_merchant/billing/gateways/sage/sage_bankcard.rb +88 -0
- data/lib/active_merchant/billing/gateways/sage/sage_core.rb +115 -0
- data/lib/active_merchant/billing/gateways/sage/sage_virtual_check.rb +97 -0
- data/lib/active_merchant/billing/gateways/sage_pay.rb +322 -0
- data/lib/active_merchant/billing/gateways/sallie_mae.rb +144 -0
- data/lib/active_merchant/billing/gateways/samurai.rb +121 -0
- data/lib/active_merchant/billing/gateways/secure_net.rb +330 -0
- data/lib/active_merchant/billing/gateways/secure_pay.rb +31 -0
- data/lib/active_merchant/billing/gateways/secure_pay_au.rb +284 -0
- data/lib/active_merchant/billing/gateways/secure_pay_tech.rb +113 -0
- data/lib/active_merchant/billing/gateways/skip_jack.rb +458 -0
- data/lib/active_merchant/billing/gateways/smart_ps.rb +273 -0
- data/lib/active_merchant/billing/gateways/stripe.rb +236 -0
- data/lib/active_merchant/billing/gateways/trans_first.rb +127 -0
- data/lib/active_merchant/billing/gateways/transax.rb +23 -0
- data/lib/active_merchant/billing/gateways/trust_commerce.rb +423 -0
- data/lib/active_merchant/billing/gateways/usa_epay.rb +25 -0
- data/lib/active_merchant/billing/gateways/usa_epay_advanced.rb +1497 -0
- data/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +206 -0
- data/lib/active_merchant/billing/gateways/verifi.rb +233 -0
- data/lib/active_merchant/billing/gateways/viaklix.rb +194 -0
- data/lib/active_merchant/billing/gateways/vindicia.rb +359 -0
- data/lib/active_merchant/billing/gateways/wirecard.rb +313 -0
- data/lib/active_merchant/billing/gateways/worldpay.rb +271 -0
- data/lib/active_merchant/billing/integrations.rb +17 -0
- data/lib/active_merchant/billing/integrations/action_view_helper.rb +73 -0
- data/lib/active_merchant/billing/integrations/authorize_net_sim.rb +38 -0
- data/lib/active_merchant/billing/integrations/authorize_net_sim/helper.rb +228 -0
- data/lib/active_merchant/billing/integrations/authorize_net_sim/notification.rb +340 -0
- data/lib/active_merchant/billing/integrations/bogus.rb +23 -0
- data/lib/active_merchant/billing/integrations/bogus/helper.rb +17 -0
- data/lib/active_merchant/billing/integrations/bogus/notification.rb +11 -0
- data/lib/active_merchant/billing/integrations/bogus/return.rb +10 -0
- data/lib/active_merchant/billing/integrations/chronopay.rb +23 -0
- data/lib/active_merchant/billing/integrations/chronopay/helper.rb +120 -0
- data/lib/active_merchant/billing/integrations/chronopay/notification.rb +158 -0
- data/lib/active_merchant/billing/integrations/chronopay/return.rb +10 -0
- data/lib/active_merchant/billing/integrations/direc_pay.rb +41 -0
- data/lib/active_merchant/billing/integrations/direc_pay/helper.rb +200 -0
- data/lib/active_merchant/billing/integrations/direc_pay/notification.rb +76 -0
- data/lib/active_merchant/billing/integrations/direc_pay/return.rb +32 -0
- data/lib/active_merchant/billing/integrations/direc_pay/status.rb +37 -0
- data/lib/active_merchant/billing/integrations/directebanking.rb +47 -0
- data/lib/active_merchant/billing/integrations/directebanking/helper.rb +90 -0
- data/lib/active_merchant/billing/integrations/directebanking/notification.rb +120 -0
- data/lib/active_merchant/billing/integrations/directebanking/return.rb +11 -0
- data/lib/active_merchant/billing/integrations/dotpay.rb +22 -0
- data/lib/active_merchant/billing/integrations/dotpay/helper.rb +77 -0
- data/lib/active_merchant/billing/integrations/dotpay/notification.rb +86 -0
- data/lib/active_merchant/billing/integrations/dotpay/return.rb +11 -0
- data/lib/active_merchant/billing/integrations/dwolla.rb +30 -0
- data/lib/active_merchant/billing/integrations/dwolla/helper.rb +31 -0
- data/lib/active_merchant/billing/integrations/dwolla/notification.rb +55 -0
- data/lib/active_merchant/billing/integrations/dwolla/return.rb +38 -0
- data/lib/active_merchant/billing/integrations/e_payment_plans.rb +48 -0
- data/lib/active_merchant/billing/integrations/e_payment_plans/helper.rb +34 -0
- data/lib/active_merchant/billing/integrations/e_payment_plans/notification.rb +84 -0
- data/lib/active_merchant/billing/integrations/easy_pay.rb +30 -0
- data/lib/active_merchant/billing/integrations/easy_pay/common.rb +40 -0
- data/lib/active_merchant/billing/integrations/easy_pay/helper.rb +40 -0
- data/lib/active_merchant/billing/integrations/easy_pay/notification.rb +51 -0
- data/lib/active_merchant/billing/integrations/epay.rb +21 -0
- data/lib/active_merchant/billing/integrations/epay/helper.rb +55 -0
- data/lib/active_merchant/billing/integrations/epay/notification.rb +110 -0
- data/lib/active_merchant/billing/integrations/first_data.rb +38 -0
- data/lib/active_merchant/billing/integrations/first_data/helper.rb +63 -0
- data/lib/active_merchant/billing/integrations/first_data/notification.rb +56 -0
- data/lib/active_merchant/billing/integrations/gestpay.rb +25 -0
- data/lib/active_merchant/billing/integrations/gestpay/common.rb +42 -0
- data/lib/active_merchant/billing/integrations/gestpay/helper.rb +70 -0
- data/lib/active_merchant/billing/integrations/gestpay/notification.rb +85 -0
- data/lib/active_merchant/billing/integrations/gestpay/return.rb +10 -0
- data/lib/active_merchant/billing/integrations/helper.rb +117 -0
- data/lib/active_merchant/billing/integrations/hi_trust.rb +27 -0
- data/lib/active_merchant/billing/integrations/hi_trust/helper.rb +58 -0
- data/lib/active_merchant/billing/integrations/hi_trust/notification.rb +59 -0
- data/lib/active_merchant/billing/integrations/hi_trust/return.rb +67 -0
- data/lib/active_merchant/billing/integrations/maksuturva.rb +86 -0
- data/lib/active_merchant/billing/integrations/maksuturva/helper.rb +119 -0
- data/lib/active_merchant/billing/integrations/maksuturva/notification.rb +48 -0
- data/lib/active_merchant/billing/integrations/moneybookers.rb +26 -0
- data/lib/active_merchant/billing/integrations/moneybookers/helper.rb +59 -0
- data/lib/active_merchant/billing/integrations/moneybookers/notification.rb +129 -0
- data/lib/active_merchant/billing/integrations/nelnet.rb +40 -0
- data/lib/active_merchant/billing/integrations/nelnet/helper.rb +34 -0
- data/lib/active_merchant/billing/integrations/nelnet/notification.rb +100 -0
- data/lib/active_merchant/billing/integrations/nochex.rb +88 -0
- data/lib/active_merchant/billing/integrations/nochex/helper.rb +68 -0
- data/lib/active_merchant/billing/integrations/nochex/notification.rb +94 -0
- data/lib/active_merchant/billing/integrations/nochex/return.rb +10 -0
- data/lib/active_merchant/billing/integrations/notification.rb +62 -0
- data/lib/active_merchant/billing/integrations/paxum.rb +44 -0
- data/lib/active_merchant/billing/integrations/paxum/common.rb +24 -0
- data/lib/active_merchant/billing/integrations/paxum/helper.rb +42 -0
- data/lib/active_merchant/billing/integrations/paxum/notification.rb +33 -0
- data/lib/active_merchant/billing/integrations/payflow_link.rb +21 -0
- data/lib/active_merchant/billing/integrations/payflow_link/helper.rb +100 -0
- data/lib/active_merchant/billing/integrations/payflow_link/notification.rb +78 -0
- data/lib/active_merchant/billing/integrations/paypal.rb +39 -0
- data/lib/active_merchant/billing/integrations/paypal/helper.rb +119 -0
- data/lib/active_merchant/billing/integrations/paypal/notification.rb +155 -0
- data/lib/active_merchant/billing/integrations/paypal/return.rb +10 -0
- data/lib/active_merchant/billing/integrations/paypal_payments_advanced.rb +20 -0
- data/lib/active_merchant/billing/integrations/paypal_payments_advanced/helper.rb +15 -0
- data/lib/active_merchant/billing/integrations/pxpay.rb +31 -0
- data/lib/active_merchant/billing/integrations/pxpay/helper.rb +110 -0
- data/lib/active_merchant/billing/integrations/pxpay/notification.rb +157 -0
- data/lib/active_merchant/billing/integrations/pxpay/return.rb +25 -0
- data/lib/active_merchant/billing/integrations/quickpay.rb +21 -0
- data/lib/active_merchant/billing/integrations/quickpay/helper.rb +71 -0
- data/lib/active_merchant/billing/integrations/quickpay/notification.rb +74 -0
- data/lib/active_merchant/billing/integrations/return.rb +42 -0
- data/lib/active_merchant/billing/integrations/robokassa.rb +49 -0
- data/lib/active_merchant/billing/integrations/robokassa/common.rb +19 -0
- data/lib/active_merchant/billing/integrations/robokassa/helper.rb +50 -0
- data/lib/active_merchant/billing/integrations/robokassa/notification.rb +55 -0
- data/lib/active_merchant/billing/integrations/robokassa/return.rb +17 -0
- data/lib/active_merchant/billing/integrations/sage_pay_form.rb +37 -0
- data/lib/active_merchant/billing/integrations/sage_pay_form/encryption.rb +33 -0
- data/lib/active_merchant/billing/integrations/sage_pay_form/helper.rb +129 -0
- data/lib/active_merchant/billing/integrations/sage_pay_form/notification.rb +210 -0
- data/lib/active_merchant/billing/integrations/sage_pay_form/return.rb +31 -0
- data/lib/active_merchant/billing/integrations/two_checkout.rb +44 -0
- data/lib/active_merchant/billing/integrations/two_checkout/helper.rb +91 -0
- data/lib/active_merchant/billing/integrations/two_checkout/notification.rb +139 -0
- data/lib/active_merchant/billing/integrations/two_checkout/return.rb +17 -0
- data/lib/active_merchant/billing/integrations/valitor.rb +33 -0
- data/lib/active_merchant/billing/integrations/valitor/helper.rb +86 -0
- data/lib/active_merchant/billing/integrations/valitor/notification.rb +13 -0
- data/lib/active_merchant/billing/integrations/valitor/response_fields.rb +97 -0
- data/lib/active_merchant/billing/integrations/valitor/return.rb +13 -0
- data/lib/active_merchant/billing/integrations/verkkomaksut.rb +20 -0
- data/lib/active_merchant/billing/integrations/verkkomaksut/helper.rb +87 -0
- data/lib/active_merchant/billing/integrations/verkkomaksut/notification.rb +59 -0
- data/lib/active_merchant/billing/integrations/web_pay.rb +45 -0
- data/lib/active_merchant/billing/integrations/web_pay/common.rb +50 -0
- data/lib/active_merchant/billing/integrations/web_pay/helper.rb +68 -0
- data/lib/active_merchant/billing/integrations/web_pay/notification.rb +51 -0
- data/lib/active_merchant/billing/integrations/world_pay.rb +27 -0
- data/lib/active_merchant/billing/integrations/world_pay/helper.rb +100 -0
- data/lib/active_merchant/billing/integrations/world_pay/notification.rb +160 -0
- data/lib/active_merchant/billing/response.rb +64 -0
- data/lib/active_merchant/version.rb +3 -0
- data/lib/activemerchant.rb +1 -0
- data/lib/support/gateway_support.rb +65 -0
- data/lib/support/outbound_hosts.rb +25 -0
- data/lib/support/ssl_verify.rb +93 -0
- metadata +482 -0
@@ -0,0 +1,322 @@
|
|
1
|
+
module ActiveMerchant #:nodoc:
|
2
|
+
module Billing #:nodoc:
|
3
|
+
class SagePayGateway < Gateway
|
4
|
+
cattr_accessor :simulate
|
5
|
+
self.simulate = false
|
6
|
+
|
7
|
+
class_attribute :simulator_url
|
8
|
+
|
9
|
+
self.test_url = 'https://test.sagepay.com/gateway/service'
|
10
|
+
self.live_url = 'https://live.sagepay.com/gateway/service'
|
11
|
+
self.simulator_url = 'https://test.sagepay.com/Simulator'
|
12
|
+
|
13
|
+
APPROVED = 'OK'
|
14
|
+
|
15
|
+
TRANSACTIONS = {
|
16
|
+
:purchase => 'PAYMENT',
|
17
|
+
:credit => 'REFUND',
|
18
|
+
:authorization => 'DEFERRED',
|
19
|
+
:capture => 'RELEASE',
|
20
|
+
:void => 'VOID',
|
21
|
+
:abort => 'ABORT'
|
22
|
+
}
|
23
|
+
|
24
|
+
CREDIT_CARDS = {
|
25
|
+
:visa => "VISA",
|
26
|
+
:master => "MC",
|
27
|
+
:delta => "DELTA",
|
28
|
+
:solo => "SOLO",
|
29
|
+
:switch => "MAESTRO",
|
30
|
+
:maestro => "MAESTRO",
|
31
|
+
:american_express => "AMEX",
|
32
|
+
:electron => "UKE",
|
33
|
+
:diners_club => "DC",
|
34
|
+
:jcb => "JCB"
|
35
|
+
}
|
36
|
+
|
37
|
+
ELECTRON = /^(424519|42496[23]|450875|48440[6-8]|4844[1-5][1-5]|4917[3-5][0-9]|491880)\d{10}(\d{3})?$/
|
38
|
+
|
39
|
+
AVS_CVV_CODE = {
|
40
|
+
"NOTPROVIDED" => nil,
|
41
|
+
"NOTCHECKED" => 'X',
|
42
|
+
"MATCHED" => 'Y',
|
43
|
+
"NOTMATCHED" => 'N'
|
44
|
+
}
|
45
|
+
|
46
|
+
self.supported_cardtypes = [:visa, :master, :american_express, :discover, :jcb, :switch, :solo, :maestro, :diners_club]
|
47
|
+
self.supported_countries = ['GB']
|
48
|
+
self.default_currency = 'GBP'
|
49
|
+
|
50
|
+
self.homepage_url = 'http://www.sagepay.com'
|
51
|
+
self.display_name = 'SagePay'
|
52
|
+
|
53
|
+
def initialize(options = {})
|
54
|
+
requires!(options, :login)
|
55
|
+
@options = options
|
56
|
+
super
|
57
|
+
end
|
58
|
+
|
59
|
+
def test?
|
60
|
+
@options[:test] || super
|
61
|
+
end
|
62
|
+
|
63
|
+
def purchase(money, credit_card, options = {})
|
64
|
+
requires!(options, :order_id)
|
65
|
+
|
66
|
+
post = {}
|
67
|
+
|
68
|
+
add_amount(post, money, options)
|
69
|
+
add_invoice(post, options)
|
70
|
+
add_credit_card(post, credit_card)
|
71
|
+
add_address(post, options)
|
72
|
+
add_customer_data(post, options)
|
73
|
+
|
74
|
+
commit(:purchase, post)
|
75
|
+
end
|
76
|
+
|
77
|
+
def authorize(money, credit_card, options = {})
|
78
|
+
requires!(options, :order_id)
|
79
|
+
|
80
|
+
post = {}
|
81
|
+
|
82
|
+
add_amount(post, money, options)
|
83
|
+
add_invoice(post, options)
|
84
|
+
add_credit_card(post, credit_card)
|
85
|
+
add_address(post, options)
|
86
|
+
add_customer_data(post, options)
|
87
|
+
|
88
|
+
commit(:authorization, post)
|
89
|
+
end
|
90
|
+
|
91
|
+
# You can only capture a transaction once, even if you didn't capture the full amount the first time.
|
92
|
+
def capture(money, identification, options = {})
|
93
|
+
post = {}
|
94
|
+
|
95
|
+
add_reference(post, identification)
|
96
|
+
add_release_amount(post, money, options)
|
97
|
+
|
98
|
+
commit(:capture, post)
|
99
|
+
end
|
100
|
+
|
101
|
+
def void(identification, options = {})
|
102
|
+
post = {}
|
103
|
+
|
104
|
+
add_reference(post, identification)
|
105
|
+
action = abort_or_void_from(identification)
|
106
|
+
|
107
|
+
commit(action, post)
|
108
|
+
end
|
109
|
+
|
110
|
+
# Refunding requires a new order_id to passed in, as well as a description
|
111
|
+
def refund(money, identification, options = {})
|
112
|
+
requires!(options, :order_id, :description)
|
113
|
+
|
114
|
+
post = {}
|
115
|
+
|
116
|
+
add_credit_reference(post, identification)
|
117
|
+
add_amount(post, money, options)
|
118
|
+
add_invoice(post, options)
|
119
|
+
|
120
|
+
commit(:credit, post)
|
121
|
+
end
|
122
|
+
|
123
|
+
def credit(money, identification, options = {})
|
124
|
+
deprecated CREDIT_DEPRECATION_MESSAGE
|
125
|
+
refund(money, identification, options)
|
126
|
+
end
|
127
|
+
|
128
|
+
private
|
129
|
+
def add_reference(post, identification)
|
130
|
+
order_id, transaction_id, authorization, security_key = identification.split(';')
|
131
|
+
|
132
|
+
add_pair(post, :VendorTxCode, order_id)
|
133
|
+
add_pair(post, :VPSTxId, transaction_id)
|
134
|
+
add_pair(post, :TxAuthNo, authorization)
|
135
|
+
add_pair(post, :SecurityKey, security_key)
|
136
|
+
end
|
137
|
+
|
138
|
+
def add_credit_reference(post, identification)
|
139
|
+
order_id, transaction_id, authorization, security_key = identification.split(';')
|
140
|
+
|
141
|
+
add_pair(post, :RelatedVendorTxCode, order_id)
|
142
|
+
add_pair(post, :RelatedVPSTxId, transaction_id)
|
143
|
+
add_pair(post, :RelatedTxAuthNo, authorization)
|
144
|
+
add_pair(post, :RelatedSecurityKey, security_key)
|
145
|
+
end
|
146
|
+
|
147
|
+
def add_amount(post, money, options)
|
148
|
+
currency = options[:currency] || currency(money)
|
149
|
+
add_pair(post, :Amount, localized_amount(money, currency), :required => true)
|
150
|
+
add_pair(post, :Currency, currency, :required => true)
|
151
|
+
end
|
152
|
+
|
153
|
+
# doesn't actually use the currency -- dodgy!
|
154
|
+
def add_release_amount(post, money, options)
|
155
|
+
add_pair(post, :ReleaseAmount, amount(money), :required => true)
|
156
|
+
end
|
157
|
+
|
158
|
+
def add_customer_data(post, options)
|
159
|
+
add_pair(post, :CustomerEMail, options[:email][0,255]) unless options[:email].blank?
|
160
|
+
add_pair(post, :BillingPhone, options[:phone].gsub(/[^0-9+]/, '')[0,20]) unless options[:phone].blank?
|
161
|
+
add_pair(post, :ClientIPAddress, options[:ip])
|
162
|
+
end
|
163
|
+
|
164
|
+
def add_address(post, options)
|
165
|
+
if billing_address = options[:billing_address] || options[:address]
|
166
|
+
first_name, last_name = parse_first_and_last_name(billing_address[:name])
|
167
|
+
add_pair(post, :BillingSurname, last_name)
|
168
|
+
add_pair(post, :BillingFirstnames, first_name)
|
169
|
+
add_pair(post, :BillingAddress1, billing_address[:address1])
|
170
|
+
add_pair(post, :BillingAddress2, billing_address[:address2])
|
171
|
+
add_pair(post, :BillingCity, billing_address[:city])
|
172
|
+
add_pair(post, :BillingState, billing_address[:state]) if billing_address[:country] == 'US'
|
173
|
+
add_pair(post, :BillingCountry, billing_address[:country])
|
174
|
+
add_pair(post, :BillingPostCode, billing_address[:zip])
|
175
|
+
end
|
176
|
+
|
177
|
+
if shipping_address = options[:shipping_address] || billing_address
|
178
|
+
first_name, last_name = parse_first_and_last_name(shipping_address[:name])
|
179
|
+
add_pair(post, :DeliverySurname, last_name)
|
180
|
+
add_pair(post, :DeliveryFirstnames, first_name)
|
181
|
+
add_pair(post, :DeliveryAddress1, shipping_address[:address1])
|
182
|
+
add_pair(post, :DeliveryAddress2, shipping_address[:address2])
|
183
|
+
add_pair(post, :DeliveryCity, shipping_address[:city])
|
184
|
+
add_pair(post, :DeliveryState, shipping_address[:state]) if shipping_address[:country] == 'US'
|
185
|
+
add_pair(post, :DeliveryCountry, shipping_address[:country])
|
186
|
+
add_pair(post, :DeliveryPostCode, shipping_address[:zip])
|
187
|
+
end
|
188
|
+
end
|
189
|
+
|
190
|
+
def add_invoice(post, options)
|
191
|
+
add_pair(post, :VendorTxCode, sanitize_order_id(options[:order_id]), :required => true)
|
192
|
+
add_pair(post, :Description, options[:description] || options[:order_id])
|
193
|
+
end
|
194
|
+
|
195
|
+
def add_credit_card(post, credit_card)
|
196
|
+
add_pair(post, :CardHolder, credit_card.name, :required => true)
|
197
|
+
add_pair(post, :CardNumber, credit_card.number, :required => true)
|
198
|
+
|
199
|
+
add_pair(post, :ExpiryDate, format_date(credit_card.month, credit_card.year), :required => true)
|
200
|
+
|
201
|
+
if requires_start_date_or_issue_number?(credit_card)
|
202
|
+
add_pair(post, :StartDate, format_date(credit_card.start_month, credit_card.start_year))
|
203
|
+
add_pair(post, :IssueNumber, credit_card.issue_number)
|
204
|
+
end
|
205
|
+
add_pair(post, :CardType, map_card_type(credit_card))
|
206
|
+
|
207
|
+
add_pair(post, :CV2, credit_card.verification_value)
|
208
|
+
end
|
209
|
+
|
210
|
+
def sanitize_order_id(order_id)
|
211
|
+
order_id.to_s.gsub(/[^-a-zA-Z0-9._]/, '')
|
212
|
+
end
|
213
|
+
|
214
|
+
def map_card_type(credit_card)
|
215
|
+
raise ArgumentError, "The credit card type must be provided" if card_brand(credit_card).blank?
|
216
|
+
|
217
|
+
card_type = card_brand(credit_card).to_sym
|
218
|
+
|
219
|
+
# Check if it is an electron card
|
220
|
+
if card_type == :visa && credit_card.number =~ ELECTRON
|
221
|
+
CREDIT_CARDS[:electron]
|
222
|
+
else
|
223
|
+
CREDIT_CARDS[card_type]
|
224
|
+
end
|
225
|
+
end
|
226
|
+
|
227
|
+
# MMYY format
|
228
|
+
def format_date(month, year)
|
229
|
+
return nil if year.blank? || month.blank?
|
230
|
+
|
231
|
+
year = sprintf("%.4i", year)
|
232
|
+
month = sprintf("%.2i", month)
|
233
|
+
|
234
|
+
"#{month}#{year[-2..-1]}"
|
235
|
+
end
|
236
|
+
|
237
|
+
def commit(action, parameters)
|
238
|
+
response = parse( ssl_post(url_for(action), post_data(action, parameters)) )
|
239
|
+
|
240
|
+
Response.new(response["Status"] == APPROVED, message_from(response), response,
|
241
|
+
:test => test?,
|
242
|
+
:authorization => authorization_from(response, parameters, action),
|
243
|
+
:avs_result => {
|
244
|
+
:street_match => AVS_CVV_CODE[ response["AddressResult"] ],
|
245
|
+
:postal_match => AVS_CVV_CODE[ response["PostCodeResult"] ],
|
246
|
+
},
|
247
|
+
:cvv_result => AVS_CVV_CODE[ response["CV2Result"] ]
|
248
|
+
)
|
249
|
+
end
|
250
|
+
|
251
|
+
def authorization_from(response, params, action)
|
252
|
+
[ params[:VendorTxCode],
|
253
|
+
response["VPSTxId"],
|
254
|
+
response["TxAuthNo"],
|
255
|
+
response["SecurityKey"],
|
256
|
+
action ].join(";")
|
257
|
+
end
|
258
|
+
|
259
|
+
def abort_or_void_from(identification)
|
260
|
+
original_transaction = identification.split(';').last
|
261
|
+
original_transaction == 'authorization' ? :abort : :void
|
262
|
+
end
|
263
|
+
|
264
|
+
def url_for(action)
|
265
|
+
simulate ? build_simulator_url(action) : build_url(action)
|
266
|
+
end
|
267
|
+
|
268
|
+
def build_url(action)
|
269
|
+
endpoint = [ :purchase, :authorization ].include?(action) ? "vspdirect-register" : TRANSACTIONS[action].downcase
|
270
|
+
"#{test? ? self.test_url : self.live_url}/#{endpoint}.vsp"
|
271
|
+
end
|
272
|
+
|
273
|
+
def build_simulator_url(action)
|
274
|
+
endpoint = [ :purchase, :authorization ].include?(action) ? "VSPDirectGateway.asp" : "VSPServerGateway.asp?Service=Vendor#{TRANSACTIONS[action].capitalize}Tx"
|
275
|
+
"#{self.simulator_url}/#{endpoint}"
|
276
|
+
end
|
277
|
+
|
278
|
+
def message_from(response)
|
279
|
+
response['Status'] == APPROVED ? 'Success' : (response['StatusDetail'] || 'Unspecified error') # simonr 20080207 can't actually get non-nil blanks, so this is shorter
|
280
|
+
end
|
281
|
+
|
282
|
+
def post_data(action, parameters = {})
|
283
|
+
parameters.update(
|
284
|
+
:Vendor => @options[:login],
|
285
|
+
:TxType => TRANSACTIONS[action],
|
286
|
+
:VPSProtocol => "2.23"
|
287
|
+
)
|
288
|
+
|
289
|
+
parameters.collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join("&")
|
290
|
+
end
|
291
|
+
|
292
|
+
# SagePay returns data in the following format
|
293
|
+
# Key1=value1
|
294
|
+
# Key2=value2
|
295
|
+
def parse(body)
|
296
|
+
result = {}
|
297
|
+
body.to_s.each_line do |pair|
|
298
|
+
result[$1] = $2 if pair.strip =~ /\A([^=]+)=(.+)\Z/im
|
299
|
+
end
|
300
|
+
result
|
301
|
+
end
|
302
|
+
|
303
|
+
def add_pair(post, key, value, options = {})
|
304
|
+
post[key] = value if !value.blank? || options[:required]
|
305
|
+
end
|
306
|
+
|
307
|
+
def parse_first_and_last_name(value)
|
308
|
+
name = value.to_s.split(' ')
|
309
|
+
|
310
|
+
last_name = name.pop || ''
|
311
|
+
first_name = name.join(' ')
|
312
|
+
[ first_name[0,20], last_name[0,20] ]
|
313
|
+
end
|
314
|
+
|
315
|
+
def localized_amount(money, currency)
|
316
|
+
amount = amount(money)
|
317
|
+
CURRENCIES_WITHOUT_FRACTIONS.include?(currency.to_s) ? amount.split('.').first : amount
|
318
|
+
end
|
319
|
+
end
|
320
|
+
end
|
321
|
+
end
|
322
|
+
|
@@ -0,0 +1,144 @@
|
|
1
|
+
module ActiveMerchant #:nodoc:
|
2
|
+
module Billing #:nodoc:
|
3
|
+
class SallieMaeGateway < Gateway
|
4
|
+
self.live_url = self.test_url = 'https://trans.salliemae.com/cgi-bin/process.cgi'
|
5
|
+
|
6
|
+
# The countries the gateway supports merchants from as 2 digit ISO country codes
|
7
|
+
self.supported_countries = ['US']
|
8
|
+
|
9
|
+
# The card types supported by the payment gateway
|
10
|
+
self.supported_cardtypes = [:visa, :master, :american_express, :discover]
|
11
|
+
|
12
|
+
# The homepage URL of the gateway
|
13
|
+
self.homepage_url = 'http://www.salliemae.com/'
|
14
|
+
|
15
|
+
# The name of the gateway
|
16
|
+
self.display_name = 'Sallie Mae'
|
17
|
+
|
18
|
+
def initialize(options = {})
|
19
|
+
requires!(options, :login)
|
20
|
+
@options = options
|
21
|
+
super
|
22
|
+
end
|
23
|
+
|
24
|
+
def test?
|
25
|
+
@options[:login] == "TEST0"
|
26
|
+
end
|
27
|
+
|
28
|
+
def authorize(money, creditcard, options = {})
|
29
|
+
post = PostData.new
|
30
|
+
add_invoice(post, options)
|
31
|
+
add_creditcard(post, creditcard)
|
32
|
+
add_address(post, creditcard, options)
|
33
|
+
add_customer_data(post, options)
|
34
|
+
|
35
|
+
commit(:authonly, money, post)
|
36
|
+
end
|
37
|
+
|
38
|
+
def purchase(money, creditcard, options = {})
|
39
|
+
post = PostData.new
|
40
|
+
add_invoice(post, options)
|
41
|
+
add_creditcard(post, creditcard)
|
42
|
+
add_address(post, creditcard, options)
|
43
|
+
add_customer_data(post, options)
|
44
|
+
|
45
|
+
commit(:sale, money, post)
|
46
|
+
end
|
47
|
+
|
48
|
+
def capture(money, authorization, options = {})
|
49
|
+
post = PostData.new
|
50
|
+
post[:postonly] = authorization
|
51
|
+
commit(:capture, money, post)
|
52
|
+
end
|
53
|
+
|
54
|
+
private
|
55
|
+
|
56
|
+
def add_customer_data(post, options)
|
57
|
+
if address = options[:billing_address] || options[:shipping_address] || options[:address]
|
58
|
+
post[:ci_phone] = address[:phone].to_s
|
59
|
+
end
|
60
|
+
|
61
|
+
post[:ci_email] = options[:email].to_s unless options[:email].blank?
|
62
|
+
post[:ci_IP] = options[:ip].to_s unless options[:ip].blank?
|
63
|
+
end
|
64
|
+
|
65
|
+
def add_address(post, creditcard, options)
|
66
|
+
if address = options[:billing_address] || options[:address]
|
67
|
+
post[:ci_billaddr1] = address[:address1].to_s
|
68
|
+
post[:ci_billaddr2] = address[:address2].to_s unless address[:address2].blank?
|
69
|
+
post[:ci_billcity] = address[:city].to_s
|
70
|
+
post[:ci_billstate] = address[:state].to_s
|
71
|
+
post[:ci_billzip] = address[:zip].to_s
|
72
|
+
end
|
73
|
+
|
74
|
+
if shipping_address = options[:shipping_address] || options[:address]
|
75
|
+
post[:ci_shipaddr1] = shipping_address[:address1].to_s
|
76
|
+
post[:ci_shipaddr2] = shipping_address[:address2].to_s unless shipping_address[:address2].blank?
|
77
|
+
post[:ci_shipcity] = shipping_address[:city].to_s
|
78
|
+
post[:ci_shipstate] = shipping_address[:state].to_s
|
79
|
+
post[:ci_shipzip] = shipping_address[:zip].to_s
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
def add_invoice(post, options)
|
84
|
+
memo = "OrderID: #{options[:order_id]}\nDescription: #{options[:description]}"
|
85
|
+
post[:ci_memo] = memo
|
86
|
+
end
|
87
|
+
|
88
|
+
def add_creditcard(post, creditcard)
|
89
|
+
post[:ccnum] = creditcard.number.to_s
|
90
|
+
post[:ccname] = creditcard.name.to_s
|
91
|
+
post[:cvv2] = creditcard.verification_value.to_s if creditcard.verification_value?
|
92
|
+
post[:expmon] = creditcard.month.to_s
|
93
|
+
post[:expyear] = creditcard.year.to_s
|
94
|
+
end
|
95
|
+
|
96
|
+
def parse(body)
|
97
|
+
h = {}
|
98
|
+
body.gsub!("<html><body><plaintext>", "")
|
99
|
+
body.
|
100
|
+
split("\r\n").
|
101
|
+
map do |i|
|
102
|
+
a = i.split("=")
|
103
|
+
h[a.first] = a.last unless a.first.nil?
|
104
|
+
end
|
105
|
+
h
|
106
|
+
end
|
107
|
+
|
108
|
+
def commit(action, money, parameters)
|
109
|
+
parameters[:acctid] = @options[:login].to_s
|
110
|
+
parameters[:subid] = @options[:sub_id].to_s unless @options[:sub_id].blank?
|
111
|
+
parameters[:amount] = amount(money)
|
112
|
+
|
113
|
+
case action
|
114
|
+
when :sale
|
115
|
+
parameters[:action] = "ns_quicksale_cc"
|
116
|
+
when :authonly
|
117
|
+
parameters[:action] = "ns_quicksale_cc"
|
118
|
+
parameters[:authonly] = 1
|
119
|
+
when :capture
|
120
|
+
parameters[:action] = "ns_quicksale_cc"
|
121
|
+
end
|
122
|
+
|
123
|
+
response = parse(ssl_post(self.live_url, parameters.to_post_data) || "")
|
124
|
+
Response.new(successful?(response), message_from(response), response,
|
125
|
+
:test => test?,
|
126
|
+
:authorization => response["refcode"]
|
127
|
+
)
|
128
|
+
end
|
129
|
+
|
130
|
+
def successful?(response)
|
131
|
+
response["Status"] == "Accepted"
|
132
|
+
end
|
133
|
+
|
134
|
+
def message_from(response)
|
135
|
+
if successful?(response)
|
136
|
+
"Accepted"
|
137
|
+
else
|
138
|
+
response["Reason"].split(":")[2].capitalize unless response["Reason"].nil?
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|