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,316 @@
|
|
1
|
+
require 'active_support/core_ext/hash/slice'
|
2
|
+
|
3
|
+
module ActiveMerchant #:nodoc:
|
4
|
+
module Billing #:nodoc:
|
5
|
+
class StripeGateway < Gateway
|
6
|
+
self.live_url = 'https://api.stripe.com/v1/'
|
7
|
+
|
8
|
+
AVS_CODE_TRANSLATOR = {
|
9
|
+
'line1: pass, zip: pass' => 'Y',
|
10
|
+
'line1: pass, zip: fail' => 'A',
|
11
|
+
'line1: pass, zip: unchecked' => 'B',
|
12
|
+
'line1: fail, zip: pass' => 'Z',
|
13
|
+
'line1: fail, zip: fail' => 'N',
|
14
|
+
'line1: unchecked, zip: pass' => 'P',
|
15
|
+
'line1: unchecked, zip: unchecked' => 'I'
|
16
|
+
}
|
17
|
+
|
18
|
+
CVC_CODE_TRANSLATOR = {
|
19
|
+
'pass' => 'M',
|
20
|
+
'fail' => 'N',
|
21
|
+
'unchecked' => 'P'
|
22
|
+
}
|
23
|
+
|
24
|
+
self.supported_countries = ['US', 'CA']
|
25
|
+
self.default_currency = 'USD'
|
26
|
+
self.money_format = :cents
|
27
|
+
self.supported_cardtypes = [:visa, :master, :american_express, :discover, :jcb, :diners_club]
|
28
|
+
|
29
|
+
self.homepage_url = 'https://stripe.com/'
|
30
|
+
self.display_name = 'Stripe'
|
31
|
+
|
32
|
+
def initialize(options = {})
|
33
|
+
requires!(options, :login)
|
34
|
+
@api_key = options[:login]
|
35
|
+
@fee_refund_api_key = options[:fee_refund_login]
|
36
|
+
super
|
37
|
+
end
|
38
|
+
|
39
|
+
def authorize(money, creditcard, options = {})
|
40
|
+
post = create_post_for_auth_or_purchase(money, creditcard, options)
|
41
|
+
post[:capture] = "false"
|
42
|
+
|
43
|
+
commit(:post, 'charges', post, generate_meta(options), creditcard)
|
44
|
+
end
|
45
|
+
|
46
|
+
# To create a charge on a card or a token, call
|
47
|
+
#
|
48
|
+
# purchase(money, card_hash_or_token, { ... })
|
49
|
+
#
|
50
|
+
# To create a charge on a customer, call
|
51
|
+
#
|
52
|
+
# purchase(money, nil, { :customer => id, ... })
|
53
|
+
def purchase(money, creditcard, options = {})
|
54
|
+
post = create_post_for_auth_or_purchase(money, creditcard, options)
|
55
|
+
|
56
|
+
commit(:post, 'charges', post, generate_meta(options), creditcard)
|
57
|
+
end
|
58
|
+
|
59
|
+
def capture(money, authorization, options = {})
|
60
|
+
post = {:amount => amount(money)}
|
61
|
+
add_application_fee(post, nil, options)
|
62
|
+
|
63
|
+
commit(:post, "charges/#{CGI.escape(authorization)}/capture", post)
|
64
|
+
end
|
65
|
+
|
66
|
+
def void(identification, options = {})
|
67
|
+
commit(:post, "charges/#{CGI.escape(identification)}/refund", {})
|
68
|
+
end
|
69
|
+
|
70
|
+
def refund(money, identification, options = {})
|
71
|
+
post = {:amount => amount(money)}
|
72
|
+
commit_options = generate_meta(options)
|
73
|
+
|
74
|
+
MultiResponse.run do |r|
|
75
|
+
r.process { commit(:post, "charges/#{CGI.escape(identification)}/refund", post, commit_options) }
|
76
|
+
|
77
|
+
return r unless options[:refund_fee_amount]
|
78
|
+
|
79
|
+
r.process { fetch_application_fees(identification, commit_options) }
|
80
|
+
r.process { refund_application_fee(options[:refund_fee_amount], application_fee_from_response(r), commit_options) }
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
def application_fee_from_response(response)
|
85
|
+
return unless response.success?
|
86
|
+
|
87
|
+
application_fees = response.params["data"].select { |fee| fee["object"] == "application_fee" }
|
88
|
+
application_fees.first["id"] unless application_fees.empty?
|
89
|
+
end
|
90
|
+
|
91
|
+
def refund_application_fee(money, identification, options = {})
|
92
|
+
return Response.new(false, "Application fee id could not be found") unless identification
|
93
|
+
|
94
|
+
post = {:amount => amount(money)}
|
95
|
+
options.merge!(:key => @fee_refund_api_key)
|
96
|
+
|
97
|
+
commit(:post, "application_fees/#{CGI.escape(identification)}/refund", post, options)
|
98
|
+
end
|
99
|
+
|
100
|
+
def store(creditcard, options = {})
|
101
|
+
post = {}
|
102
|
+
add_creditcard(post, creditcard, options)
|
103
|
+
post[:description] = options[:description]
|
104
|
+
post[:email] = options[:email]
|
105
|
+
|
106
|
+
path = if options[:customer]
|
107
|
+
"customers/#{CGI.escape(options[:customer])}"
|
108
|
+
else
|
109
|
+
'customers'
|
110
|
+
end
|
111
|
+
|
112
|
+
commit(:post, path, post, generate_meta(options))
|
113
|
+
end
|
114
|
+
|
115
|
+
def update(customer_id, creditcard, options = {})
|
116
|
+
options = options.merge(:customer => customer_id)
|
117
|
+
store(creditcard, options)
|
118
|
+
end
|
119
|
+
|
120
|
+
def unstore(customer_id, options = {})
|
121
|
+
commit(:delete, "customers/#{CGI.escape(customer_id)}", nil, generate_meta(options))
|
122
|
+
end
|
123
|
+
|
124
|
+
private
|
125
|
+
|
126
|
+
def create_post_for_auth_or_purchase(money, creditcard, options)
|
127
|
+
post = {}
|
128
|
+
add_amount(post, money, options)
|
129
|
+
add_creditcard(post, creditcard, options)
|
130
|
+
add_customer(post, options)
|
131
|
+
add_customer_data(post,options)
|
132
|
+
post[:description] = options[:description] || options[:email]
|
133
|
+
add_flags(post, options)
|
134
|
+
add_application_fee(post, creditcard, options)
|
135
|
+
post
|
136
|
+
end
|
137
|
+
|
138
|
+
def add_amount(post, money, options)
|
139
|
+
post[:amount] = amount(money)
|
140
|
+
post[:currency] = (options[:currency] || currency(money)).downcase
|
141
|
+
end
|
142
|
+
|
143
|
+
def add_application_fee(post, creditcard, options)
|
144
|
+
return unless options[:application_fee]
|
145
|
+
if use_card_not_present_fee?(creditcard, options)
|
146
|
+
post[:application_fee] = options[:card_not_present_fee]
|
147
|
+
else
|
148
|
+
post[:application_fee] = options[:application_fee]
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
def use_card_not_present_fee?(creditcard, options)
|
153
|
+
options[:card_not_present_fee].present? && !includes_track_data?(creditcard, options)
|
154
|
+
end
|
155
|
+
|
156
|
+
def includes_track_data?(creditcard, options)
|
157
|
+
if creditcard.respond_to?(:track_data)
|
158
|
+
creditcard.track_data.present?
|
159
|
+
else
|
160
|
+
options[:track_data].present?
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
def add_customer_data(post, options)
|
165
|
+
metadata_options = [:description,:browser_ip,:user_agent,:referrer]
|
166
|
+
post.update(options.slice(*metadata_options))
|
167
|
+
|
168
|
+
post[:external_id] = options[:order_id]
|
169
|
+
post[:payment_user_agent] = "Stripe/v1 ActiveMerchantBindings/#{ActiveMerchant::VERSION}"
|
170
|
+
end
|
171
|
+
|
172
|
+
def add_address(post, options)
|
173
|
+
return unless post[:card] && post[:card].kind_of?(Hash)
|
174
|
+
if address = options[:billing_address] || options[:address]
|
175
|
+
post[:card][:address_line1] = address[:address1] if address[:address1]
|
176
|
+
post[:card][:address_line2] = address[:address2] if address[:address2]
|
177
|
+
post[:card][:address_country] = address[:country] if address[:country]
|
178
|
+
post[:card][:address_zip] = address[:zip] if address[:zip]
|
179
|
+
post[:card][:address_state] = address[:state] if address[:state]
|
180
|
+
post[:card][:address_city] = address[:city] if address[:city]
|
181
|
+
end
|
182
|
+
end
|
183
|
+
|
184
|
+
def add_creditcard(post, creditcard, options)
|
185
|
+
card = {}
|
186
|
+
if creditcard.respond_to?(:number)
|
187
|
+
if creditcard.respond_to?(:track_data) && creditcard.track_data.present?
|
188
|
+
card[:swipe_data] = creditcard.track_data
|
189
|
+
else
|
190
|
+
card[:number] = creditcard.number
|
191
|
+
card[:exp_month] = creditcard.month
|
192
|
+
card[:exp_year] = creditcard.year
|
193
|
+
card[:cvc] = creditcard.verification_value if creditcard.verification_value?
|
194
|
+
card[:name] = creditcard.name if creditcard.name
|
195
|
+
end
|
196
|
+
|
197
|
+
post[:card] = card
|
198
|
+
add_address(post, options)
|
199
|
+
elsif creditcard.kind_of?(String)
|
200
|
+
if options[:track_data]
|
201
|
+
card[:swipe_data] = options[:track_data]
|
202
|
+
else
|
203
|
+
card[:number] = creditcard
|
204
|
+
end
|
205
|
+
post[:card] = card
|
206
|
+
end
|
207
|
+
end
|
208
|
+
|
209
|
+
def add_customer(post, options)
|
210
|
+
post[:customer] = options[:customer] if options[:customer] && !post[:card]
|
211
|
+
end
|
212
|
+
|
213
|
+
def add_flags(post, options)
|
214
|
+
post[:uncaptured] = true if options[:uncaptured]
|
215
|
+
end
|
216
|
+
|
217
|
+
def fetch_application_fees(identification, options = {})
|
218
|
+
options.merge!(:key => @fee_refund_api_key)
|
219
|
+
|
220
|
+
commit(:get, "application_fees?charge=#{identification}", nil, options)
|
221
|
+
end
|
222
|
+
|
223
|
+
def parse(body)
|
224
|
+
JSON.parse(body)
|
225
|
+
end
|
226
|
+
|
227
|
+
def post_data(params)
|
228
|
+
return nil unless params
|
229
|
+
|
230
|
+
params.map do |key, value|
|
231
|
+
next if value.blank?
|
232
|
+
if value.is_a?(Hash)
|
233
|
+
h = {}
|
234
|
+
value.each do |k, v|
|
235
|
+
h["#{key}[#{k}]"] = v unless v.blank?
|
236
|
+
end
|
237
|
+
post_data(h)
|
238
|
+
else
|
239
|
+
"#{key}=#{CGI.escape(value.to_s)}"
|
240
|
+
end
|
241
|
+
end.compact.join("&")
|
242
|
+
end
|
243
|
+
|
244
|
+
def generate_meta(options)
|
245
|
+
{:meta => {:ip => options[:ip]}}
|
246
|
+
end
|
247
|
+
|
248
|
+
def headers(options = {})
|
249
|
+
@@ua ||= JSON.dump({
|
250
|
+
:bindings_version => ActiveMerchant::VERSION,
|
251
|
+
:lang => 'ruby',
|
252
|
+
:lang_version => "#{RUBY_VERSION} p#{RUBY_PATCHLEVEL} (#{RUBY_RELEASE_DATE})",
|
253
|
+
:platform => RUBY_PLATFORM,
|
254
|
+
:publisher => 'active_merchant',
|
255
|
+
:uname => (RUBY_PLATFORM =~ /linux|darwin/i ? `uname -a 2>/dev/null`.strip : nil)
|
256
|
+
})
|
257
|
+
|
258
|
+
key = options[:key] || @api_key
|
259
|
+
|
260
|
+
{
|
261
|
+
"Authorization" => "Basic " + Base64.encode64(key.to_s + ":").strip,
|
262
|
+
"User-Agent" => "Stripe/v1 ActiveMerchantBindings/#{ActiveMerchant::VERSION}",
|
263
|
+
"X-Stripe-Client-User-Agent" => @@ua,
|
264
|
+
"X-Stripe-Client-User-Metadata" => options[:meta].to_json
|
265
|
+
}
|
266
|
+
end
|
267
|
+
|
268
|
+
def commit(method, url, parameters=nil, options = {}, creditcard = nil)
|
269
|
+
raw_response = response = nil
|
270
|
+
success = false
|
271
|
+
begin
|
272
|
+
raw_response = ssl_request(method, self.live_url + url, post_data(parameters), headers(options))
|
273
|
+
response = parse(raw_response)
|
274
|
+
success = !response.key?("error")
|
275
|
+
rescue ResponseError => e
|
276
|
+
raw_response = e.response.body
|
277
|
+
response = response_error(raw_response)
|
278
|
+
rescue JSON::ParserError
|
279
|
+
response = json_error(raw_response)
|
280
|
+
end
|
281
|
+
|
282
|
+
response[:card_present] = includes_track_data?(creditcard, options)
|
283
|
+
|
284
|
+
card = response["card"] || response["active_card"] || {}
|
285
|
+
avs_code = AVS_CODE_TRANSLATOR["line1: #{card["address_line1_check"]}, zip: #{card["address_zip_check"]}"]
|
286
|
+
cvc_code = CVC_CODE_TRANSLATOR[card["cvc_check"]]
|
287
|
+
Response.new(success,
|
288
|
+
success ? "Transaction approved" : response["error"]["message"],
|
289
|
+
response,
|
290
|
+
:test => response.has_key?("livemode") ? !response["livemode"] : false,
|
291
|
+
:authorization => response["id"],
|
292
|
+
:avs_result => { :code => avs_code },
|
293
|
+
:cvv_result => cvc_code
|
294
|
+
)
|
295
|
+
end
|
296
|
+
|
297
|
+
def response_error(raw_response)
|
298
|
+
begin
|
299
|
+
parse(raw_response)
|
300
|
+
rescue JSON::ParserError
|
301
|
+
json_error(raw_response)
|
302
|
+
end
|
303
|
+
end
|
304
|
+
|
305
|
+
def json_error(raw_response)
|
306
|
+
msg = 'Invalid response received from the Stripe API. Please contact support@stripe.com if you continue to receive this message.'
|
307
|
+
msg += " (The raw response returned by the API was #{raw_response.inspect})"
|
308
|
+
{
|
309
|
+
"error" => {
|
310
|
+
"message" => msg
|
311
|
+
}
|
312
|
+
}
|
313
|
+
end
|
314
|
+
end
|
315
|
+
end
|
316
|
+
end
|
@@ -0,0 +1,126 @@
|
|
1
|
+
module ActiveMerchant #:nodoc:
|
2
|
+
module Billing #:nodoc:
|
3
|
+
class TransFirstGateway < Gateway
|
4
|
+
self.live_url = self.test_url = 'https://webservices.primerchants.com/creditcard.asmx/CCSale'
|
5
|
+
|
6
|
+
self.supported_countries = ['US']
|
7
|
+
self.supported_cardtypes = [:visa, :master, :american_express, :discover]
|
8
|
+
self.homepage_url = 'http://www.transfirst.com/'
|
9
|
+
self.display_name = 'TransFirst'
|
10
|
+
|
11
|
+
UNUSED_FIELDS = %w(ECIValue UserId CAVVData TrackData POSInd EComInd MerchZIP MerchCustPNum MCC InstallmentNum InstallmentOf POSEntryMode POSConditionCode AuthCharInd CardCertData)
|
12
|
+
|
13
|
+
DECLINED = 'The transaction was declined'
|
14
|
+
|
15
|
+
def initialize(options = {})
|
16
|
+
requires!(options, :login, :password)
|
17
|
+
super
|
18
|
+
end
|
19
|
+
|
20
|
+
def purchase(money, credit_card, options = {})
|
21
|
+
post = {}
|
22
|
+
|
23
|
+
add_amount(post, money)
|
24
|
+
add_invoice(post, options)
|
25
|
+
add_credit_card(post, credit_card)
|
26
|
+
add_address(post, options)
|
27
|
+
|
28
|
+
commit(post)
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
def add_amount(post, money)
|
33
|
+
add_pair(post, :Amount, amount(money), :required => true)
|
34
|
+
end
|
35
|
+
|
36
|
+
def add_address(post, options)
|
37
|
+
address = options[:billing_address] || options[:address]
|
38
|
+
|
39
|
+
if address
|
40
|
+
add_pair(post, :Address, address[:address1])
|
41
|
+
add_pair(post, :ZipCode, address[:zip])
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def add_invoice(post, options)
|
46
|
+
add_pair(post, :RefID, options[:order_id], :required => true)
|
47
|
+
add_pair(post, :PONumber, options[:invoice], :required => true)
|
48
|
+
add_pair(post, :SaleTaxAmount, amount(options[:tax] || 0))
|
49
|
+
add_pair(post, :PaymentDesc, options[:description], :required => true)
|
50
|
+
add_pair(post, :TaxIndicator, 0)
|
51
|
+
end
|
52
|
+
|
53
|
+
def add_credit_card(post, credit_card)
|
54
|
+
add_pair(post, :CardHolderName, credit_card.name, :required => true)
|
55
|
+
add_pair(post, :CardNumber, credit_card.number, :required => true)
|
56
|
+
|
57
|
+
add_pair(post, :Expiration, expdate(credit_card), :required => true)
|
58
|
+
add_pair(post, :CVV2, credit_card.verification_value)
|
59
|
+
end
|
60
|
+
|
61
|
+
def add_unused_fields(post)
|
62
|
+
UNUSED_FIELDS.each do |f|
|
63
|
+
post[f] = ""
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def expdate(credit_card)
|
68
|
+
year = format(credit_card.year, :two_digits)
|
69
|
+
month = format(credit_card.month, :two_digits)
|
70
|
+
|
71
|
+
"#{month}#{year}"
|
72
|
+
end
|
73
|
+
|
74
|
+
def parse(data)
|
75
|
+
response = {}
|
76
|
+
|
77
|
+
xml = REXML::Document.new(data)
|
78
|
+
root = REXML::XPath.first(xml, "//CCSaleDebitResponse")
|
79
|
+
|
80
|
+
if root.nil?
|
81
|
+
response[:message] = data.to_s.strip
|
82
|
+
else
|
83
|
+
root.elements.to_a.each do |node|
|
84
|
+
response[node.name.underscore.to_sym] = node.text
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
response
|
89
|
+
end
|
90
|
+
|
91
|
+
def commit(params)
|
92
|
+
response = parse( ssl_post(self.live_url, post_data(params)) )
|
93
|
+
|
94
|
+
Response.new(response[:status] == "Authorized", message_from(response), response,
|
95
|
+
:test => test?,
|
96
|
+
:authorization => response[:trans_id],
|
97
|
+
:avs_result => { :code => response[:avs_code] },
|
98
|
+
:cvv_result => response[:cvv2_code]
|
99
|
+
)
|
100
|
+
end
|
101
|
+
|
102
|
+
def message_from(response)
|
103
|
+
case response[:message]
|
104
|
+
when 'Call Voice Center'
|
105
|
+
DECLINED
|
106
|
+
else
|
107
|
+
response[:message]
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
def post_data(params = {})
|
112
|
+
add_unused_fields(params)
|
113
|
+
params[:MerchantID] = @options[:login]
|
114
|
+
params[:RegKey] = @options[:password]
|
115
|
+
|
116
|
+
request = params.collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join("&")
|
117
|
+
request
|
118
|
+
end
|
119
|
+
|
120
|
+
def add_pair(post, key, value, options = {})
|
121
|
+
post[key] = value if !value.blank? || options[:required]
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__),'smart_ps.rb')
|
2
|
+
|
3
|
+
module ActiveMerchant #:nodoc:
|
4
|
+
module Billing #:nodoc:
|
5
|
+
class TransaxGateway < SmartPs
|
6
|
+
self.live_url = self.test_url = 'https://secure.nelixtransax.net/api/transact.php'
|
7
|
+
|
8
|
+
# The countries the gateway supports merchants from as 2 digit ISO country codes
|
9
|
+
self.supported_countries = ['US']
|
10
|
+
|
11
|
+
# The card types supported by the payment gateway
|
12
|
+
self.supported_cardtypes = [:visa, :master, :american_express, :discover]
|
13
|
+
|
14
|
+
# The homepage URL of the gateway
|
15
|
+
self.homepage_url = 'https://www.nelixtransax.com/'
|
16
|
+
|
17
|
+
# The name of the gateway
|
18
|
+
self.display_name = 'NELiX TransaX'
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
@@ -0,0 +1,239 @@
|
|
1
|
+
module ActiveMerchant #:nodoc:
|
2
|
+
module Billing #:nodoc:
|
3
|
+
class TransnationalGateway < Gateway
|
4
|
+
self.live_url = self.test_url = 'https://secure.networkmerchants.com/api/transact.php'
|
5
|
+
|
6
|
+
self.supported_countries = ['US']
|
7
|
+
self.supported_cardtypes = [:visa, :master, :american_express, :discover]
|
8
|
+
|
9
|
+
self.homepage_url = 'http://www.tnbci.com/'
|
10
|
+
self.display_name = 'Transnational'
|
11
|
+
|
12
|
+
self.money_format = :dollars
|
13
|
+
self.default_currency = 'USD'
|
14
|
+
|
15
|
+
def initialize(options = {})
|
16
|
+
requires!(options, :login, :password)
|
17
|
+
super
|
18
|
+
end
|
19
|
+
|
20
|
+
def authorize(money, creditcard_or_vault_id, options = {})
|
21
|
+
post = build_auth_post(money, creditcard_or_vault_id, options)
|
22
|
+
commit('auth', post)
|
23
|
+
end
|
24
|
+
|
25
|
+
def purchase(money, creditcard_or_vault_id, options = {})
|
26
|
+
post = build_purchase_post(money, creditcard_or_vault_id, options)
|
27
|
+
commit('sale', post)
|
28
|
+
end
|
29
|
+
|
30
|
+
def capture(money, authorization, options = {})
|
31
|
+
post = build_capture_post(money, authorization, options)
|
32
|
+
commit('capture', post)
|
33
|
+
end
|
34
|
+
|
35
|
+
def void(authorization, options = {})
|
36
|
+
post = build_void_post(authorization, options)
|
37
|
+
commit('void', post)
|
38
|
+
end
|
39
|
+
|
40
|
+
def refund(money, authorization, options = {})
|
41
|
+
post = build_refund_post(money, authorization, options)
|
42
|
+
commit('refund', post)
|
43
|
+
end
|
44
|
+
|
45
|
+
def store(creditcard, options = {})
|
46
|
+
post = build_store_post(creditcard, options)
|
47
|
+
commit_vault('add_customer', post)
|
48
|
+
end
|
49
|
+
|
50
|
+
def unstore(customer_vault_id, options = {})
|
51
|
+
post = build_unstore_post(customer_vault_id, options)
|
52
|
+
commit_vault('delete_customer', post)
|
53
|
+
end
|
54
|
+
|
55
|
+
private
|
56
|
+
|
57
|
+
def build_auth_post(money, creditcard_or_vault_id, options)
|
58
|
+
post = {}
|
59
|
+
add_order(post, options)
|
60
|
+
add_address(post, options)
|
61
|
+
add_shipping_address(post, options)
|
62
|
+
add_payment_method(post, creditcard_or_vault_id, options)
|
63
|
+
add_amount(post, money)
|
64
|
+
post
|
65
|
+
end
|
66
|
+
|
67
|
+
def build_purchase_post(money, creditcard, options)
|
68
|
+
build_auth_post(money, creditcard, options)
|
69
|
+
end
|
70
|
+
|
71
|
+
def build_capture_post(money, authorization, option)
|
72
|
+
post = {}
|
73
|
+
post[:transactionid] = authorization
|
74
|
+
add_amount(post, money)
|
75
|
+
post
|
76
|
+
end
|
77
|
+
|
78
|
+
def build_void_post(authorization, options)
|
79
|
+
post = {}
|
80
|
+
post[:transactionid] = authorization
|
81
|
+
post
|
82
|
+
end
|
83
|
+
|
84
|
+
def build_refund_post(money, authorization, options)
|
85
|
+
post = {}
|
86
|
+
post[:transactionid] = authorization
|
87
|
+
add_amount(post, money)
|
88
|
+
post
|
89
|
+
end
|
90
|
+
|
91
|
+
def build_store_post(creditcard_or_check, options)
|
92
|
+
post = {}
|
93
|
+
add_address(post, options)
|
94
|
+
add_shipping_address(post, options)
|
95
|
+
add_payment_method(post, creditcard_or_check, options)
|
96
|
+
post
|
97
|
+
end
|
98
|
+
|
99
|
+
def build_unstore_post(customer_vault_id, options)
|
100
|
+
post = {}
|
101
|
+
post['customer_vault_id'] = customer_vault_id
|
102
|
+
post
|
103
|
+
end
|
104
|
+
|
105
|
+
def add_order(post, options)
|
106
|
+
post[:orderid] = options[:order_id]
|
107
|
+
post[:orderdescription] = options[:description]
|
108
|
+
end
|
109
|
+
|
110
|
+
def add_address(post, options)
|
111
|
+
post[:email] = options[:email]
|
112
|
+
post[:ipaddress] = options[:ip]
|
113
|
+
|
114
|
+
address = options[:billing_address] || options[:address] || {}
|
115
|
+
post[:address1] = address[:address1]
|
116
|
+
post[:address2] = address[:address2]
|
117
|
+
post[:city] = address[:city]
|
118
|
+
post[:state] = address[:state]
|
119
|
+
post[:zip] = address[:zip]
|
120
|
+
post[:country] = address[:country]
|
121
|
+
post[:phone] = address[:phone]
|
122
|
+
end
|
123
|
+
|
124
|
+
def add_shipping_address(post, options)
|
125
|
+
shipping_address = options[:shipping_address] || {}
|
126
|
+
post[:shipping_address1] = shipping_address[:address1]
|
127
|
+
post[:shipping_address2] = shipping_address[:address2]
|
128
|
+
post[:shipping_city] = shipping_address[:city]
|
129
|
+
post[:shipping_state] = shipping_address[:state]
|
130
|
+
post[:shipping_zip] = shipping_address[:zip]
|
131
|
+
post[:shipping_country] = shipping_address[:country]
|
132
|
+
end
|
133
|
+
|
134
|
+
def add_swipe_data(post, options)
|
135
|
+
# unencrypted tracks
|
136
|
+
post[:track_1] = options[:track_1]
|
137
|
+
post[:track_2] = options[:track_2]
|
138
|
+
post[:track_3] = options[:track_3]
|
139
|
+
|
140
|
+
# encrypted tracks
|
141
|
+
post[:magnesafe_track_1] = options[:magnesafe_track_1]
|
142
|
+
post[:magnesafe_track_2] = options[:magnesafe_track_2]
|
143
|
+
post[:magnesafe_track_3] = options[:magnesafe_track_3]
|
144
|
+
post[:magnesafe_magneprint] = options[:magnesafe_magneprint]
|
145
|
+
post[:magnesafe_ksn] = options[:magnesafe_ksn]
|
146
|
+
post[:magnesafe_magneprint_status] = options[:magnesafe_magneprint_status]
|
147
|
+
end
|
148
|
+
|
149
|
+
def add_payment_method(post, creditcard_or_check_or_vault_id, options)
|
150
|
+
post[:processor_id] = options[:processor_id]
|
151
|
+
post[:customer_vault] = 'add_customer' if options[:store]
|
152
|
+
|
153
|
+
add_swipe_data(post, options)
|
154
|
+
|
155
|
+
# creditcard_or_check can be blank if using swipe data
|
156
|
+
if creditcard_or_check_or_vault_id.is_a?(CreditCard) # creditcard or check
|
157
|
+
creditcard = creditcard_or_check_or_vault_id
|
158
|
+
post[:firstname] = creditcard.first_name
|
159
|
+
post[:lastname] = creditcard.last_name
|
160
|
+
post[:ccnumber] = creditcard.number
|
161
|
+
post[:ccexp] = format(creditcard.month, :two_digits) + format(creditcard.year, :two_digits)
|
162
|
+
post[:cvv] = creditcard.verification_value
|
163
|
+
post[:payment] = 'creditcard'
|
164
|
+
elsif creditcard_or_check_or_vault_id.is_a?(Check)
|
165
|
+
check = creditcard_or_check_or_vault_id
|
166
|
+
post[:firstname] = check.first_name
|
167
|
+
post[:lastname] = check.last_name
|
168
|
+
post[:checkname] = check.name
|
169
|
+
post[:checkaba] = check.routing_number
|
170
|
+
post[:checkaccount] = check.account_number
|
171
|
+
post[:account_type] = check.account_type
|
172
|
+
post[:account_holder_type] = check.account_holder_type
|
173
|
+
post[:payment] = 'check'
|
174
|
+
else
|
175
|
+
post[:customer_vault_id] = creditcard_or_check_or_vault_id
|
176
|
+
end
|
177
|
+
end
|
178
|
+
|
179
|
+
def add_login(post)
|
180
|
+
post[:username] = @options[:login]
|
181
|
+
post[:password] = @options[:password]
|
182
|
+
end
|
183
|
+
|
184
|
+
def add_amount(post, money)
|
185
|
+
post[:currency] = options[:currency] || currency(money)
|
186
|
+
post[:amount] = amount(money)
|
187
|
+
end
|
188
|
+
|
189
|
+
def commit_vault(action, parameters)
|
190
|
+
commit(nil, parameters.merge(:customer_vault => action))
|
191
|
+
end
|
192
|
+
|
193
|
+
def commit(action, parameters)
|
194
|
+
raw = parse(ssl_post(self.live_url, build_request(action, parameters)))
|
195
|
+
|
196
|
+
success = (raw['response'] == ResponseCodes::APPROVED)
|
197
|
+
|
198
|
+
authorization = authorization_from(success, parameters, raw)
|
199
|
+
|
200
|
+
Response.new(success, raw['responsetext'], raw,
|
201
|
+
:test => test?,
|
202
|
+
:authorization => authorization,
|
203
|
+
:avs_result => { :code => raw['avsresponse']},
|
204
|
+
:cvv_result => raw['cvvresponse']
|
205
|
+
)
|
206
|
+
end
|
207
|
+
|
208
|
+
def build_request(action, parameters)
|
209
|
+
parameters[:type] = action if action
|
210
|
+
add_login(parameters)
|
211
|
+
parameters.to_query
|
212
|
+
end
|
213
|
+
|
214
|
+
def authorization_from(success, parameters, response)
|
215
|
+
return nil unless success
|
216
|
+
|
217
|
+
authorization = response['transactionid']
|
218
|
+
if(parameters[:customer_vault] && (authorization.nil? || authorization.empty?))
|
219
|
+
authorization = response['customer_vault_id']
|
220
|
+
end
|
221
|
+
|
222
|
+
authorization
|
223
|
+
end
|
224
|
+
|
225
|
+
class ResponseCodes
|
226
|
+
APPROVED = '1'
|
227
|
+
DENIED = '2'
|
228
|
+
ERROR = '3'
|
229
|
+
end
|
230
|
+
|
231
|
+
def parse(raw_response)
|
232
|
+
rsp = CGI.parse(raw_response)
|
233
|
+
rsp.keys.each { |k| rsp[k] = rsp[k].first } # flatten out the values
|
234
|
+
rsp
|
235
|
+
end
|
236
|
+
end
|
237
|
+
end
|
238
|
+
end
|
239
|
+
|