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,165 @@
|
|
1
|
+
module ActiveMerchant #:nodoc:
|
2
|
+
module Billing #:nodoc:
|
3
|
+
class PinGateway < Gateway
|
4
|
+
self.test_url = 'https://test-api.pin.net.au/1'
|
5
|
+
self.live_url = 'https://api.pin.net.au/1'
|
6
|
+
|
7
|
+
self.default_currency = 'AUD'
|
8
|
+
self.money_format = :cents
|
9
|
+
self.supported_countries = ['AU']
|
10
|
+
self.supported_cardtypes = [:visa, :master]
|
11
|
+
self.homepage_url = 'http://www.pin.net.au/'
|
12
|
+
self.display_name = 'Pin'
|
13
|
+
|
14
|
+
def initialize(options = {})
|
15
|
+
requires!(options, :api_key)
|
16
|
+
super
|
17
|
+
end
|
18
|
+
|
19
|
+
# Create a charge using a credit card, card token or customer token
|
20
|
+
#
|
21
|
+
# To charge a credit card: purchase([money], [creditcard hash], ...)
|
22
|
+
# To charge a customer: purchase([money], [token], ...)
|
23
|
+
def purchase(money, creditcard, options = {})
|
24
|
+
post = {}
|
25
|
+
|
26
|
+
add_amount(post, money, options)
|
27
|
+
add_customer_data(post, options)
|
28
|
+
add_invoice(post, options)
|
29
|
+
add_creditcard(post, creditcard)
|
30
|
+
add_address(post, creditcard, options)
|
31
|
+
|
32
|
+
commit('charges', post, options)
|
33
|
+
end
|
34
|
+
|
35
|
+
# Create a customer and associated credit card. The token that is returned
|
36
|
+
# can be used instead of a credit card parameter in the purchase method
|
37
|
+
def store(creditcard, options = {})
|
38
|
+
post = {}
|
39
|
+
|
40
|
+
add_creditcard(post, creditcard)
|
41
|
+
add_customer_data(post, options)
|
42
|
+
add_address(post, creditcard, options)
|
43
|
+
commit('customers', post, options)
|
44
|
+
end
|
45
|
+
|
46
|
+
# Refund a transaction, note that the money attribute is ignored at the
|
47
|
+
# moment as the API does not support partial refunds. The parameter is
|
48
|
+
# kept for compatibility reasons
|
49
|
+
def refund(money, token, options = {})
|
50
|
+
commit("charges/#{CGI.escape(token)}/refunds", { :amount => amount(money) }, options)
|
51
|
+
end
|
52
|
+
|
53
|
+
private
|
54
|
+
def add_amount(post, money, options)
|
55
|
+
post[:amount] = amount(money)
|
56
|
+
post[:currency] = (options[:currency] || currency(money))
|
57
|
+
post[:currency] = post[:currency].upcase if post[:currency]
|
58
|
+
end
|
59
|
+
|
60
|
+
def add_customer_data(post, options)
|
61
|
+
post[:email] = options[:email]
|
62
|
+
post[:ip_address] = options[:ip]
|
63
|
+
end
|
64
|
+
|
65
|
+
def add_address(post, creditcard, options)
|
66
|
+
return if creditcard.kind_of?(String)
|
67
|
+
address = (options[:billing_address] || options[:address])
|
68
|
+
return unless address
|
69
|
+
|
70
|
+
post[:card] ||= {}
|
71
|
+
post[:card].merge!(
|
72
|
+
:address_line1 => address[:address1],
|
73
|
+
:address_city => address[:city],
|
74
|
+
:address_postcode => address[:zip],
|
75
|
+
:address_state => address[:state],
|
76
|
+
:address_country => address[:country]
|
77
|
+
)
|
78
|
+
end
|
79
|
+
|
80
|
+
def add_invoice(post, options)
|
81
|
+
post[:description] = options[:description] || "Active Merchant Purchase"
|
82
|
+
end
|
83
|
+
|
84
|
+
def add_creditcard(post, creditcard)
|
85
|
+
if creditcard.respond_to?(:number)
|
86
|
+
post[:card] ||= {}
|
87
|
+
|
88
|
+
post[:card].merge!(
|
89
|
+
:number => creditcard.number,
|
90
|
+
:expiry_month => creditcard.month,
|
91
|
+
:expiry_year => creditcard.year,
|
92
|
+
:cvc => creditcard.verification_value,
|
93
|
+
:name => "#{creditcard.first_name} #{creditcard.last_name}"
|
94
|
+
)
|
95
|
+
elsif creditcard.kind_of?(String)
|
96
|
+
if creditcard =~ /^card_/
|
97
|
+
post[:card_token] = creditcard
|
98
|
+
else
|
99
|
+
post[:customer_token] = creditcard
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
def headers(params = {})
|
105
|
+
result = {
|
106
|
+
"Content-Type" => "application/json",
|
107
|
+
"Authorization" => "Basic #{Base64.strict_encode64(options[:api_key] + ':').strip}"
|
108
|
+
}
|
109
|
+
|
110
|
+
result['X-Partner-Key'] = params[:partner_key] if params[:partner_key]
|
111
|
+
result['X-Safe-Card'] = params[:safe_card] if params[:safe_card]
|
112
|
+
result
|
113
|
+
end
|
114
|
+
|
115
|
+
def commit(action, params, options)
|
116
|
+
url = "#{test? ? test_url : live_url}/#{action}"
|
117
|
+
|
118
|
+
begin
|
119
|
+
body = parse(ssl_post(url, post_data(params), headers(options)))
|
120
|
+
rescue ResponseError => e
|
121
|
+
body = parse(e.response.body)
|
122
|
+
end
|
123
|
+
|
124
|
+
if body["response"]
|
125
|
+
success_response(body)
|
126
|
+
elsif body["error"]
|
127
|
+
error_response(body)
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
def success_response(body)
|
132
|
+
response = body["response"]
|
133
|
+
Response.new(
|
134
|
+
true,
|
135
|
+
response['status_message'],
|
136
|
+
body,
|
137
|
+
:authorization => token(response),
|
138
|
+
:test => test?
|
139
|
+
)
|
140
|
+
end
|
141
|
+
|
142
|
+
def error_response(body)
|
143
|
+
Response.new(
|
144
|
+
false,
|
145
|
+
body['error_description'],
|
146
|
+
body,
|
147
|
+
:authorization => nil,
|
148
|
+
:test => test?
|
149
|
+
)
|
150
|
+
end
|
151
|
+
|
152
|
+
def token(response)
|
153
|
+
response['token']
|
154
|
+
end
|
155
|
+
|
156
|
+
def parse(body)
|
157
|
+
JSON.parse(body)
|
158
|
+
end
|
159
|
+
|
160
|
+
def post_data(parameters = {})
|
161
|
+
parameters.to_json
|
162
|
+
end
|
163
|
+
end
|
164
|
+
end
|
165
|
+
end
|
@@ -0,0 +1,294 @@
|
|
1
|
+
module ActiveMerchant
|
2
|
+
module Billing
|
3
|
+
class PlugnpayGateway < Gateway
|
4
|
+
class PlugnpayPostData < PostData
|
5
|
+
# Fields that will be sent even if they are blank
|
6
|
+
self.required_fields = [ :publisher_name, :publisher_password,
|
7
|
+
:card_amount, :card_name, :card_number, :card_exp, :orderID ]
|
8
|
+
end
|
9
|
+
self.live_url = self.test_url = 'https://pay1.plugnpay.com/payment/pnpremote.cgi'
|
10
|
+
|
11
|
+
CARD_CODE_MESSAGES = {
|
12
|
+
"M" => "Card verification number matched",
|
13
|
+
"N" => "Card verification number didn't match",
|
14
|
+
"P" => "Card verification number was not processed",
|
15
|
+
"S" => "Card verification number should be on card but was not indicated",
|
16
|
+
"U" => "Issuer was not certified for card verification"
|
17
|
+
}
|
18
|
+
|
19
|
+
CARD_CODE_ERRORS = %w( N S )
|
20
|
+
|
21
|
+
AVS_MESSAGES = {
|
22
|
+
"A" => "Street address matches billing information, zip/postal code does not",
|
23
|
+
"B" => "Address information not provided for address verification check",
|
24
|
+
"E" => "Address verification service error",
|
25
|
+
"G" => "Non-U.S. card-issuing bank",
|
26
|
+
"N" => "Neither street address nor zip/postal match billing information",
|
27
|
+
"P" => "Address verification not applicable for this transaction",
|
28
|
+
"R" => "Payment gateway was unavailable or timed out",
|
29
|
+
"S" => "Address verification service not supported by issuer",
|
30
|
+
"U" => "Address information is unavailable",
|
31
|
+
"W" => "9-digit zip/postal code matches billing information, street address does not",
|
32
|
+
"X" => "Street address and 9-digit zip/postal code matches billing information",
|
33
|
+
"Y" => "Street address and 5-digit zip/postal code matches billing information",
|
34
|
+
"Z" => "5-digit zip/postal code matches billing information, street address does not",
|
35
|
+
}
|
36
|
+
|
37
|
+
AVS_ERRORS = %w( A E N R W Z )
|
38
|
+
|
39
|
+
PAYMENT_GATEWAY_RESPONSES = {
|
40
|
+
"P01" => "AVS Mismatch Failure",
|
41
|
+
"P02" => "CVV2 Mismatch Failure",
|
42
|
+
"P21" => "Transaction may not be marked",
|
43
|
+
"P30" => "Test Tran. Bad Card",
|
44
|
+
"P35" => "Test Tran. Problem",
|
45
|
+
"P40" => "Username already exists",
|
46
|
+
"P41" => "Username is blank",
|
47
|
+
"P50" => "Fraud Screen Failure",
|
48
|
+
"P51" => "Missing PIN Code",
|
49
|
+
"P52" => "Invalid Bank Acct. No.",
|
50
|
+
"P53" => "Invalid Bank Routing No.",
|
51
|
+
"P54" => "Invalid/Missing Check No.",
|
52
|
+
"P55" => "Invalid Credit Card No.",
|
53
|
+
"P56" => "Invalid CVV2/CVC2 No.",
|
54
|
+
"P57" => "Expired. CC Exp. Date",
|
55
|
+
"P58" => "Missing Data",
|
56
|
+
"P59" => "Missing Email Address",
|
57
|
+
"P60" => "Zip Code does not match Billing State.",
|
58
|
+
"P61" => "Invalid Billing Zip Code",
|
59
|
+
"P62" => "Zip Code does not match Shipping State.",
|
60
|
+
"P63" => "Invalid Shipping Zip Code",
|
61
|
+
"P64" => "Invalid Credit Card CVV2/CVC2 Format.",
|
62
|
+
"P65" => "Maximum number of attempts has been exceeded.",
|
63
|
+
"P66" => "Credit Card number has been flagged and can not be used to access this service.",
|
64
|
+
"P67" => "IP Address is on Blocked List.",
|
65
|
+
"P68" => "Billing country does not match ipaddress country.",
|
66
|
+
"P69" => "US based ipaddresses are currently blocked.",
|
67
|
+
"P70" => "Credit Cards issued from this bank are currently not being accepted.",
|
68
|
+
"P71" => "Credit Cards issued from this bank are currently not being accepted.",
|
69
|
+
"P72" => "Daily volume exceeded.",
|
70
|
+
"P73" => "Too many transactions within allotted time.",
|
71
|
+
"P91" => "Missing/incorrect password",
|
72
|
+
"P92" => "Account not configured for mobil administration",
|
73
|
+
"P93" => "IP Not registered to username.",
|
74
|
+
"P94" => "Mode not permitted for this account.",
|
75
|
+
"P95" => "Currently Blank",
|
76
|
+
"P96" => "Currently Blank",
|
77
|
+
"P97" => "Processor not responding",
|
78
|
+
"P98" => "Missing merchant/publisher name",
|
79
|
+
"P99" => "Currently Blank"
|
80
|
+
}
|
81
|
+
|
82
|
+
TRANSACTIONS = {
|
83
|
+
:authorization => 'auth',
|
84
|
+
:purchase => 'auth',
|
85
|
+
:capture => 'mark',
|
86
|
+
:void => 'void',
|
87
|
+
:refund => 'return',
|
88
|
+
:credit => 'newreturn'
|
89
|
+
}
|
90
|
+
|
91
|
+
SUCCESS_CODES = [ 'pending', 'success' ]
|
92
|
+
FAILURE_CODES = [ 'badcard', 'fraud' ]
|
93
|
+
|
94
|
+
self.default_currency = 'USD'
|
95
|
+
self.supported_countries = ['US']
|
96
|
+
self.supported_cardtypes = [:visa, :master, :american_express, :discover]
|
97
|
+
self.homepage_url = 'http://www.plugnpay.com/'
|
98
|
+
self.display_name = "Plug'n Pay"
|
99
|
+
|
100
|
+
def initialize(options = {})
|
101
|
+
requires!(options, :login, :password)
|
102
|
+
super
|
103
|
+
end
|
104
|
+
|
105
|
+
def purchase(money, creditcard, options = {})
|
106
|
+
post = PlugnpayPostData.new
|
107
|
+
|
108
|
+
add_amount(post, money, options)
|
109
|
+
add_creditcard(post, creditcard)
|
110
|
+
add_addresses(post, options)
|
111
|
+
add_invoice_data(post, options)
|
112
|
+
add_customer_data(post, options)
|
113
|
+
|
114
|
+
post[:authtype] = 'authpostauth'
|
115
|
+
commit(:authorization, post)
|
116
|
+
end
|
117
|
+
|
118
|
+
def authorize(money, creditcard, options = {})
|
119
|
+
post = PlugnpayPostData.new
|
120
|
+
|
121
|
+
add_amount(post, money, options)
|
122
|
+
add_creditcard(post, creditcard)
|
123
|
+
add_addresses(post, options)
|
124
|
+
add_invoice_data(post, options)
|
125
|
+
add_customer_data(post, options)
|
126
|
+
|
127
|
+
post[:authtype] = 'authonly'
|
128
|
+
commit(:authorization, post)
|
129
|
+
end
|
130
|
+
|
131
|
+
def capture(money, authorization, options = {})
|
132
|
+
post = PlugnpayPostData.new
|
133
|
+
|
134
|
+
post[:orderID] = authorization
|
135
|
+
|
136
|
+
add_amount(post, money, options)
|
137
|
+
add_customer_data(post, options)
|
138
|
+
|
139
|
+
commit(:capture, post)
|
140
|
+
end
|
141
|
+
|
142
|
+
def void(authorization, options = {})
|
143
|
+
post = PlugnpayPostData.new
|
144
|
+
|
145
|
+
post[:orderID] = authorization
|
146
|
+
post[:txn_type] = 'auth'
|
147
|
+
|
148
|
+
commit(:void, post)
|
149
|
+
end
|
150
|
+
|
151
|
+
def credit(money, identification_or_creditcard, options = {})
|
152
|
+
post = PlugnpayPostData.new
|
153
|
+
add_amount(post, money, options)
|
154
|
+
|
155
|
+
if identification_or_creditcard.is_a?(String)
|
156
|
+
deprecated CREDIT_DEPRECATION_MESSAGE
|
157
|
+
refund(money, identification_or_creditcard, options)
|
158
|
+
else
|
159
|
+
add_creditcard(post, identification_or_creditcard)
|
160
|
+
add_addresses(post, options)
|
161
|
+
add_customer_data(post, options)
|
162
|
+
|
163
|
+
commit(:credit, post)
|
164
|
+
end
|
165
|
+
end
|
166
|
+
|
167
|
+
def refund(money, reference, options = {})
|
168
|
+
post = PlugnpayPostData.new
|
169
|
+
add_amount(post, money, options)
|
170
|
+
post[:orderID] = reference
|
171
|
+
commit(:refund, post)
|
172
|
+
end
|
173
|
+
|
174
|
+
private
|
175
|
+
def commit(action, post)
|
176
|
+
response = parse( ssl_post(self.live_url, post_data(action, post)) )
|
177
|
+
success = SUCCESS_CODES.include?(response[:finalstatus])
|
178
|
+
message = success ? 'Success' : message_from(response)
|
179
|
+
|
180
|
+
Response.new(success, message, response,
|
181
|
+
:test => test?,
|
182
|
+
:authorization => response[:orderid],
|
183
|
+
:avs_result => { :code => response[:avs_code] },
|
184
|
+
:cvv_result => response[:cvvresp]
|
185
|
+
)
|
186
|
+
end
|
187
|
+
|
188
|
+
def parse(body)
|
189
|
+
body = CGI.unescape(body)
|
190
|
+
results = {}
|
191
|
+
body.split('&').collect { |e| e.split('=') }.each do |key,value|
|
192
|
+
results[key.downcase.to_sym] = normalize(value.to_s.strip)
|
193
|
+
end
|
194
|
+
|
195
|
+
results.delete(:publisher_password)
|
196
|
+
results[:avs_message] = AVS_MESSAGES[results[:avs_code]] if results[:avs_code]
|
197
|
+
results[:card_code_message] = CARD_CODE_MESSAGES[results[:cvvresp]] if results[:cvvresp]
|
198
|
+
|
199
|
+
results
|
200
|
+
end
|
201
|
+
|
202
|
+
def post_data(action, post)
|
203
|
+
post[:mode] = TRANSACTIONS[action]
|
204
|
+
post[:convert] = 'underscores'
|
205
|
+
post[:app_level] = 0
|
206
|
+
post[:publisher_name] = @options[:login]
|
207
|
+
post[:publisher_password] = @options[:password]
|
208
|
+
|
209
|
+
post.to_s
|
210
|
+
end
|
211
|
+
|
212
|
+
def add_creditcard(post, creditcard)
|
213
|
+
post[:card_number] = creditcard.number
|
214
|
+
post[:card_cvv] = creditcard.verification_value
|
215
|
+
post[:card_exp] = expdate(creditcard)
|
216
|
+
post[:card_name] = creditcard.name.slice(0..38)
|
217
|
+
end
|
218
|
+
|
219
|
+
def add_customer_data(post, options)
|
220
|
+
post[:email] = options[:email]
|
221
|
+
post[:dontsndmail] = 'yes' unless options[:send_email_confirmation]
|
222
|
+
post[:ipaddress] = options[:ip]
|
223
|
+
end
|
224
|
+
|
225
|
+
def add_invoice_data(post, options)
|
226
|
+
post[:shipping] = amount(options[:shipping]) unless options[:shipping].blank?
|
227
|
+
post[:tax] = amount(options[:tax]) unless options[:tax].blank?
|
228
|
+
end
|
229
|
+
|
230
|
+
def add_addresses(post, options)
|
231
|
+
if address = options[:billing_address] || options[:address]
|
232
|
+
post[:card_address1] = address[:address1]
|
233
|
+
post[:card_zip] = address[:zip]
|
234
|
+
post[:card_city] = address[:city]
|
235
|
+
post[:card_country] = address[:country]
|
236
|
+
post[:phone] = address[:phone]
|
237
|
+
|
238
|
+
case address[:country]
|
239
|
+
when 'US', 'CA'
|
240
|
+
post[:card_state] = address[:state]
|
241
|
+
else
|
242
|
+
post[:card_state] = 'ZZ'
|
243
|
+
post[:card_prov] = address[:state]
|
244
|
+
end
|
245
|
+
end
|
246
|
+
|
247
|
+
if shipping_address = options[:shipping_address] || address
|
248
|
+
post[:shipname] = shipping_address[:name]
|
249
|
+
post[:address1] = shipping_address[:address1]
|
250
|
+
post[:address2] = shipping_address[:address2]
|
251
|
+
post[:city] = shipping_address[:city]
|
252
|
+
|
253
|
+
case shipping_address[:country]
|
254
|
+
when 'US', 'CA'
|
255
|
+
post[:state] = shipping_address[:state]
|
256
|
+
else
|
257
|
+
post[:state] = 'ZZ'
|
258
|
+
post[:province] = shipping_address[:state]
|
259
|
+
end
|
260
|
+
|
261
|
+
post[:country] = shipping_address[:country]
|
262
|
+
post[:zip] = shipping_address[:zip]
|
263
|
+
end
|
264
|
+
end
|
265
|
+
|
266
|
+
def add_amount(post, money, options)
|
267
|
+
post[:card_amount] = amount(money)
|
268
|
+
post[:currency] = options[:currency] || currency(money)
|
269
|
+
end
|
270
|
+
|
271
|
+
# Make a ruby type out of the response string
|
272
|
+
def normalize(field)
|
273
|
+
case field
|
274
|
+
when "true" then true
|
275
|
+
when "false" then false
|
276
|
+
when "" then nil
|
277
|
+
when "null" then nil
|
278
|
+
else field
|
279
|
+
end
|
280
|
+
end
|
281
|
+
|
282
|
+
def message_from(results)
|
283
|
+
PAYMENT_GATEWAY_RESPONSES[results[:resp_code]]
|
284
|
+
end
|
285
|
+
|
286
|
+
def expdate(creditcard)
|
287
|
+
year = sprintf("%.4i", creditcard.year)
|
288
|
+
month = sprintf("%.2i", creditcard.month)
|
289
|
+
|
290
|
+
"#{month}/#{year[-2..-1]}"
|
291
|
+
end
|
292
|
+
end
|
293
|
+
end
|
294
|
+
end
|
@@ -0,0 +1,227 @@
|
|
1
|
+
require 'rexml/document'
|
2
|
+
|
3
|
+
module ActiveMerchant #:nodoc:
|
4
|
+
module Billing #:nodoc:
|
5
|
+
# This class implements the Psigate gateway for the ActiveMerchant module.
|
6
|
+
#
|
7
|
+
# Modifications by Sean O'Hara ( sohara at sohara dot com )
|
8
|
+
#
|
9
|
+
# Usage for a PreAuth (authorize) is as follows:
|
10
|
+
#
|
11
|
+
# gateway = PsigateGateway.new(
|
12
|
+
# :login => 'teststore',
|
13
|
+
# :password => 'psigate1234'
|
14
|
+
# )
|
15
|
+
#
|
16
|
+
# creditcard = CreditCard.new(
|
17
|
+
# :number => '4242424242424242',
|
18
|
+
# :month => 8,
|
19
|
+
# :year => 2006,
|
20
|
+
# :first_name => 'Longbob',
|
21
|
+
# :last_name => 'Longsen'
|
22
|
+
# )
|
23
|
+
#
|
24
|
+
# twenty = 2000
|
25
|
+
# response = @gateway.authorize(twenty, creditcard,
|
26
|
+
# :order_id => 1234,
|
27
|
+
# :billing_address => {
|
28
|
+
# :address1 => '123 fairweather Lane',
|
29
|
+
# :address2 => 'Apt B',
|
30
|
+
# :city => 'New York',
|
31
|
+
# :state => 'NY',
|
32
|
+
# :country => 'U.S.A.',
|
33
|
+
# :zip => '10010'
|
34
|
+
# },
|
35
|
+
# :email => 'jack@yahoo.com'
|
36
|
+
# )
|
37
|
+
class PsigateGateway < Gateway
|
38
|
+
self.test_url = 'https://dev.psigate.com:7989/Messenger/XMLMessenger'
|
39
|
+
self.live_url = 'https://secure.psigate.com:7934/Messenger/XMLMessenger'
|
40
|
+
|
41
|
+
self.supported_cardtypes = [:visa, :master, :american_express]
|
42
|
+
self.supported_countries = ['CA']
|
43
|
+
self.homepage_url = 'http://www.psigate.com/'
|
44
|
+
self.display_name = 'Psigate'
|
45
|
+
|
46
|
+
SUCCESS_MESSAGE = 'Success'
|
47
|
+
FAILURE_MESSAGE = 'The transaction was declined'
|
48
|
+
|
49
|
+
def initialize(options = {})
|
50
|
+
requires!(options, :login, :password)
|
51
|
+
super
|
52
|
+
end
|
53
|
+
|
54
|
+
def authorize(money, creditcard, options = {})
|
55
|
+
requires!(options, :order_id)
|
56
|
+
options[:CardAction] = "1"
|
57
|
+
commit(money, creditcard, options)
|
58
|
+
end
|
59
|
+
|
60
|
+
def purchase(money, creditcard, options = {})
|
61
|
+
requires!(options, :order_id)
|
62
|
+
options[:CardAction] = "0"
|
63
|
+
commit(money, creditcard, options)
|
64
|
+
end
|
65
|
+
|
66
|
+
def capture(money, authorization, options = {})
|
67
|
+
options[:CardAction] = "2"
|
68
|
+
options[:order_id], options[:trans_ref_number] = split_authorization(authorization)
|
69
|
+
commit(money, nil, options)
|
70
|
+
end
|
71
|
+
|
72
|
+
def credit(money, authorization, options = {})
|
73
|
+
deprecated CREDIT_DEPRECATION_MESSAGE
|
74
|
+
refund(money, authorization, options)
|
75
|
+
end
|
76
|
+
|
77
|
+
def refund(money, authorization, options = {})
|
78
|
+
options[:CardAction] = "3"
|
79
|
+
options[:order_id], options[:trans_ref_number] = split_authorization(authorization)
|
80
|
+
commit(money, nil, options)
|
81
|
+
end
|
82
|
+
|
83
|
+
def void(authorization, options = {})
|
84
|
+
options[:CardAction] = "9"
|
85
|
+
options[:order_id], options[:trans_ref_number] = split_authorization(authorization)
|
86
|
+
commit(nil, nil, options)
|
87
|
+
end
|
88
|
+
|
89
|
+
private
|
90
|
+
|
91
|
+
def commit(money, creditcard, options = {})
|
92
|
+
response = parse(ssl_post(url, post_data(money, creditcard, options)))
|
93
|
+
|
94
|
+
Response.new(successful?(response), message_from(response), response,
|
95
|
+
:test => test?,
|
96
|
+
:authorization => build_authorization(response) ,
|
97
|
+
:avs_result => { :code => response[:avsresult] },
|
98
|
+
:cvv_result => response[:cardidresult]
|
99
|
+
)
|
100
|
+
end
|
101
|
+
|
102
|
+
def url
|
103
|
+
(test? ? self.test_url : self.live_url)
|
104
|
+
end
|
105
|
+
|
106
|
+
def successful?(response)
|
107
|
+
response[:approved] == "APPROVED"
|
108
|
+
end
|
109
|
+
|
110
|
+
def parse(xml)
|
111
|
+
response = {:message => "Global Error Receipt", :complete => false}
|
112
|
+
|
113
|
+
xml = REXML::Document.new(xml)
|
114
|
+
xml.elements.each('//Result/*') do |node|
|
115
|
+
response[node.name.downcase.to_sym] = normalize(node.text)
|
116
|
+
end unless xml.root.nil?
|
117
|
+
|
118
|
+
response
|
119
|
+
end
|
120
|
+
|
121
|
+
def post_data(money, creditcard, options)
|
122
|
+
xml = REXML::Document.new
|
123
|
+
xml << REXML::XMLDecl.new
|
124
|
+
root = xml.add_element("Order")
|
125
|
+
|
126
|
+
parameters(money, creditcard, options).each do |key, value|
|
127
|
+
root.add_element(key.to_s).text = value if value
|
128
|
+
end
|
129
|
+
|
130
|
+
xml.to_s
|
131
|
+
end
|
132
|
+
|
133
|
+
def parameters(money, creditcard, options = {})
|
134
|
+
params = {
|
135
|
+
# General order parameters
|
136
|
+
:StoreID => @options[:login],
|
137
|
+
:Passphrase => @options[:password],
|
138
|
+
:TestResult => options[:test_result],
|
139
|
+
:OrderID => options[:order_id],
|
140
|
+
:UserID => options[:user_id],
|
141
|
+
:Phone => options[:phone],
|
142
|
+
:Fax => options[:fax],
|
143
|
+
:Email => options[:email],
|
144
|
+
:TransRefNumber => options[:trans_ref_number],
|
145
|
+
|
146
|
+
# Credit Card parameters
|
147
|
+
:PaymentType => "CC",
|
148
|
+
:CardAction => options[:CardAction],
|
149
|
+
|
150
|
+
# Financial parameters
|
151
|
+
:CustomerIP => options[:ip],
|
152
|
+
:SubTotal => amount(money),
|
153
|
+
:Tax1 => options[:tax1],
|
154
|
+
:Tax2 => options[:tax2],
|
155
|
+
:ShippingTotal => options[:shipping_total],
|
156
|
+
}
|
157
|
+
|
158
|
+
if creditcard
|
159
|
+
exp_month = sprintf("%.2i", creditcard.month) unless creditcard.month.blank?
|
160
|
+
exp_year = creditcard.year.to_s[2,2] unless creditcard.year.blank?
|
161
|
+
card_id_code = (creditcard.verification_value.blank? ? nil : "1")
|
162
|
+
|
163
|
+
params.update(
|
164
|
+
:CardNumber => creditcard.number,
|
165
|
+
:CardExpMonth => exp_month,
|
166
|
+
:CardExpYear => exp_year,
|
167
|
+
:CardIDCode => card_id_code,
|
168
|
+
:CardIDNumber => creditcard.verification_value
|
169
|
+
)
|
170
|
+
end
|
171
|
+
|
172
|
+
if(address = (options[:billing_address] || options[:address]))
|
173
|
+
params[:Bname] = address[:name] || creditcard.name
|
174
|
+
params[:Baddress1] = address[:address1] unless address[:address1].blank?
|
175
|
+
params[:Baddress2] = address[:address2] unless address[:address2].blank?
|
176
|
+
params[:Bcity] = address[:city] unless address[:city].blank?
|
177
|
+
params[:Bprovince] = address[:state] unless address[:state].blank?
|
178
|
+
params[:Bpostalcode] = address[:zip] unless address[:zip].blank?
|
179
|
+
params[:Bcountry] = address[:country] unless address[:country].blank?
|
180
|
+
params[:Bcompany] = address[:company] unless address[:company].blank?
|
181
|
+
end
|
182
|
+
|
183
|
+
if address = options[:shipping_address]
|
184
|
+
params[:Sname] = address[:name] || creditcard.name
|
185
|
+
params[:Saddress1] = address[:address1] unless address[:address1].blank?
|
186
|
+
params[:Saddress2] = address[:address2] unless address[:address2].blank?
|
187
|
+
params[:Scity] = address[:city] unless address[:city].blank?
|
188
|
+
params[:Sprovince] = address[:state] unless address[:state].blank?
|
189
|
+
params[:Spostalcode] = address[:zip] unless address[:zip].blank?
|
190
|
+
params[:Scountry] = address[:country] unless address[:country].blank?
|
191
|
+
params[:Scompany] = address[:company] unless address[:company].blank?
|
192
|
+
end
|
193
|
+
|
194
|
+
params
|
195
|
+
end
|
196
|
+
|
197
|
+
def message_from(response)
|
198
|
+
if response[:approved] == "APPROVED"
|
199
|
+
return SUCCESS_MESSAGE
|
200
|
+
else
|
201
|
+
return FAILURE_MESSAGE if response[:errmsg].blank?
|
202
|
+
return response[:errmsg].gsub(/[^\w]/, ' ').split.join(" ").capitalize
|
203
|
+
end
|
204
|
+
end
|
205
|
+
|
206
|
+
# Make a ruby type out of the response string
|
207
|
+
def normalize(field)
|
208
|
+
case field
|
209
|
+
when "true" then true
|
210
|
+
when "false" then false
|
211
|
+
when "" then nil
|
212
|
+
when "null" then nil
|
213
|
+
else field
|
214
|
+
end
|
215
|
+
end
|
216
|
+
|
217
|
+
def split_authorization(authorization)
|
218
|
+
order_id, trans_ref_number = authorization.split(';')
|
219
|
+
[order_id, trans_ref_number]
|
220
|
+
end
|
221
|
+
|
222
|
+
def build_authorization(response)
|
223
|
+
[response[:orderid], response[:transrefnumber]].join(";")
|
224
|
+
end
|
225
|
+
end
|
226
|
+
end
|
227
|
+
end
|