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,324 @@
|
|
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
|
+
super
|
56
|
+
end
|
57
|
+
|
58
|
+
def purchase(money, credit_card, options = {})
|
59
|
+
requires!(options, :order_id)
|
60
|
+
|
61
|
+
post = {}
|
62
|
+
|
63
|
+
add_amount(post, money, options)
|
64
|
+
add_invoice(post, options)
|
65
|
+
add_credit_card(post, credit_card)
|
66
|
+
add_address(post, options)
|
67
|
+
add_customer_data(post, options)
|
68
|
+
add_optional_data(post, options)
|
69
|
+
|
70
|
+
commit(:purchase, post)
|
71
|
+
end
|
72
|
+
|
73
|
+
def authorize(money, credit_card, options = {})
|
74
|
+
requires!(options, :order_id)
|
75
|
+
|
76
|
+
post = {}
|
77
|
+
|
78
|
+
add_amount(post, money, options)
|
79
|
+
add_invoice(post, options)
|
80
|
+
add_credit_card(post, credit_card)
|
81
|
+
add_address(post, options)
|
82
|
+
add_customer_data(post, options)
|
83
|
+
add_optional_data(post, options)
|
84
|
+
|
85
|
+
commit(:authorization, post)
|
86
|
+
end
|
87
|
+
|
88
|
+
# You can only capture a transaction once, even if you didn't capture the full amount the first time.
|
89
|
+
def capture(money, identification, options = {})
|
90
|
+
post = {}
|
91
|
+
|
92
|
+
add_reference(post, identification)
|
93
|
+
add_release_amount(post, money, options)
|
94
|
+
|
95
|
+
commit(:capture, post)
|
96
|
+
end
|
97
|
+
|
98
|
+
def void(identification, options = {})
|
99
|
+
post = {}
|
100
|
+
|
101
|
+
add_reference(post, identification)
|
102
|
+
action = abort_or_void_from(identification)
|
103
|
+
|
104
|
+
commit(action, post)
|
105
|
+
end
|
106
|
+
|
107
|
+
# Refunding requires a new order_id to passed in, as well as a description
|
108
|
+
def refund(money, identification, options = {})
|
109
|
+
requires!(options, :order_id, :description)
|
110
|
+
|
111
|
+
post = {}
|
112
|
+
|
113
|
+
add_credit_reference(post, identification)
|
114
|
+
add_amount(post, money, options)
|
115
|
+
add_invoice(post, options)
|
116
|
+
|
117
|
+
commit(:credit, post)
|
118
|
+
end
|
119
|
+
|
120
|
+
def credit(money, identification, options = {})
|
121
|
+
deprecated CREDIT_DEPRECATION_MESSAGE
|
122
|
+
refund(money, identification, options)
|
123
|
+
end
|
124
|
+
|
125
|
+
private
|
126
|
+
def add_reference(post, identification)
|
127
|
+
order_id, transaction_id, authorization, security_key = identification.split(';')
|
128
|
+
|
129
|
+
add_pair(post, :VendorTxCode, order_id)
|
130
|
+
add_pair(post, :VPSTxId, transaction_id)
|
131
|
+
add_pair(post, :TxAuthNo, authorization)
|
132
|
+
add_pair(post, :SecurityKey, security_key)
|
133
|
+
end
|
134
|
+
|
135
|
+
def add_credit_reference(post, identification)
|
136
|
+
order_id, transaction_id, authorization, security_key = identification.split(';')
|
137
|
+
|
138
|
+
add_pair(post, :RelatedVendorTxCode, order_id)
|
139
|
+
add_pair(post, :RelatedVPSTxId, transaction_id)
|
140
|
+
add_pair(post, :RelatedTxAuthNo, authorization)
|
141
|
+
add_pair(post, :RelatedSecurityKey, security_key)
|
142
|
+
end
|
143
|
+
|
144
|
+
def add_amount(post, money, options)
|
145
|
+
currency = options[:currency] || currency(money)
|
146
|
+
add_pair(post, :Amount, localized_amount(money, currency), :required => true)
|
147
|
+
add_pair(post, :Currency, currency, :required => true)
|
148
|
+
end
|
149
|
+
|
150
|
+
# doesn't actually use the currency -- dodgy!
|
151
|
+
def add_release_amount(post, money, options)
|
152
|
+
add_pair(post, :ReleaseAmount, amount(money), :required => true)
|
153
|
+
end
|
154
|
+
|
155
|
+
def add_customer_data(post, options)
|
156
|
+
add_pair(post, :CustomerEMail, options[:email][0,255]) unless options[:email].blank?
|
157
|
+
add_pair(post, :BillingPhone, options[:phone].gsub(/[^0-9+]/, '')[0,20]) unless options[:phone].blank?
|
158
|
+
add_pair(post, :ClientIPAddress, options[:ip])
|
159
|
+
end
|
160
|
+
|
161
|
+
def add_optional_data(post, options)
|
162
|
+
add_pair(post, :GiftAidPayment, options[:gift_aid_payment]) unless options[:gift_aid_payment].blank?
|
163
|
+
add_pair(post, :Apply3DSecure, options[:apply_3d_secure]) unless options[:apply_3d_secure].blank?
|
164
|
+
end
|
165
|
+
|
166
|
+
def add_address(post, options)
|
167
|
+
if billing_address = options[:billing_address] || options[:address]
|
168
|
+
first_name, last_name = parse_first_and_last_name(billing_address[:name])
|
169
|
+
add_pair(post, :BillingSurname, last_name)
|
170
|
+
add_pair(post, :BillingFirstnames, first_name)
|
171
|
+
add_pair(post, :BillingAddress1, billing_address[:address1])
|
172
|
+
add_pair(post, :BillingAddress2, billing_address[:address2])
|
173
|
+
add_pair(post, :BillingCity, billing_address[:city])
|
174
|
+
add_pair(post, :BillingState, billing_address[:state]) if billing_address[:country] == 'US'
|
175
|
+
add_pair(post, :BillingCountry, billing_address[:country])
|
176
|
+
add_pair(post, :BillingPostCode, billing_address[:zip])
|
177
|
+
end
|
178
|
+
|
179
|
+
if shipping_address = options[:shipping_address] || billing_address
|
180
|
+
first_name, last_name = parse_first_and_last_name(shipping_address[:name])
|
181
|
+
add_pair(post, :DeliverySurname, last_name)
|
182
|
+
add_pair(post, :DeliveryFirstnames, first_name)
|
183
|
+
add_pair(post, :DeliveryAddress1, shipping_address[:address1])
|
184
|
+
add_pair(post, :DeliveryAddress2, shipping_address[:address2])
|
185
|
+
add_pair(post, :DeliveryCity, shipping_address[:city])
|
186
|
+
add_pair(post, :DeliveryState, shipping_address[:state]) if shipping_address[:country] == 'US'
|
187
|
+
add_pair(post, :DeliveryCountry, shipping_address[:country])
|
188
|
+
add_pair(post, :DeliveryPostCode, shipping_address[:zip])
|
189
|
+
end
|
190
|
+
end
|
191
|
+
|
192
|
+
def add_invoice(post, options)
|
193
|
+
add_pair(post, :VendorTxCode, sanitize_order_id(options[:order_id]), :required => true)
|
194
|
+
add_pair(post, :Description, options[:description] || options[:order_id])
|
195
|
+
end
|
196
|
+
|
197
|
+
def add_credit_card(post, credit_card)
|
198
|
+
add_pair(post, :CardHolder, credit_card.name, :required => true)
|
199
|
+
add_pair(post, :CardNumber, credit_card.number, :required => true)
|
200
|
+
|
201
|
+
add_pair(post, :ExpiryDate, format_date(credit_card.month, credit_card.year), :required => true)
|
202
|
+
|
203
|
+
if requires_start_date_or_issue_number?(credit_card)
|
204
|
+
add_pair(post, :StartDate, format_date(credit_card.start_month, credit_card.start_year))
|
205
|
+
add_pair(post, :IssueNumber, credit_card.issue_number)
|
206
|
+
end
|
207
|
+
add_pair(post, :CardType, map_card_type(credit_card))
|
208
|
+
|
209
|
+
add_pair(post, :CV2, credit_card.verification_value)
|
210
|
+
end
|
211
|
+
|
212
|
+
def sanitize_order_id(order_id)
|
213
|
+
order_id.to_s.gsub(/[^-a-zA-Z0-9._]/, '')
|
214
|
+
end
|
215
|
+
|
216
|
+
def map_card_type(credit_card)
|
217
|
+
raise ArgumentError, "The credit card type must be provided" if card_brand(credit_card).blank?
|
218
|
+
|
219
|
+
card_type = card_brand(credit_card).to_sym
|
220
|
+
|
221
|
+
# Check if it is an electron card
|
222
|
+
if card_type == :visa && credit_card.number =~ ELECTRON
|
223
|
+
CREDIT_CARDS[:electron]
|
224
|
+
else
|
225
|
+
CREDIT_CARDS[card_type]
|
226
|
+
end
|
227
|
+
end
|
228
|
+
|
229
|
+
# MMYY format
|
230
|
+
def format_date(month, year)
|
231
|
+
return nil if year.blank? || month.blank?
|
232
|
+
|
233
|
+
year = sprintf("%.4i", year)
|
234
|
+
month = sprintf("%.2i", month)
|
235
|
+
|
236
|
+
"#{month}#{year[-2..-1]}"
|
237
|
+
end
|
238
|
+
|
239
|
+
def commit(action, parameters)
|
240
|
+
response = parse( ssl_post(url_for(action), post_data(action, parameters)) )
|
241
|
+
|
242
|
+
Response.new(response["Status"] == APPROVED, message_from(response), response,
|
243
|
+
:test => test?,
|
244
|
+
:authorization => authorization_from(response, parameters, action),
|
245
|
+
:avs_result => {
|
246
|
+
:street_match => AVS_CVV_CODE[ response["AddressResult"] ],
|
247
|
+
:postal_match => AVS_CVV_CODE[ response["PostCodeResult"] ],
|
248
|
+
},
|
249
|
+
:cvv_result => AVS_CVV_CODE[ response["CV2Result"] ]
|
250
|
+
)
|
251
|
+
end
|
252
|
+
|
253
|
+
def authorization_from(response, params, action)
|
254
|
+
[ params[:VendorTxCode],
|
255
|
+
response["VPSTxId"],
|
256
|
+
response["TxAuthNo"],
|
257
|
+
response["SecurityKey"],
|
258
|
+
action ].join(";")
|
259
|
+
end
|
260
|
+
|
261
|
+
def abort_or_void_from(identification)
|
262
|
+
original_transaction = identification.split(';').last
|
263
|
+
original_transaction == 'authorization' ? :abort : :void
|
264
|
+
end
|
265
|
+
|
266
|
+
def url_for(action)
|
267
|
+
simulate ? build_simulator_url(action) : build_url(action)
|
268
|
+
end
|
269
|
+
|
270
|
+
def build_url(action)
|
271
|
+
endpoint = [ :purchase, :authorization ].include?(action) ? "vspdirect-register" : TRANSACTIONS[action].downcase
|
272
|
+
"#{test? ? self.test_url : self.live_url}/#{endpoint}.vsp"
|
273
|
+
end
|
274
|
+
|
275
|
+
def build_simulator_url(action)
|
276
|
+
endpoint = [ :purchase, :authorization ].include?(action) ? "VSPDirectGateway.asp" : "VSPServerGateway.asp?Service=Vendor#{TRANSACTIONS[action].capitalize}Tx"
|
277
|
+
"#{self.simulator_url}/#{endpoint}"
|
278
|
+
end
|
279
|
+
|
280
|
+
def message_from(response)
|
281
|
+
response['Status'] == APPROVED ? 'Success' : (response['StatusDetail'] || 'Unspecified error') # simonr 20080207 can't actually get non-nil blanks, so this is shorter
|
282
|
+
end
|
283
|
+
|
284
|
+
def post_data(action, parameters = {})
|
285
|
+
parameters.update(
|
286
|
+
:Vendor => @options[:login],
|
287
|
+
:TxType => TRANSACTIONS[action],
|
288
|
+
:VPSProtocol => "2.23"
|
289
|
+
)
|
290
|
+
|
291
|
+
parameters.collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join("&")
|
292
|
+
end
|
293
|
+
|
294
|
+
# SagePay returns data in the following format
|
295
|
+
# Key1=value1
|
296
|
+
# Key2=value2
|
297
|
+
def parse(body)
|
298
|
+
result = {}
|
299
|
+
body.to_s.each_line do |pair|
|
300
|
+
result[$1] = $2 if pair.strip =~ /\A([^=]+)=(.+)\Z/im
|
301
|
+
end
|
302
|
+
result
|
303
|
+
end
|
304
|
+
|
305
|
+
def add_pair(post, key, value, options = {})
|
306
|
+
post[key] = value if !value.blank? || options[:required]
|
307
|
+
end
|
308
|
+
|
309
|
+
def parse_first_and_last_name(value)
|
310
|
+
name = value.to_s.split(' ')
|
311
|
+
|
312
|
+
last_name = name.pop || ''
|
313
|
+
first_name = name.join(' ')
|
314
|
+
[ first_name[0,20], last_name[0,20] ]
|
315
|
+
end
|
316
|
+
|
317
|
+
def localized_amount(money, currency)
|
318
|
+
amount = amount(money)
|
319
|
+
CURRENCIES_WITHOUT_FRACTIONS.include?(currency.to_s) ? amount.split('.').first : amount
|
320
|
+
end
|
321
|
+
end
|
322
|
+
end
|
323
|
+
end
|
324
|
+
|
@@ -0,0 +1,143 @@
|
|
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
|
+
super
|
21
|
+
end
|
22
|
+
|
23
|
+
def test?
|
24
|
+
@options[:login] == "TEST0"
|
25
|
+
end
|
26
|
+
|
27
|
+
def authorize(money, creditcard, options = {})
|
28
|
+
post = PostData.new
|
29
|
+
add_invoice(post, options)
|
30
|
+
add_creditcard(post, creditcard)
|
31
|
+
add_address(post, creditcard, options)
|
32
|
+
add_customer_data(post, options)
|
33
|
+
|
34
|
+
commit(:authonly, money, post)
|
35
|
+
end
|
36
|
+
|
37
|
+
def purchase(money, creditcard, options = {})
|
38
|
+
post = PostData.new
|
39
|
+
add_invoice(post, options)
|
40
|
+
add_creditcard(post, creditcard)
|
41
|
+
add_address(post, creditcard, options)
|
42
|
+
add_customer_data(post, options)
|
43
|
+
|
44
|
+
commit(:sale, money, post)
|
45
|
+
end
|
46
|
+
|
47
|
+
def capture(money, authorization, options = {})
|
48
|
+
post = PostData.new
|
49
|
+
post[:postonly] = authorization
|
50
|
+
commit(:capture, money, post)
|
51
|
+
end
|
52
|
+
|
53
|
+
private
|
54
|
+
|
55
|
+
def add_customer_data(post, options)
|
56
|
+
if address = options[:billing_address] || options[:shipping_address] || options[:address]
|
57
|
+
post[:ci_phone] = address[:phone].to_s
|
58
|
+
end
|
59
|
+
|
60
|
+
post[:ci_email] = options[:email].to_s unless options[:email].blank?
|
61
|
+
post[:ci_IP] = options[:ip].to_s unless options[:ip].blank?
|
62
|
+
end
|
63
|
+
|
64
|
+
def add_address(post, creditcard, options)
|
65
|
+
if address = options[:billing_address] || options[:address]
|
66
|
+
post[:ci_billaddr1] = address[:address1].to_s
|
67
|
+
post[:ci_billaddr2] = address[:address2].to_s unless address[:address2].blank?
|
68
|
+
post[:ci_billcity] = address[:city].to_s
|
69
|
+
post[:ci_billstate] = address[:state].to_s
|
70
|
+
post[:ci_billzip] = address[:zip].to_s
|
71
|
+
end
|
72
|
+
|
73
|
+
if shipping_address = options[:shipping_address] || options[:address]
|
74
|
+
post[:ci_shipaddr1] = shipping_address[:address1].to_s
|
75
|
+
post[:ci_shipaddr2] = shipping_address[:address2].to_s unless shipping_address[:address2].blank?
|
76
|
+
post[:ci_shipcity] = shipping_address[:city].to_s
|
77
|
+
post[:ci_shipstate] = shipping_address[:state].to_s
|
78
|
+
post[:ci_shipzip] = shipping_address[:zip].to_s
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
def add_invoice(post, options)
|
83
|
+
memo = "OrderID: #{options[:order_id]}\nDescription: #{options[:description]}"
|
84
|
+
post[:ci_memo] = memo
|
85
|
+
end
|
86
|
+
|
87
|
+
def add_creditcard(post, creditcard)
|
88
|
+
post[:ccnum] = creditcard.number.to_s
|
89
|
+
post[:ccname] = creditcard.name.to_s
|
90
|
+
post[:cvv2] = creditcard.verification_value.to_s if creditcard.verification_value?
|
91
|
+
post[:expmon] = creditcard.month.to_s
|
92
|
+
post[:expyear] = creditcard.year.to_s
|
93
|
+
end
|
94
|
+
|
95
|
+
def parse(body)
|
96
|
+
h = {}
|
97
|
+
body.gsub!("<html><body><plaintext>", "")
|
98
|
+
body.
|
99
|
+
split("\r\n").
|
100
|
+
map do |i|
|
101
|
+
a = i.split("=")
|
102
|
+
h[a.first] = a.last unless a.first.nil?
|
103
|
+
end
|
104
|
+
h
|
105
|
+
end
|
106
|
+
|
107
|
+
def commit(action, money, parameters)
|
108
|
+
parameters[:acctid] = @options[:login].to_s
|
109
|
+
parameters[:subid] = @options[:sub_id].to_s unless @options[:sub_id].blank?
|
110
|
+
parameters[:amount] = amount(money)
|
111
|
+
|
112
|
+
case action
|
113
|
+
when :sale
|
114
|
+
parameters[:action] = "ns_quicksale_cc"
|
115
|
+
when :authonly
|
116
|
+
parameters[:action] = "ns_quicksale_cc"
|
117
|
+
parameters[:authonly] = 1
|
118
|
+
when :capture
|
119
|
+
parameters[:action] = "ns_quicksale_cc"
|
120
|
+
end
|
121
|
+
|
122
|
+
response = parse(ssl_post(self.live_url, parameters.to_post_data) || "")
|
123
|
+
Response.new(successful?(response), message_from(response), response,
|
124
|
+
:test => test?,
|
125
|
+
:authorization => response["refcode"]
|
126
|
+
)
|
127
|
+
end
|
128
|
+
|
129
|
+
def successful?(response)
|
130
|
+
response["Status"] == "Accepted"
|
131
|
+
end
|
132
|
+
|
133
|
+
def message_from(response)
|
134
|
+
if successful?(response)
|
135
|
+
"Accepted"
|
136
|
+
else
|
137
|
+
response["Reason"].split(":")[2].capitalize unless response["Reason"].nil?
|
138
|
+
end
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
@@ -0,0 +1,118 @@
|
|
1
|
+
module ActiveMerchant #:nodoc:
|
2
|
+
module Billing #:nodoc:
|
3
|
+
class SamuraiGateway < Gateway
|
4
|
+
|
5
|
+
self.homepage_url = 'https://samurai.feefighters.com'
|
6
|
+
self.display_name = 'Samurai'
|
7
|
+
self.supported_countries = ['US']
|
8
|
+
self.supported_cardtypes = [:visa, :master, :american_express, :discover, :jcb, :diners_club]
|
9
|
+
self.default_currency = 'USD'
|
10
|
+
self.money_format = :dollars
|
11
|
+
|
12
|
+
def initialize(options = {})
|
13
|
+
begin
|
14
|
+
require 'samurai'
|
15
|
+
rescue LoadError
|
16
|
+
raise "Could not load the samurai gem (>= 0.2.25). Use `gem install samurai` to install it."
|
17
|
+
end
|
18
|
+
|
19
|
+
requires!(options, :login, :password, :processor_token)
|
20
|
+
Samurai.options = {
|
21
|
+
:merchant_key => options[:login],
|
22
|
+
:merchant_password => options[:password],
|
23
|
+
:processor_token => options[:processor_token]
|
24
|
+
}
|
25
|
+
|
26
|
+
super
|
27
|
+
end
|
28
|
+
|
29
|
+
def authorize(money, credit_card_or_vault_id, options = {})
|
30
|
+
token = payment_method_token(credit_card_or_vault_id, options)
|
31
|
+
return token if token.is_a?(Response)
|
32
|
+
|
33
|
+
authorize = Samurai::Processor.authorize(token, amount(money), processor_options(options))
|
34
|
+
handle_result(authorize)
|
35
|
+
end
|
36
|
+
|
37
|
+
def purchase(money, credit_card_or_vault_id, options = {})
|
38
|
+
token = payment_method_token(credit_card_or_vault_id, options)
|
39
|
+
return token if token.is_a?(Response)
|
40
|
+
|
41
|
+
purchase = Samurai::Processor.purchase(token, amount(money), processor_options(options))
|
42
|
+
handle_result(purchase)
|
43
|
+
end
|
44
|
+
|
45
|
+
def capture(money, authorization_id, options = {})
|
46
|
+
transaction = Samurai::Transaction.find(authorization_id)
|
47
|
+
handle_result(transaction.capture(amount(money)))
|
48
|
+
end
|
49
|
+
|
50
|
+
def refund(money, transaction_id, options = {})
|
51
|
+
transaction = Samurai::Transaction.find(transaction_id)
|
52
|
+
handle_result(transaction.credit(amount(money)))
|
53
|
+
end
|
54
|
+
|
55
|
+
def void(transaction_id, options = {})
|
56
|
+
transaction = Samurai::Transaction.find(transaction_id)
|
57
|
+
handle_result(transaction.void)
|
58
|
+
end
|
59
|
+
|
60
|
+
def store(creditcard, options = {})
|
61
|
+
address = options[:billing_address] || options[:address] || {}
|
62
|
+
|
63
|
+
result = Samurai::PaymentMethod.create({
|
64
|
+
:card_number => creditcard.number,
|
65
|
+
:expiry_month => creditcard.month.to_s.rjust(2, "0"),
|
66
|
+
:expiry_year => creditcard.year.to_s,
|
67
|
+
:cvv => creditcard.verification_value,
|
68
|
+
:first_name => creditcard.first_name,
|
69
|
+
:last_name => creditcard.last_name,
|
70
|
+
:address_1 => address[:address1],
|
71
|
+
:address_2 => address[:address2],
|
72
|
+
:city => address[:city],
|
73
|
+
:zip => address[:zip],
|
74
|
+
:sandbox => test?
|
75
|
+
})
|
76
|
+
result.retain if options[:retain] && result.is_sensitive_data_valid && result.payment_method_token
|
77
|
+
|
78
|
+
Response.new(result.is_sensitive_data_valid,
|
79
|
+
message_from_result(result),
|
80
|
+
{ :payment_method_token => result.is_sensitive_data_valid && result.payment_method_token })
|
81
|
+
end
|
82
|
+
|
83
|
+
private
|
84
|
+
|
85
|
+
def payment_method_token(credit_card_or_vault_id, options)
|
86
|
+
return credit_card_or_vault_id if credit_card_or_vault_id.is_a?(String)
|
87
|
+
store_result = store(credit_card_or_vault_id, options)
|
88
|
+
store_result.success? ? store_result.params["payment_method_token"] : store_result
|
89
|
+
end
|
90
|
+
|
91
|
+
def handle_result(result)
|
92
|
+
response_params, response_options = {}, {}
|
93
|
+
if result.success?
|
94
|
+
response_options[:test] = test?
|
95
|
+
response_options[:authorization] = result.reference_id
|
96
|
+
response_params[:reference_id] = result.reference_id
|
97
|
+
response_params[:transaction_token] = result.transaction_token
|
98
|
+
response_params[:payment_method_token] = result.payment_method.payment_method_token
|
99
|
+
end
|
100
|
+
|
101
|
+
response_options[:avs_result] = { :code => result.processor_response && result.processor_response.avs_result_code }
|
102
|
+
response_options[:cvv_result] = result.processor_response && result.processor_response.cvv_result_code
|
103
|
+
|
104
|
+
message = message_from_result(result)
|
105
|
+
Response.new(result.success?, message, response_params, response_options)
|
106
|
+
end
|
107
|
+
|
108
|
+
def message_from_result(result)
|
109
|
+
return "OK" if result.success?
|
110
|
+
result.errors.map {|_, messages| messages }.join(" ")
|
111
|
+
end
|
112
|
+
|
113
|
+
def processor_options(options)
|
114
|
+
options.slice(:billing_reference, :customer_reference, :custom, :descriptor)
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|