tanga_activemerchant 1.37.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG +1202 -0
- data/CONTRIBUTORS +414 -0
- data/MIT-LICENSE +20 -0
- data/README.md +221 -0
- data/gem-public_cert.pem +20 -0
- data/lib/active_merchant/billing/avs_result.rb +98 -0
- data/lib/active_merchant/billing/base.rb +57 -0
- data/lib/active_merchant/billing/check.rb +69 -0
- data/lib/active_merchant/billing/credit_card.rb +283 -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 +181 -0
- data/lib/active_merchant/billing/gateways/authorize_net.rb +725 -0
- data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +956 -0
- data/lib/active_merchant/billing/gateways/balanced.rb +468 -0
- data/lib/active_merchant/billing/gateways/banwire.rb +105 -0
- data/lib/active_merchant/billing/gateways/barclays_epdq.rb +314 -0
- data/lib/active_merchant/billing/gateways/barclays_epdq_extra_plus.rb +15 -0
- data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +393 -0
- data/lib/active_merchant/billing/gateways/beanstream.rb +169 -0
- data/lib/active_merchant/billing/gateways/beanstream_interac.rb +54 -0
- data/lib/active_merchant/billing/gateways/blue_pay.rb +501 -0
- data/lib/active_merchant/billing/gateways/bogus.rb +142 -0
- data/lib/active_merchant/billing/gateways/braintree/braintree_common.rb +9 -0
- data/lib/active_merchant/billing/gateways/braintree.rb +19 -0
- data/lib/active_merchant/billing/gateways/braintree_blue.rb +401 -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 +225 -0
- data/lib/active_merchant/billing/gateways/card_stream_modern.rb +155 -0
- data/lib/active_merchant/billing/gateways/cc5.rb +156 -0
- data/lib/active_merchant/billing/gateways/certo_direct.rb +277 -0
- data/lib/active_merchant/billing/gateways/cyber_source.rb +639 -0
- data/lib/active_merchant/billing/gateways/data_cash.rb +591 -0
- data/lib/active_merchant/billing/gateways/efsnet.rb +230 -0
- data/lib/active_merchant/billing/gateways/elavon.rb +312 -0
- data/lib/active_merchant/billing/gateways/epay.rb +275 -0
- data/lib/active_merchant/billing/gateways/evo_ca.rb +308 -0
- data/lib/active_merchant/billing/gateways/eway.rb +225 -0
- data/lib/active_merchant/billing/gateways/eway_managed.rb +291 -0
- data/lib/active_merchant/billing/gateways/eway_rapid.rb +320 -0
- data/lib/active_merchant/billing/gateways/exact.rb +218 -0
- data/lib/active_merchant/billing/gateways/fat_zebra.rb +173 -0
- data/lib/active_merchant/billing/gateways/federated_canada.rb +167 -0
- data/lib/active_merchant/billing/gateways/finansbank.rb +22 -0
- data/lib/active_merchant/billing/gateways/first_pay.rb +176 -0
- data/lib/active_merchant/billing/gateways/firstdata_e4.rb +314 -0
- data/lib/active_merchant/billing/gateways/garanti.rb +257 -0
- data/lib/active_merchant/billing/gateways/hdfc.rb +207 -0
- data/lib/active_merchant/billing/gateways/iats_payments.rb +35 -0
- data/lib/active_merchant/billing/gateways/ideal/ideal_base.rb +249 -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 +66 -0
- data/lib/active_merchant/billing/gateways/inspire.rb +221 -0
- data/lib/active_merchant/billing/gateways/instapay.rb +163 -0
- data/lib/active_merchant/billing/gateways/iridium.rb +262 -0
- data/lib/active_merchant/billing/gateways/itransact.rb +448 -0
- data/lib/active_merchant/billing/gateways/jetpay.rb +275 -0
- data/lib/active_merchant/billing/gateways/linkpoint.rb +447 -0
- data/lib/active_merchant/billing/gateways/litle.rb +554 -0
- data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +176 -0
- data/lib/active_merchant/billing/gateways/merchant_one.rb +115 -0
- data/lib/active_merchant/billing/gateways/merchant_ware.rb +322 -0
- data/lib/active_merchant/billing/gateways/merchant_ware_version_four.rb +275 -0
- data/lib/active_merchant/billing/gateways/merchant_warrior.rb +191 -0
- data/lib/active_merchant/billing/gateways/mercury.rb +311 -0
- data/lib/active_merchant/billing/gateways/metrics_global.rb +322 -0
- data/lib/active_merchant/billing/gateways/migs/migs_codes.rb +100 -0
- data/lib/active_merchant/billing/gateways/migs.rb +265 -0
- data/lib/active_merchant/billing/gateways/modern_payments.rb +37 -0
- data/lib/active_merchant/billing/gateways/modern_payments_cim.rb +219 -0
- data/lib/active_merchant/billing/gateways/moneris.rb +244 -0
- data/lib/active_merchant/billing/gateways/moneris_us.rb +208 -0
- data/lib/active_merchant/billing/gateways/nab_transact.rb +277 -0
- data/lib/active_merchant/billing/gateways/net_registry.rb +193 -0
- data/lib/active_merchant/billing/gateways/netaxept.rb +181 -0
- data/lib/active_merchant/billing/gateways/netbilling.rb +197 -0
- data/lib/active_merchant/billing/gateways/netpay.rb +223 -0
- data/lib/active_merchant/billing/gateways/nmi.rb +20 -0
- data/lib/active_merchant/billing/gateways/ogone.rb +421 -0
- data/lib/active_merchant/billing/gateways/optimal_payment.rb +297 -0
- data/lib/active_merchant/billing/gateways/orbital/avs_result.rb +93 -0
- data/lib/active_merchant/billing/gateways/orbital/orbital_soft_descriptors.rb +46 -0
- data/lib/active_merchant/billing/gateways/orbital.rb +633 -0
- data/lib/active_merchant/billing/gateways/pay_gate_xml.rb +261 -0
- data/lib/active_merchant/billing/gateways/pay_junction.rb +396 -0
- data/lib/active_merchant/billing/gateways/pay_secure.rb +119 -0
- data/lib/active_merchant/billing/gateways/paybox_direct.rb +196 -0
- data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +209 -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.rb +268 -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 +353 -0
- data/lib/active_merchant/billing/gateways/paymill.rb +179 -0
- data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +670 -0
- data/lib/active_merchant/billing/gateways/paypal/paypal_express_response.rb +61 -0
- data/lib/active_merchant/billing/gateways/paypal/paypal_recurring_api.rb +248 -0
- data/lib/active_merchant/billing/gateways/paypal.rb +106 -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 +239 -0
- data/lib/active_merchant/billing/gateways/paypal_express_common.rb +30 -0
- data/lib/active_merchant/billing/gateways/paystation.rb +199 -0
- data/lib/active_merchant/billing/gateways/payway.rb +207 -0
- data/lib/active_merchant/billing/gateways/pin.rb +165 -0
- data/lib/active_merchant/billing/gateways/plugnpay.rb +294 -0
- data/lib/active_merchant/billing/gateways/psigate.rb +227 -0
- data/lib/active_merchant/billing/gateways/psl_card.rb +303 -0
- data/lib/active_merchant/billing/gateways/qbms.rb +292 -0
- data/lib/active_merchant/billing/gateways/quantum.rb +276 -0
- data/lib/active_merchant/billing/gateways/quickpay.rb +335 -0
- data/lib/active_merchant/billing/gateways/realex.rb +303 -0
- data/lib/active_merchant/billing/gateways/redsys.rb +394 -0
- data/lib/active_merchant/billing/gateways/sage/sage_bankcard.rb +93 -0
- data/lib/active_merchant/billing/gateways/sage/sage_core.rb +114 -0
- data/lib/active_merchant/billing/gateways/sage/sage_virtual_check.rb +102 -0
- data/lib/active_merchant/billing/gateways/sage.rb +152 -0
- data/lib/active_merchant/billing/gateways/sage_pay.rb +324 -0
- data/lib/active_merchant/billing/gateways/sallie_mae.rb +143 -0
- data/lib/active_merchant/billing/gateways/samurai.rb +118 -0
- data/lib/active_merchant/billing/gateways/secure_net.rb +261 -0
- data/lib/active_merchant/billing/gateways/secure_pay.rb +28 -0
- data/lib/active_merchant/billing/gateways/secure_pay_au.rb +279 -0
- data/lib/active_merchant/billing/gateways/secure_pay_tech.rb +112 -0
- data/lib/active_merchant/billing/gateways/skip_jack.rb +453 -0
- data/lib/active_merchant/billing/gateways/smart_ps.rb +272 -0
- data/lib/active_merchant/billing/gateways/spreedly_core.rb +233 -0
- data/lib/active_merchant/billing/gateways/stripe.rb +316 -0
- data/lib/active_merchant/billing/gateways/trans_first.rb +126 -0
- data/lib/active_merchant/billing/gateways/transax.rb +23 -0
- data/lib/active_merchant/billing/gateways/transnational.rb +239 -0
- data/lib/active_merchant/billing/gateways/trust_commerce.rb +421 -0
- data/lib/active_merchant/billing/gateways/usa_epay.rb +25 -0
- data/lib/active_merchant/billing/gateways/usa_epay_advanced.rb +1501 -0
- data/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +201 -0
- data/lib/active_merchant/billing/gateways/verifi.rb +232 -0
- data/lib/active_merchant/billing/gateways/viaklix.rb +189 -0
- data/lib/active_merchant/billing/gateways/vindicia.rb +361 -0
- data/lib/active_merchant/billing/gateways/webpay.rb +57 -0
- data/lib/active_merchant/billing/gateways/wirecard.rb +313 -0
- data/lib/active_merchant/billing/gateways/worldpay.rb +303 -0
- data/lib/active_merchant/billing/gateways.rb +17 -0
- data/lib/active_merchant/billing/integrations/a1agregator/helper.rb +31 -0
- data/lib/active_merchant/billing/integrations/a1agregator/notification.rb +186 -0
- data/lib/active_merchant/billing/integrations/a1agregator/status.rb +38 -0
- data/lib/active_merchant/billing/integrations/a1agregator.rb +26 -0
- data/lib/active_merchant/billing/integrations/action_view_helper.rb +73 -0
- data/lib/active_merchant/billing/integrations/authorize_net_sim/helper.rb +229 -0
- data/lib/active_merchant/billing/integrations/authorize_net_sim/notification.rb +340 -0
- data/lib/active_merchant/billing/integrations/authorize_net_sim.rb +38 -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/bogus.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/chronopay.rb +23 -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/direc_pay.rb +41 -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/directebanking.rb +47 -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/dotpay.rb +22 -0
- data/lib/active_merchant/billing/integrations/dwolla/common.rb +23 -0
- data/lib/active_merchant/billing/integrations/dwolla/helper.rb +43 -0
- data/lib/active_merchant/billing/integrations/dwolla/notification.rb +64 -0
- data/lib/active_merchant/billing/integrations/dwolla/return.rb +49 -0
- data/lib/active_merchant/billing/integrations/dwolla.rb +23 -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/e_payment_plans.rb +48 -0
- data/lib/active_merchant/billing/integrations/easy_pay/common.rb +40 -0
- data/lib/active_merchant/billing/integrations/easy_pay/helper.rb +36 -0
- data/lib/active_merchant/billing/integrations/easy_pay/notification.rb +59 -0
- data/lib/active_merchant/billing/integrations/easy_pay.rb +30 -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/epay.rb +21 -0
- data/lib/active_merchant/billing/integrations/first_data/helper.rb +61 -0
- data/lib/active_merchant/billing/integrations/first_data/notification.rb +56 -0
- data/lib/active_merchant/billing/integrations/first_data.rb +38 -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/gestpay.rb +25 -0
- data/lib/active_merchant/billing/integrations/helper.rb +117 -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/hi_trust.rb +27 -0
- data/lib/active_merchant/billing/integrations/ipay88/helper.rb +114 -0
- data/lib/active_merchant/billing/integrations/ipay88/return.rb +95 -0
- data/lib/active_merchant/billing/integrations/ipay88.rb +19 -0
- data/lib/active_merchant/billing/integrations/liqpay/helper.rb +43 -0
- data/lib/active_merchant/billing/integrations/liqpay/notification.rb +89 -0
- data/lib/active_merchant/billing/integrations/liqpay/return.rb +83 -0
- data/lib/active_merchant/billing/integrations/liqpay.rb +30 -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/maksuturva.rb +86 -0
- data/lib/active_merchant/billing/integrations/moneybookers/helper.rb +75 -0
- data/lib/active_merchant/billing/integrations/moneybookers/notification.rb +129 -0
- data/lib/active_merchant/billing/integrations/moneybookers.rb +26 -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/nochex.rb +88 -0
- data/lib/active_merchant/billing/integrations/notification.rb +71 -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/paxum.rb +44 -0
- data/lib/active_merchant/billing/integrations/pay_fast/common.rb +42 -0
- data/lib/active_merchant/billing/integrations/pay_fast/helper.rb +50 -0
- data/lib/active_merchant/billing/integrations/pay_fast/notification.rb +134 -0
- data/lib/active_merchant/billing/integrations/pay_fast/return.rb +10 -0
- data/lib/active_merchant/billing/integrations/pay_fast.rb +70 -0
- data/lib/active_merchant/billing/integrations/payflow_link/helper.rb +116 -0
- data/lib/active_merchant/billing/integrations/payflow_link/notification.rb +78 -0
- data/lib/active_merchant/billing/integrations/payflow_link.rb +21 -0
- data/lib/active_merchant/billing/integrations/paypal/helper.rb +119 -0
- data/lib/active_merchant/billing/integrations/paypal/notification.rb +227 -0
- data/lib/active_merchant/billing/integrations/paypal/return.rb +10 -0
- data/lib/active_merchant/billing/integrations/paypal.rb +39 -0
- data/lib/active_merchant/billing/integrations/paypal_payments_advanced/helper.rb +15 -0
- data/lib/active_merchant/billing/integrations/paypal_payments_advanced.rb +20 -0
- data/lib/active_merchant/billing/integrations/paysbuy/helper.rb +15 -0
- data/lib/active_merchant/billing/integrations/paysbuy/notification.rb +28 -0
- data/lib/active_merchant/billing/integrations/paysbuy.rb +36 -0
- data/lib/active_merchant/billing/integrations/payu_in/helper.rb +74 -0
- data/lib/active_merchant/billing/integrations/payu_in/notification.rb +165 -0
- data/lib/active_merchant/billing/integrations/payu_in/return.rb +36 -0
- data/lib/active_merchant/billing/integrations/payu_in.rb +43 -0
- data/lib/active_merchant/billing/integrations/platron/helper.rb +32 -0
- data/lib/active_merchant/billing/integrations/platron/notification.rb +113 -0
- data/lib/active_merchant/billing/integrations/platron.rb +28 -0
- data/lib/active_merchant/billing/integrations/pxpay/helper.rb +112 -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/pxpay.rb +31 -0
- data/lib/active_merchant/billing/integrations/quickpay/helper.rb +74 -0
- data/lib/active_merchant/billing/integrations/quickpay/notification.rb +137 -0
- data/lib/active_merchant/billing/integrations/quickpay.rb +21 -0
- data/lib/active_merchant/billing/integrations/rbkmoney/helper.rb +23 -0
- data/lib/active_merchant/billing/integrations/rbkmoney/notification.rb +91 -0
- data/lib/active_merchant/billing/integrations/rbkmoney.rb +17 -0
- data/lib/active_merchant/billing/integrations/return.rb +42 -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/robokassa.rb +49 -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 +136 -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/sage_pay_form.rb +37 -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/two_checkout.rb +44 -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/valitor.rb +33 -0
- data/lib/active_merchant/billing/integrations/verkkomaksut/helper.rb +88 -0
- data/lib/active_merchant/billing/integrations/verkkomaksut/notification.rb +59 -0
- data/lib/active_merchant/billing/integrations/verkkomaksut.rb +20 -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/web_pay.rb +45 -0
- data/lib/active_merchant/billing/integrations/webmoney/common.rb +17 -0
- data/lib/active_merchant/billing/integrations/webmoney/helper.rb +40 -0
- data/lib/active_merchant/billing/integrations/webmoney/notification.rb +47 -0
- data/lib/active_merchant/billing/integrations/webmoney.rb +43 -0
- data/lib/active_merchant/billing/integrations/world_pay/helper.rb +101 -0
- data/lib/active_merchant/billing/integrations/world_pay/notification.rb +160 -0
- data/lib/active_merchant/billing/integrations/world_pay.rb +34 -0
- data/lib/active_merchant/billing/integrations.rb +17 -0
- data/lib/active_merchant/billing/response.rb +77 -0
- data/lib/active_merchant/billing.rb +9 -0
- data/lib/active_merchant/version.rb +3 -0
- data/lib/active_merchant.rb +63 -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 +506 -0
@@ -0,0 +1,401 @@
|
|
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
|
+
# For more information on the Braintree Gateway please visit their
|
14
|
+
# {Developer Portal}[https://www.braintreepayments.com/developers]
|
15
|
+
#
|
16
|
+
# ==== About this implementation
|
17
|
+
#
|
18
|
+
# This implementation leverages the Braintree-authored ruby gem:
|
19
|
+
# https://github.com/braintree/braintree_ruby
|
20
|
+
#
|
21
|
+
# ==== Debugging Information
|
22
|
+
#
|
23
|
+
# Setting an ActiveMerchant +wiredump_device+ will automatically
|
24
|
+
# configure the Braintree logger (via the Braintree gem's
|
25
|
+
# configuration) when the BraintreeBlueGateway is instantiated.
|
26
|
+
# Additionally, the log level will be set to +DEBUG+. Therefore,
|
27
|
+
# all you have to do is set the +wiredump_device+ and you'll
|
28
|
+
# get your debug output from your HTTP interactions with the
|
29
|
+
# remote gateway. (Don't enable this in production.)
|
30
|
+
#
|
31
|
+
# For example:
|
32
|
+
#
|
33
|
+
# ActiveMerchant::Billing::BraintreeBlueGateway.wiredump_device = Logger.new(STDOUT)
|
34
|
+
# # => #<Logger:0x107d385f8 ...>
|
35
|
+
#
|
36
|
+
# Braintree::Configuration.logger
|
37
|
+
# # => (some other logger, created by default by the gem)
|
38
|
+
#
|
39
|
+
# Braintree::Configuration.logger.level
|
40
|
+
# # => 1 (INFO)
|
41
|
+
#
|
42
|
+
# ActiveMerchant::Billing::BraintreeBlueGateway.new(:merchant_id => 'x', :public_key => 'x', :private_key => 'x')
|
43
|
+
#
|
44
|
+
# Braintree::Configuration.logger
|
45
|
+
# # => #<Logger:0x107d385f8 ...>
|
46
|
+
#
|
47
|
+
# Braintree::Configuration.logger.level
|
48
|
+
# # => 0 (DEBUG)
|
49
|
+
#
|
50
|
+
# Alternatively, you can avoid setting the +wiredump_device+
|
51
|
+
# and set +Braintree::Configuration.logger+ and/or
|
52
|
+
# +Braintree::Configuration.logger.level+ directly.
|
53
|
+
class BraintreeBlueGateway < Gateway
|
54
|
+
include BraintreeCommon
|
55
|
+
|
56
|
+
self.display_name = 'Braintree (Blue Platform)'
|
57
|
+
|
58
|
+
def initialize(options = {})
|
59
|
+
requires!(options, :merchant_id, :public_key, :private_key)
|
60
|
+
@merchant_account_id = options[:merchant_account_id]
|
61
|
+
|
62
|
+
super
|
63
|
+
|
64
|
+
Braintree::Configuration.merchant_id = options[:merchant_id]
|
65
|
+
Braintree::Configuration.public_key = options[:public_key]
|
66
|
+
Braintree::Configuration.private_key = options[:private_key]
|
67
|
+
Braintree::Configuration.environment = (options[:environment] || (test? ? :sandbox : :production)).to_sym
|
68
|
+
Braintree::Configuration.custom_user_agent = "ActiveMerchant #{ActiveMerchant::VERSION}"
|
69
|
+
|
70
|
+
if wiredump_device
|
71
|
+
Braintree::Configuration.logger = ((Logger === wiredump_device) ? wiredump_device : Logger.new(wiredump_device))
|
72
|
+
Braintree::Configuration.logger.level = Logger::DEBUG
|
73
|
+
else
|
74
|
+
Braintree::Configuration.logger.level = Logger::WARN
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
def authorize(money, credit_card_or_vault_id, options = {})
|
79
|
+
create_transaction(:sale, money, credit_card_or_vault_id, options)
|
80
|
+
end
|
81
|
+
|
82
|
+
def capture(money, authorization, options = {})
|
83
|
+
commit do
|
84
|
+
result = Braintree::Transaction.submit_for_settlement(authorization, amount(money).to_s)
|
85
|
+
Response.new(result.success?, message_from_result(result))
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
def purchase(money, credit_card_or_vault_id, options = {})
|
90
|
+
authorize(money, credit_card_or_vault_id, options.merge(:submit_for_settlement => true))
|
91
|
+
end
|
92
|
+
|
93
|
+
def credit(money, credit_card_or_vault_id, options = {})
|
94
|
+
create_transaction(:credit, money, credit_card_or_vault_id, options)
|
95
|
+
end
|
96
|
+
|
97
|
+
def refund(*args)
|
98
|
+
# legacy signature: #refund(transaction_id, options = {})
|
99
|
+
# new signature: #refund(money, transaction_id, options = {})
|
100
|
+
money, transaction_id, _ = extract_refund_args(args)
|
101
|
+
money = amount(money).to_s if money
|
102
|
+
|
103
|
+
commit do
|
104
|
+
result = Braintree::Transaction.refund(transaction_id, money)
|
105
|
+
Response.new(result.success?, message_from_result(result),
|
106
|
+
{:braintree_transaction => (transaction_hash(result.transaction) if result.success?)},
|
107
|
+
{:authorization => (result.transaction.id if result.success?)}
|
108
|
+
)
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
def void(authorization, options = {})
|
113
|
+
commit do
|
114
|
+
result = Braintree::Transaction.void(authorization)
|
115
|
+
Response.new(result.success?, message_from_result(result),
|
116
|
+
{:braintree_transaction => (transaction_hash(result.transaction) if result.success?)},
|
117
|
+
{:authorization => (result.transaction.id if result.success?)}
|
118
|
+
)
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
def store(creditcard, options = {})
|
123
|
+
commit do
|
124
|
+
parameters = {
|
125
|
+
:first_name => creditcard.first_name,
|
126
|
+
:last_name => creditcard.last_name,
|
127
|
+
:email => options[:email],
|
128
|
+
:credit_card => {
|
129
|
+
:number => creditcard.number,
|
130
|
+
:cvv => creditcard.verification_value,
|
131
|
+
:expiration_month => creditcard.month.to_s.rjust(2, "0"),
|
132
|
+
:expiration_year => creditcard.year.to_s
|
133
|
+
}
|
134
|
+
}
|
135
|
+
result = Braintree::Customer.create(merge_credit_card_options(parameters, options))
|
136
|
+
Response.new(result.success?, message_from_result(result),
|
137
|
+
{
|
138
|
+
:braintree_customer => (customer_hash(result.customer) if result.success?),
|
139
|
+
:customer_vault_id => (result.customer.id if result.success?)
|
140
|
+
},
|
141
|
+
:authorization => (result.customer.id if result.success?)
|
142
|
+
)
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
def update(vault_id, creditcard, options = {})
|
147
|
+
braintree_credit_card = nil
|
148
|
+
commit do
|
149
|
+
braintree_credit_card = Braintree::Customer.find(vault_id).credit_cards.detect { |cc| cc.default? }
|
150
|
+
return Response.new(false, 'Braintree::NotFoundError') if braintree_credit_card.nil?
|
151
|
+
|
152
|
+
options.merge!(:update_existing_token => braintree_credit_card.token)
|
153
|
+
credit_card_params = merge_credit_card_options({
|
154
|
+
:credit_card => {
|
155
|
+
:number => creditcard.number,
|
156
|
+
:cvv => creditcard.verification_value,
|
157
|
+
:expiration_month => creditcard.month.to_s.rjust(2, "0"),
|
158
|
+
:expiration_year => creditcard.year.to_s
|
159
|
+
}
|
160
|
+
}, options)[:credit_card]
|
161
|
+
|
162
|
+
result = Braintree::Customer.update(vault_id,
|
163
|
+
:first_name => creditcard.first_name,
|
164
|
+
:last_name => creditcard.last_name,
|
165
|
+
:email => options[:email],
|
166
|
+
:credit_card => credit_card_params
|
167
|
+
)
|
168
|
+
Response.new(result.success?, message_from_result(result),
|
169
|
+
:braintree_customer => (customer_hash(Braintree::Customer.find(vault_id)) if result.success?),
|
170
|
+
:customer_vault_id => (result.customer.id if result.success?)
|
171
|
+
)
|
172
|
+
end
|
173
|
+
end
|
174
|
+
|
175
|
+
def unstore(customer_vault_id, options = {})
|
176
|
+
commit do
|
177
|
+
Braintree::Customer.delete(customer_vault_id)
|
178
|
+
Response.new(true, "OK")
|
179
|
+
end
|
180
|
+
end
|
181
|
+
alias_method :delete, :unstore
|
182
|
+
|
183
|
+
private
|
184
|
+
|
185
|
+
def merge_credit_card_options(parameters, options)
|
186
|
+
valid_options = {}
|
187
|
+
options.each do |key, value|
|
188
|
+
valid_options[key] = value if [:update_existing_token, :verify_card, :verification_merchant_account_id].include?(key)
|
189
|
+
end
|
190
|
+
|
191
|
+
parameters[:credit_card] ||= {}
|
192
|
+
parameters[:credit_card].merge!(:options => valid_options)
|
193
|
+
parameters[:credit_card][:billing_address] = map_address(options[:billing_address]) if options[:billing_address]
|
194
|
+
parameters
|
195
|
+
end
|
196
|
+
|
197
|
+
def map_address(address)
|
198
|
+
return {} if address.nil?
|
199
|
+
mapped = {
|
200
|
+
:street_address => address[:address1],
|
201
|
+
:extended_address => address[:address2],
|
202
|
+
:company => address[:company],
|
203
|
+
:locality => address[:city],
|
204
|
+
:region => address[:state],
|
205
|
+
:postal_code => address[:zip],
|
206
|
+
}
|
207
|
+
if(address[:country] || address[:country_code_alpha2])
|
208
|
+
mapped[:country_code_alpha2] = (address[:country] || address[:country_code_alpha2])
|
209
|
+
elsif address[:country_name]
|
210
|
+
mapped[:country_name] = address[:country_name]
|
211
|
+
elsif address[:country_code_alpha3]
|
212
|
+
mapped[:country_code_alpha3] = address[:country_code_alpha3]
|
213
|
+
elsif address[:country_code_numeric]
|
214
|
+
mapped[:country_code_numeric] = address[:country_code_numeric]
|
215
|
+
end
|
216
|
+
mapped
|
217
|
+
end
|
218
|
+
|
219
|
+
def commit(&block)
|
220
|
+
yield
|
221
|
+
rescue Braintree::BraintreeError => ex
|
222
|
+
Response.new(false, ex.class.to_s)
|
223
|
+
end
|
224
|
+
|
225
|
+
def message_from_result(result)
|
226
|
+
if result.success?
|
227
|
+
"OK"
|
228
|
+
elsif result.errors.size == 0 && result.credit_card_verification
|
229
|
+
"Processor declined: #{result.credit_card_verification.processor_response_text} (#{result.credit_card_verification.processor_response_code})"
|
230
|
+
else
|
231
|
+
result.errors.map { |e| "#{e.message} (#{e.code})" }.join(" ")
|
232
|
+
end
|
233
|
+
end
|
234
|
+
|
235
|
+
def create_transaction(transaction_type, money, credit_card_or_vault_id, options)
|
236
|
+
transaction_params = create_transaction_parameters(money, credit_card_or_vault_id, options)
|
237
|
+
|
238
|
+
commit do
|
239
|
+
result = Braintree::Transaction.send(transaction_type, transaction_params)
|
240
|
+
response_params, response_options, avs_result, cvv_result = {}, {}, {}, {}
|
241
|
+
if result.success?
|
242
|
+
response_params[:braintree_transaction] = transaction_hash(result.transaction)
|
243
|
+
response_params[:customer_vault_id] = result.transaction.customer_details.id
|
244
|
+
response_options[:authorization] = result.transaction.id
|
245
|
+
end
|
246
|
+
if result.transaction
|
247
|
+
response_options[:avs_result] = {
|
248
|
+
:code => nil, :message => nil,
|
249
|
+
:street_match => result.transaction.avs_street_address_response_code,
|
250
|
+
:postal_match => result.transaction.avs_postal_code_response_code
|
251
|
+
}
|
252
|
+
response_options[:cvv_result] = result.transaction.cvv_response_code
|
253
|
+
if result.transaction.status == "gateway_rejected"
|
254
|
+
message = "Transaction declined - gateway rejected"
|
255
|
+
else
|
256
|
+
message = "#{result.transaction.processor_response_code} #{result.transaction.processor_response_text}"
|
257
|
+
end
|
258
|
+
else
|
259
|
+
message = message_from_result(result)
|
260
|
+
end
|
261
|
+
response = Response.new(result.success?, message, response_params, response_options)
|
262
|
+
response.cvv_result['message'] = ''
|
263
|
+
response
|
264
|
+
end
|
265
|
+
end
|
266
|
+
|
267
|
+
def extract_refund_args(args)
|
268
|
+
options = args.extract_options!
|
269
|
+
|
270
|
+
# money, transaction_id, options
|
271
|
+
if args.length == 1 # legacy signature
|
272
|
+
return nil, args[0], options
|
273
|
+
elsif args.length == 2
|
274
|
+
return args[0], args[1], options
|
275
|
+
else
|
276
|
+
raise ArgumentError, "wrong number of arguments (#{args.length} for 2)"
|
277
|
+
end
|
278
|
+
end
|
279
|
+
|
280
|
+
def customer_hash(customer)
|
281
|
+
credit_cards = customer.credit_cards.map do |cc|
|
282
|
+
{
|
283
|
+
"bin" => cc.bin,
|
284
|
+
"expiration_date" => cc.expiration_date,
|
285
|
+
"token" => cc.token,
|
286
|
+
"last_4" => cc.last_4,
|
287
|
+
"card_type" => cc.card_type,
|
288
|
+
"masked_number" => cc.masked_number
|
289
|
+
}
|
290
|
+
end
|
291
|
+
|
292
|
+
{
|
293
|
+
"email" => customer.email,
|
294
|
+
"first_name" => customer.first_name,
|
295
|
+
"last_name" => customer.last_name,
|
296
|
+
"credit_cards" => credit_cards,
|
297
|
+
"id" => customer.id
|
298
|
+
}
|
299
|
+
end
|
300
|
+
|
301
|
+
def transaction_hash(transaction)
|
302
|
+
if transaction.vault_customer
|
303
|
+
vault_customer = {
|
304
|
+
}
|
305
|
+
vault_customer["credit_cards"] = transaction.vault_customer.credit_cards.map do |cc|
|
306
|
+
{
|
307
|
+
"bin" => cc.bin
|
308
|
+
}
|
309
|
+
end
|
310
|
+
else
|
311
|
+
vault_customer = nil
|
312
|
+
end
|
313
|
+
|
314
|
+
customer_details = {
|
315
|
+
"id" => transaction.customer_details.id,
|
316
|
+
"email" => transaction.customer_details.email
|
317
|
+
}
|
318
|
+
|
319
|
+
billing_details = {
|
320
|
+
"street_address" => transaction.billing_details.street_address,
|
321
|
+
"extended_address" => transaction.billing_details.extended_address,
|
322
|
+
"company" => transaction.billing_details.company,
|
323
|
+
"locality" => transaction.billing_details.locality,
|
324
|
+
"region" => transaction.billing_details.region,
|
325
|
+
"postal_code" => transaction.billing_details.postal_code,
|
326
|
+
"country_name" => transaction.billing_details.country_name,
|
327
|
+
}
|
328
|
+
|
329
|
+
shipping_details = {
|
330
|
+
"street_address" => transaction.shipping_details.street_address,
|
331
|
+
"extended_address" => transaction.shipping_details.extended_address,
|
332
|
+
"company" => transaction.shipping_details.company,
|
333
|
+
"locality" => transaction.shipping_details.locality,
|
334
|
+
"region" => transaction.shipping_details.region,
|
335
|
+
"postal_code" => transaction.shipping_details.postal_code,
|
336
|
+
"country_name" => transaction.shipping_details.country_name,
|
337
|
+
}
|
338
|
+
credit_card_details = {
|
339
|
+
"masked_number" => transaction.credit_card_details.masked_number,
|
340
|
+
"bin" => transaction.credit_card_details.bin,
|
341
|
+
"last_4" => transaction.credit_card_details.last_4,
|
342
|
+
"card_type" => transaction.credit_card_details.card_type,
|
343
|
+
"token" => transaction.credit_card_details.token
|
344
|
+
}
|
345
|
+
|
346
|
+
{
|
347
|
+
"order_id" => transaction.order_id,
|
348
|
+
"status" => transaction.status,
|
349
|
+
"credit_card_details" => credit_card_details,
|
350
|
+
"customer_details" => customer_details,
|
351
|
+
"billing_details" => billing_details,
|
352
|
+
"shipping_details" => shipping_details,
|
353
|
+
"vault_customer" => vault_customer,
|
354
|
+
"merchant_account_id" => transaction.merchant_account_id
|
355
|
+
}
|
356
|
+
end
|
357
|
+
|
358
|
+
def create_transaction_parameters(money, credit_card_or_vault_id, options)
|
359
|
+
parameters = {
|
360
|
+
:amount => amount(money).to_s,
|
361
|
+
:order_id => options[:order_id],
|
362
|
+
:customer => {
|
363
|
+
:id => options[:store] == true ? "" : options[:store],
|
364
|
+
:email => options[:email]
|
365
|
+
},
|
366
|
+
:options => {
|
367
|
+
:store_in_vault => options[:store] ? true : false,
|
368
|
+
:submit_for_settlement => options[:submit_for_settlement]
|
369
|
+
}
|
370
|
+
}
|
371
|
+
|
372
|
+
if merchant_account_id = (options[:merchant_account_id] || @merchant_account_id)
|
373
|
+
parameters[:merchant_account_id] = merchant_account_id
|
374
|
+
end
|
375
|
+
|
376
|
+
if options[:recurring]
|
377
|
+
parameters[:recurring] = true
|
378
|
+
end
|
379
|
+
|
380
|
+
if credit_card_or_vault_id.is_a?(String) || credit_card_or_vault_id.is_a?(Integer)
|
381
|
+
parameters[:customer_id] = credit_card_or_vault_id
|
382
|
+
else
|
383
|
+
parameters[:customer].merge!(
|
384
|
+
:first_name => credit_card_or_vault_id.first_name,
|
385
|
+
:last_name => credit_card_or_vault_id.last_name
|
386
|
+
)
|
387
|
+
parameters[:credit_card] = {
|
388
|
+
:number => credit_card_or_vault_id.number,
|
389
|
+
:cvv => credit_card_or_vault_id.verification_value,
|
390
|
+
:expiration_month => credit_card_or_vault_id.month.to_s.rjust(2, "0"),
|
391
|
+
:expiration_year => credit_card_or_vault_id.year.to_s
|
392
|
+
}
|
393
|
+
end
|
394
|
+
parameters[:billing] = map_address(options[:billing_address]) if options[:billing_address]
|
395
|
+
parameters[:shipping] = map_address(options[:shipping_address]) if options[:shipping_address]
|
396
|
+
parameters
|
397
|
+
end
|
398
|
+
end
|
399
|
+
end
|
400
|
+
end
|
401
|
+
|
@@ -0,0 +1,19 @@
|
|
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
|
+
self.live_url = self.test_url = 'https://secure.braintreepaymentgateway.com/api/transact.php'
|
12
|
+
|
13
|
+
def add_processor(post, options)
|
14
|
+
post[:processor_id] = options[:processor] unless options[:processor].nil?
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module ActiveMerchant #:nodoc:
|
2
|
+
module Billing #:nodoc:
|
3
|
+
class CardSaveGateway < IridiumGateway
|
4
|
+
#CardSave lets you handle failovers on payments by providing 3 gateways in case one happens to be down
|
5
|
+
#URLS = ['https://gw1.cardsaveonlinepayments.com:4430/','https://gw2.cardsaveonlinepayments.com:4430/','https://gw3.cardsaveonlinepayments.com:4430/']
|
6
|
+
|
7
|
+
self.money_format = :cents
|
8
|
+
self.default_currency = 'GBP'
|
9
|
+
self.supported_cardtypes = [ :visa, :switch, :maestro, :master, :solo, :american_express, :jcb ]
|
10
|
+
self.supported_countries = [ 'GB' ]
|
11
|
+
self.homepage_url = 'http://www.cardsave.net/'
|
12
|
+
self.display_name = 'CardSave'
|
13
|
+
|
14
|
+
def initialize(options={})
|
15
|
+
super
|
16
|
+
@test_url = 'https://gw1.cardsaveonlinepayments.com:4430/'
|
17
|
+
@live_url = 'https://gw1.cardsaveonlinepayments.com:4430/'
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
@@ -0,0 +1,225 @@
|
|
1
|
+
module ActiveMerchant #:nodoc:
|
2
|
+
module Billing #:nodoc:
|
3
|
+
#
|
4
|
+
# CardStream supports the following credit cards, which are auto-detected by
|
5
|
+
# the gateway based on the card number used:
|
6
|
+
# * AM American Express
|
7
|
+
# * Diners Club
|
8
|
+
# * Electron
|
9
|
+
# * JCB
|
10
|
+
# * UK Maestro
|
11
|
+
# * Maestro International
|
12
|
+
# * Mastercard
|
13
|
+
# * Solo
|
14
|
+
# * Style
|
15
|
+
# * Switch
|
16
|
+
# * Visa Credit
|
17
|
+
# * Visa Debit
|
18
|
+
# * Visa Purchasing
|
19
|
+
#
|
20
|
+
class CardStreamGateway < Gateway
|
21
|
+
self.live_url = self.test_url = 'https://gateway.cardstream.com/process.ashx'
|
22
|
+
|
23
|
+
self.money_format = :cents
|
24
|
+
self.default_currency = 'GBP'
|
25
|
+
self.supported_countries = ['GB']
|
26
|
+
self.supported_cardtypes = [:visa, :master, :american_express, :diners_club, :discover, :jcb, :maestro, :solo, :switch]
|
27
|
+
self.homepage_url = 'http://www.cardstream.com/'
|
28
|
+
self.display_name = 'CardStream'
|
29
|
+
|
30
|
+
APPROVED = '00'
|
31
|
+
|
32
|
+
CURRENCY_CODES = {
|
33
|
+
"AUD"=> '036',
|
34
|
+
"CAD"=> '124',
|
35
|
+
"CZK"=> '203',
|
36
|
+
"DKK"=> '208',
|
37
|
+
"HKD"=> '344',
|
38
|
+
"ICK"=> '352',
|
39
|
+
"JPY"=> '392',
|
40
|
+
"NOK"=> '578',
|
41
|
+
"SGD"=> '702',
|
42
|
+
"SEK"=> '752',
|
43
|
+
"CHF"=> '756',
|
44
|
+
"GBP"=> '826',
|
45
|
+
"USD"=> '840',
|
46
|
+
"EUR"=> '978'
|
47
|
+
}
|
48
|
+
|
49
|
+
TRANSACTIONS = {
|
50
|
+
:purchase => 'ESALE_KEYED',
|
51
|
+
:refund => 'EREFUND_KEYED',
|
52
|
+
:authorization => 'ESALE_KEYED'
|
53
|
+
}
|
54
|
+
|
55
|
+
CVV_CODE = {
|
56
|
+
'0' => 'U',
|
57
|
+
'1' => 'P',
|
58
|
+
'2' => 'M',
|
59
|
+
'4' => 'N'
|
60
|
+
}
|
61
|
+
|
62
|
+
# 0 - No additional information available.
|
63
|
+
# 1 - Postcode not checked.
|
64
|
+
# 2 - Postcode matched.
|
65
|
+
# 4 - Postcode not matched.
|
66
|
+
# 8 - Postcode partially matched.
|
67
|
+
AVS_POSTAL_MATCH = {
|
68
|
+
"0" => nil,
|
69
|
+
"1" => nil,
|
70
|
+
"2" => "Y",
|
71
|
+
"4" => "N",
|
72
|
+
"8" => "N"
|
73
|
+
}
|
74
|
+
|
75
|
+
# 0 - No additional information available.
|
76
|
+
# 1 - Address numeric not checked.
|
77
|
+
# 2 - Address numeric matched.
|
78
|
+
# 4 - Address numeric not matched.
|
79
|
+
# 8 - Address numeric partially matched.
|
80
|
+
AVS_STREET_MATCH = {
|
81
|
+
"0" => nil,
|
82
|
+
"1" => nil,
|
83
|
+
"2" => "Y",
|
84
|
+
"4" => "N",
|
85
|
+
"8" => "N"
|
86
|
+
}
|
87
|
+
|
88
|
+
def initialize(options = {})
|
89
|
+
requires!(options, :login, :password)
|
90
|
+
super
|
91
|
+
end
|
92
|
+
|
93
|
+
def purchase(money, credit_card, options = {})
|
94
|
+
requires!(options, :order_id)
|
95
|
+
|
96
|
+
post = {}
|
97
|
+
|
98
|
+
add_amount(post, money, options)
|
99
|
+
add_invoice(post, money, credit_card, options)
|
100
|
+
add_credit_card(post, credit_card)
|
101
|
+
add_address(post, options)
|
102
|
+
add_customer_data(post, options)
|
103
|
+
|
104
|
+
commit(:purchase, post)
|
105
|
+
end
|
106
|
+
|
107
|
+
private
|
108
|
+
|
109
|
+
def add_amount(post, money, options)
|
110
|
+
add_pair(post, :Amount, amount(money), :required => true)
|
111
|
+
add_pair(post, :CurrencyCode, currency_code(options[:currency] || currency(money)), :required => true)
|
112
|
+
end
|
113
|
+
|
114
|
+
def add_customer_data(post, options)
|
115
|
+
add_pair(post, :BillingEmail, options[:email])
|
116
|
+
add_pair(post, :BillingPhoneNumber, options[:phone])
|
117
|
+
end
|
118
|
+
|
119
|
+
def add_address(post, options)
|
120
|
+
address = options[:billing_address] || options[:address]
|
121
|
+
|
122
|
+
return if address.nil?
|
123
|
+
|
124
|
+
add_pair(post, :BillingStreet, address[:address1])
|
125
|
+
add_pair(post, :BillingHouseNumber, address[:address2])
|
126
|
+
add_pair(post, :BillingCity, address[:city])
|
127
|
+
add_pair(post, :BillingState, address[:state])
|
128
|
+
add_pair(post, :BillingPostCode, address[:zip])
|
129
|
+
end
|
130
|
+
|
131
|
+
def add_invoice(post, money, credit_card, options)
|
132
|
+
add_pair(post, :TransactionUnique, options[:order_id], :required => true)
|
133
|
+
add_pair(post, :OrderDesc, options[:description] || options[:order_id], :required => true)
|
134
|
+
|
135
|
+
if [ 'american_express', 'diners_club' ].include?(card_brand(credit_card).to_s)
|
136
|
+
add_pair(post, :AEIT1Quantity, 1)
|
137
|
+
add_pair(post, :AEIT1Description, (options[:description] || options[:order_id]).slice(0, 15))
|
138
|
+
add_pair(post, :AEIT1GrossValue, amount(money))
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
def add_credit_card(post, credit_card)
|
143
|
+
add_pair(post, :CardName, credit_card.name, :required => true)
|
144
|
+
add_pair(post, :CardNumber, credit_card.number, :required => true)
|
145
|
+
|
146
|
+
add_pair(post, :ExpiryDateMM, format(credit_card.month, :two_digits), :required => true)
|
147
|
+
add_pair(post, :ExpiryDateYY, format(credit_card.year, :two_digits), :required => true)
|
148
|
+
|
149
|
+
if requires_start_date_or_issue_number?(credit_card)
|
150
|
+
add_pair(post, :StartDateMM, format(credit_card.start_month, :two_digits))
|
151
|
+
add_pair(post, :StartDateYY, format(credit_card.start_year, :two_digits))
|
152
|
+
|
153
|
+
add_pair(post, :IssueNumber, credit_card.issue_number)
|
154
|
+
end
|
155
|
+
|
156
|
+
add_pair(post, :CV2, credit_card.verification_value)
|
157
|
+
end
|
158
|
+
|
159
|
+
def commit(action, parameters)
|
160
|
+
response = parse( ssl_post(self.live_url, post_data(action, parameters)) )
|
161
|
+
|
162
|
+
Response.new(response[:response_code] == APPROVED, message_from(response), response,
|
163
|
+
:test => test?,
|
164
|
+
:authorization => response[:cross_reference],
|
165
|
+
:cvv_result => CVV_CODE[ response[:avscv2_response_code].to_s[0, 1] ],
|
166
|
+
:avs_result => {
|
167
|
+
:street_match => AVS_STREET_MATCH[ response[:avscv2_response_code].to_s[2, 1] ],
|
168
|
+
:postal_match => AVS_POSTAL_MATCH[ response[:avscv2_response_code].to_s[1, 1] ]
|
169
|
+
}
|
170
|
+
)
|
171
|
+
end
|
172
|
+
|
173
|
+
def message_from(results)
|
174
|
+
results[:response_code] == APPROVED ? "APPROVED" : results[:message]
|
175
|
+
end
|
176
|
+
|
177
|
+
def post_data(action, parameters = {})
|
178
|
+
parameters.update(
|
179
|
+
:MerchantPassword => @options[:password],
|
180
|
+
:MerchantID => @options[:login],
|
181
|
+
:MessageType => TRANSACTIONS[action],
|
182
|
+
:CallBack => "disable",
|
183
|
+
:DuplicateDelay => "0",
|
184
|
+
:EchoCardType => "YES",
|
185
|
+
:EchoAmount => "YES",
|
186
|
+
:EchoAVSCV2ResponseCode => "YES",
|
187
|
+
:ReturnAVSCV2Message => "YES",
|
188
|
+
:CountryCode => '826' # 826 for UK based merchant
|
189
|
+
)
|
190
|
+
|
191
|
+
add_pair(parameters, :Dispatch, action == :authorization ? "LATER" : "NOW")
|
192
|
+
|
193
|
+
parameters.collect { |key, value| "VP#{key}=#{CGI.escape(value.to_s)}" }.join("&")
|
194
|
+
end
|
195
|
+
|
196
|
+
# VPCrossReference
|
197
|
+
# The value in VPCrossReference on a success transaction will contain
|
198
|
+
# a unique reference that you may use to run future transactions.
|
199
|
+
# Please note that cross reference transactions must come a static IP
|
200
|
+
# addressed that has been pre-registered with Cardstream. To
|
201
|
+
# register an IP address please send it to support@cardstream.com
|
202
|
+
# with your Cardstream issued merchant ID and it will be added to
|
203
|
+
# your account.
|
204
|
+
def parse(body)
|
205
|
+
result = {}
|
206
|
+
pairs = body.split("&")
|
207
|
+
pairs.each do |pair|
|
208
|
+
a = pair.split("=")
|
209
|
+
result[a[0].gsub(/^VP/,'').underscore.to_sym] = a[1]
|
210
|
+
end
|
211
|
+
|
212
|
+
result
|
213
|
+
end
|
214
|
+
|
215
|
+
def currency_code(currency)
|
216
|
+
CURRENCY_CODES[currency]
|
217
|
+
end
|
218
|
+
|
219
|
+
def add_pair(post, key, value, options = {})
|
220
|
+
post[key] = value if !value.blank? || options[:required]
|
221
|
+
end
|
222
|
+
end
|
223
|
+
end
|
224
|
+
end
|
225
|
+
|