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,313 @@
|
|
1
|
+
require 'base64'
|
2
|
+
|
3
|
+
module ActiveMerchant #:nodoc:
|
4
|
+
module Billing #:nodoc:
|
5
|
+
class WirecardGateway < Gateway
|
6
|
+
# Test server location
|
7
|
+
self.test_url = 'https://c3-test.wirecard.com/secure/ssl-gateway'
|
8
|
+
|
9
|
+
# Live server location
|
10
|
+
self.live_url = 'https://c3.wirecard.com/secure/ssl-gateway'
|
11
|
+
|
12
|
+
# The Namespaces are not really needed, because it just tells the System, that there's actually no namespace used.
|
13
|
+
# It's just specified here for completeness.
|
14
|
+
ENVELOPE_NAMESPACES = {
|
15
|
+
'xmlns:xsi' => 'http://www.w3.org/1999/XMLSchema-instance',
|
16
|
+
'xsi:noNamespaceSchemaLocation' => 'wirecard.xsd'
|
17
|
+
}
|
18
|
+
|
19
|
+
PERMITTED_TRANSACTIONS = %w[ PREAUTHORIZATION CAPTURE PURCHASE ]
|
20
|
+
|
21
|
+
RETURN_CODES = %w[ ACK NOK ]
|
22
|
+
|
23
|
+
# Wirecard only allows phone numbers with a format like this: +xxx(yyy)zzz-zzzz-ppp, where:
|
24
|
+
# xxx = Country code
|
25
|
+
# yyy = Area or city code
|
26
|
+
# zzz-zzzz = Local number
|
27
|
+
# ppp = PBX extension
|
28
|
+
# For example, a typical U.S. or Canadian number would be "+1(202)555-1234-739" indicating PBX extension 739 at phone
|
29
|
+
# number 5551234 within area code 202 (country code 1).
|
30
|
+
VALID_PHONE_FORMAT = /\+\d{1,3}(\(?\d{3}\)?)?\d{3}-\d{4}-\d{3}/
|
31
|
+
|
32
|
+
# The countries the gateway supports merchants from as 2 digit ISO country codes
|
33
|
+
self.supported_countries = ['DE']
|
34
|
+
|
35
|
+
# Wirecard supports all major credit and debit cards:
|
36
|
+
# Visa, Mastercard, American Express, Diners Club,
|
37
|
+
# JCB, Switch, VISA Carte Bancaire, Visa Electron and UATP cards.
|
38
|
+
# They also support the latest anti-fraud systems such as Verified by Visa or Master Secure Code.
|
39
|
+
self.supported_cardtypes = [
|
40
|
+
:visa, :master, :american_express, :diners_club, :jcb, :switch
|
41
|
+
]
|
42
|
+
|
43
|
+
# The homepage URL of the gateway
|
44
|
+
self.homepage_url = 'http://www.wirecard.com'
|
45
|
+
|
46
|
+
# The name of the gateway
|
47
|
+
self.display_name = 'Wirecard'
|
48
|
+
|
49
|
+
# The currency should normally be EUROs
|
50
|
+
self.default_currency = 'EUR'
|
51
|
+
|
52
|
+
# 100 is 1.00 Euro
|
53
|
+
self.money_format = :cents
|
54
|
+
|
55
|
+
def initialize(options = {})
|
56
|
+
# verify that username and password are supplied
|
57
|
+
requires!(options, :login, :password)
|
58
|
+
# unfortunately Wirecard also requires a BusinessCaseSignature in the XML request
|
59
|
+
requires!(options, :signature)
|
60
|
+
super
|
61
|
+
end
|
62
|
+
|
63
|
+
# Authorization
|
64
|
+
def authorize(money, creditcard, options = {})
|
65
|
+
options[:credit_card] = creditcard
|
66
|
+
commit(:preauthorization, money, options)
|
67
|
+
end
|
68
|
+
|
69
|
+
# Capture Authorization
|
70
|
+
def capture(money, authorization, options = {})
|
71
|
+
options[:preauthorization] = authorization
|
72
|
+
commit(:capture, money, options)
|
73
|
+
end
|
74
|
+
|
75
|
+
# Purchase
|
76
|
+
def purchase(money, creditcard, options = {})
|
77
|
+
options[:credit_card] = creditcard
|
78
|
+
commit(:purchase, money, options)
|
79
|
+
end
|
80
|
+
|
81
|
+
private
|
82
|
+
|
83
|
+
def prepare_options_hash(options)
|
84
|
+
result = @options.merge(options)
|
85
|
+
setup_address_hash!(result)
|
86
|
+
result
|
87
|
+
end
|
88
|
+
|
89
|
+
# Create all address hash key value pairs so that
|
90
|
+
# it still works if only provided with one or two of them
|
91
|
+
def setup_address_hash!(options)
|
92
|
+
options[:billing_address] = options[:billing_address] || options[:address] || {}
|
93
|
+
options[:shipping_address] = options[:shipping_address] || {}
|
94
|
+
# Include Email in address-hash from options-hash
|
95
|
+
options[:billing_address][:email] = options[:email] if options[:email]
|
96
|
+
end
|
97
|
+
|
98
|
+
# Contact WireCard, make the XML request, and parse the
|
99
|
+
# reply into a Response object
|
100
|
+
def commit(action, money, options)
|
101
|
+
request = build_request(action, money, options)
|
102
|
+
|
103
|
+
headers = { 'Content-Type' => 'text/xml',
|
104
|
+
'Authorization' => encoded_credentials }
|
105
|
+
|
106
|
+
response = parse(ssl_post(test? ? self.test_url : self.live_url, request, headers))
|
107
|
+
# Pending Status also means Acknowledged (as stated in their specification)
|
108
|
+
success = response[:FunctionResult] == "ACK" || response[:FunctionResult] == "PENDING"
|
109
|
+
message = response[:Message]
|
110
|
+
authorization = response[:GuWID]
|
111
|
+
|
112
|
+
Response.new(success, message, response,
|
113
|
+
:test => test?,
|
114
|
+
:authorization => authorization,
|
115
|
+
:avs_result => { :code => response[:avsCode] },
|
116
|
+
:cvv_result => response[:cvCode]
|
117
|
+
)
|
118
|
+
rescue ResponseError => e
|
119
|
+
if e.response.code == "401"
|
120
|
+
return Response.new(false, "Invalid Login")
|
121
|
+
else
|
122
|
+
raise
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
# Generates the complete xml-message, that gets sent to the gateway
|
127
|
+
def build_request(action, money, options)
|
128
|
+
options = prepare_options_hash(options)
|
129
|
+
options[:action] = action
|
130
|
+
xml = Builder::XmlMarkup.new :indent => 2
|
131
|
+
xml.instruct!
|
132
|
+
xml.tag! 'WIRECARD_BXML' do
|
133
|
+
xml.tag! 'W_REQUEST' do
|
134
|
+
xml.tag! 'W_JOB' do
|
135
|
+
xml.tag! 'JobID', ''
|
136
|
+
# UserID for this transaction
|
137
|
+
xml.tag! 'BusinessCaseSignature', options[:signature] || options[:login]
|
138
|
+
# Create the whole rest of the message
|
139
|
+
add_transaction_data(xml, money, options)
|
140
|
+
end
|
141
|
+
end
|
142
|
+
end
|
143
|
+
xml.target!
|
144
|
+
end
|
145
|
+
|
146
|
+
# Includes the whole transaction data (payment, creditcard, address)
|
147
|
+
def add_transaction_data(xml, money, options)
|
148
|
+
options[:order_id] ||= generate_unique_id
|
149
|
+
|
150
|
+
xml.tag! "FNC_CC_#{options[:action].to_s.upcase}" do
|
151
|
+
xml.tag! 'FunctionID', options[:description].to_s.slice(0,32)
|
152
|
+
xml.tag! 'CC_TRANSACTION' do
|
153
|
+
xml.tag! 'TransactionID', options[:order_id]
|
154
|
+
case options[:action]
|
155
|
+
when :preauthorization, :purchase
|
156
|
+
add_invoice(xml, money, options)
|
157
|
+
add_creditcard(xml, options[:credit_card])
|
158
|
+
add_address(xml, options[:billing_address])
|
159
|
+
when :capture
|
160
|
+
xml.tag! 'GuWID', options[:preauthorization]
|
161
|
+
add_amount(xml, money)
|
162
|
+
end
|
163
|
+
end
|
164
|
+
end
|
165
|
+
end
|
166
|
+
|
167
|
+
# Includes the payment (amount, currency, country) to the transaction-xml
|
168
|
+
def add_invoice(xml, money, options)
|
169
|
+
add_amount(xml, money)
|
170
|
+
xml.tag! 'Currency', options[:currency] || currency(money)
|
171
|
+
xml.tag! 'CountryCode', options[:billing_address][:country]
|
172
|
+
xml.tag! 'RECURRING_TRANSACTION' do
|
173
|
+
xml.tag! 'Type', options[:recurring] || 'Single'
|
174
|
+
end
|
175
|
+
end
|
176
|
+
|
177
|
+
# Include the amount in the transaction-xml
|
178
|
+
def add_amount(xml, money)
|
179
|
+
xml.tag! 'Amount', amount(money)
|
180
|
+
end
|
181
|
+
|
182
|
+
# Includes the credit-card data to the transaction-xml
|
183
|
+
def add_creditcard(xml, creditcard)
|
184
|
+
raise "Creditcard must be supplied!" if creditcard.nil?
|
185
|
+
xml.tag! 'CREDIT_CARD_DATA' do
|
186
|
+
xml.tag! 'CreditCardNumber', creditcard.number
|
187
|
+
xml.tag! 'CVC2', creditcard.verification_value
|
188
|
+
xml.tag! 'ExpirationYear', creditcard.year
|
189
|
+
xml.tag! 'ExpirationMonth', format(creditcard.month, :two_digits)
|
190
|
+
xml.tag! 'CardHolderName', [creditcard.first_name, creditcard.last_name].join(' ')
|
191
|
+
end
|
192
|
+
end
|
193
|
+
|
194
|
+
# Includes the IP address of the customer to the transaction-xml
|
195
|
+
def add_customer_data(xml, options)
|
196
|
+
return unless options[:ip]
|
197
|
+
xml.tag! 'CONTACT_DATA' do
|
198
|
+
xml.tag! 'IPAddress', options[:ip]
|
199
|
+
end
|
200
|
+
end
|
201
|
+
|
202
|
+
# Includes the address to the transaction-xml
|
203
|
+
def add_address(xml, address)
|
204
|
+
return if address.nil?
|
205
|
+
xml.tag! 'CORPTRUSTCENTER_DATA' do
|
206
|
+
xml.tag! 'ADDRESS' do
|
207
|
+
xml.tag! 'Address1', address[:address1]
|
208
|
+
xml.tag! 'Address2', address[:address2] if address[:address2]
|
209
|
+
xml.tag! 'City', address[:city]
|
210
|
+
xml.tag! 'ZipCode', address[:zip]
|
211
|
+
|
212
|
+
if address[:state] =~ /[A-Za-z]{2}/ && address[:country] =~ /^(us|ca)$/i
|
213
|
+
xml.tag! 'State', address[:state].upcase
|
214
|
+
end
|
215
|
+
|
216
|
+
xml.tag! 'Country', address[:country]
|
217
|
+
xml.tag! 'Phone', address[:phone] if address[:phone] =~ VALID_PHONE_FORMAT
|
218
|
+
xml.tag! 'Email', address[:email]
|
219
|
+
end
|
220
|
+
end
|
221
|
+
end
|
222
|
+
|
223
|
+
# Read the XML message from the gateway and check if it was successful,
|
224
|
+
# and also extract required return values from the response.
|
225
|
+
def parse(xml)
|
226
|
+
basepath = '/WIRECARD_BXML/W_RESPONSE'
|
227
|
+
response = {}
|
228
|
+
|
229
|
+
xml = REXML::Document.new(xml)
|
230
|
+
if root = REXML::XPath.first(xml, "#{basepath}/W_JOB")
|
231
|
+
parse_response(response, root)
|
232
|
+
elsif root = REXML::XPath.first(xml, "//ERROR")
|
233
|
+
parse_error(response, root)
|
234
|
+
else
|
235
|
+
response[:Message] = "No valid XML response message received. \
|
236
|
+
Propably wrong credentials supplied with HTTP header."
|
237
|
+
end
|
238
|
+
|
239
|
+
response
|
240
|
+
end
|
241
|
+
|
242
|
+
# Parse the <ProcessingStatus> Element which containts all important information
|
243
|
+
def parse_response(response, root)
|
244
|
+
status = nil
|
245
|
+
# get the root element for this Transaction
|
246
|
+
root.elements.to_a.each do |node|
|
247
|
+
if node.name =~ /FNC_CC_/
|
248
|
+
status = REXML::XPath.first(node, "CC_TRANSACTION/PROCESSING_STATUS")
|
249
|
+
end
|
250
|
+
end
|
251
|
+
message = ""
|
252
|
+
if status
|
253
|
+
if info = status.elements['Info']
|
254
|
+
message << info.text
|
255
|
+
end
|
256
|
+
# Get basic response information
|
257
|
+
status.elements.to_a.each do |node|
|
258
|
+
response[node.name.to_sym] = (node.text || '').strip
|
259
|
+
end
|
260
|
+
end
|
261
|
+
parse_error(root, message)
|
262
|
+
response[:Message] = message
|
263
|
+
end
|
264
|
+
|
265
|
+
# Parse a generic error response from the gateway
|
266
|
+
def parse_error(root, message = "")
|
267
|
+
# Get errors if available and append them to the message
|
268
|
+
errors = errors_to_string(root)
|
269
|
+
unless errors.strip.blank?
|
270
|
+
message << ' - ' unless message.strip.blank?
|
271
|
+
message << errors
|
272
|
+
end
|
273
|
+
message
|
274
|
+
end
|
275
|
+
|
276
|
+
# Parses all <ERROR> elements in the response and converts the information
|
277
|
+
# to a single string
|
278
|
+
def errors_to_string(root)
|
279
|
+
# Get context error messages (can be 0..*)
|
280
|
+
errors = []
|
281
|
+
REXML::XPath.each(root, "//ERROR") do |error_elem|
|
282
|
+
error = {}
|
283
|
+
error[:Advice] = []
|
284
|
+
error[:Message] = error_elem.elements['Message'].text
|
285
|
+
error_elem.elements.each('Advice') do |advice|
|
286
|
+
error[:Advice] << advice.text
|
287
|
+
end
|
288
|
+
errors << error
|
289
|
+
end
|
290
|
+
# Convert all messages to a single string
|
291
|
+
string = ''
|
292
|
+
errors.each do |error|
|
293
|
+
string << error[:Message]
|
294
|
+
error[:Advice].each_with_index do |advice, index|
|
295
|
+
string << ' (' if index == 0
|
296
|
+
string << "#{index+1}. #{advice}"
|
297
|
+
string << ' and ' if index < error[:Advice].size - 1
|
298
|
+
string << ')' if index == error[:Advice].size - 1
|
299
|
+
end
|
300
|
+
end
|
301
|
+
string
|
302
|
+
end
|
303
|
+
|
304
|
+
# Encode login and password in Base64 to supply as HTTP header
|
305
|
+
# (for http basic authentication)
|
306
|
+
def encoded_credentials
|
307
|
+
credentials = [@options[:login], @options[:password]].join(':')
|
308
|
+
"Basic " << Base64.encode64(credentials).strip
|
309
|
+
end
|
310
|
+
end
|
311
|
+
end
|
312
|
+
end
|
313
|
+
|
@@ -0,0 +1,303 @@
|
|
1
|
+
module ActiveMerchant #:nodoc:
|
2
|
+
module Billing #:nodoc:
|
3
|
+
class WorldpayGateway < Gateway
|
4
|
+
self.test_url = 'https://secure-test.worldpay.com/jsp/merchant/xml/paymentService.jsp'
|
5
|
+
self.live_url = 'https://secure.worldpay.com/jsp/merchant/xml/paymentService.jsp'
|
6
|
+
|
7
|
+
self.default_currency = 'GBP'
|
8
|
+
self.money_format = :cents
|
9
|
+
self.supported_countries = ['HK', 'US', 'GB', 'AU']
|
10
|
+
self.supported_cardtypes = [:visa, :master, :american_express, :discover, :jcb, :maestro, :laser]
|
11
|
+
self.homepage_url = 'http://www.worldpay.com/'
|
12
|
+
self.display_name = 'WorldPay'
|
13
|
+
|
14
|
+
CARD_CODES = {
|
15
|
+
'visa' => 'VISA-SSL',
|
16
|
+
'master' => 'ECMC-SSL',
|
17
|
+
'discover' => 'DISCOVER-SSL',
|
18
|
+
'american_express' => 'AMEX-SSL',
|
19
|
+
'jcb' => 'JCB-SSL',
|
20
|
+
'maestro' => 'MAESTRO-SSL',
|
21
|
+
'laser' => 'LASER-SSL',
|
22
|
+
'diners_club' => 'DINERS-SSL'
|
23
|
+
}
|
24
|
+
|
25
|
+
def initialize(options = {})
|
26
|
+
requires!(options, :login, :password)
|
27
|
+
super
|
28
|
+
end
|
29
|
+
|
30
|
+
def purchase(money, payment_method, options = {})
|
31
|
+
MultiResponse.run do |r|
|
32
|
+
r.process{authorize(money, payment_method, options)}
|
33
|
+
r.process{capture(money, r.authorization, options.merge(:authorization_validated => true))}
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def authorize(money, payment_method, options = {})
|
38
|
+
requires!(options, :order_id)
|
39
|
+
authorize_request(money, payment_method, options)
|
40
|
+
end
|
41
|
+
|
42
|
+
def capture(money, authorization, options = {})
|
43
|
+
MultiResponse.run do |r|
|
44
|
+
r.process{inquire_request(authorization, options, "AUTHORISED")} unless options[:authorization_validated]
|
45
|
+
if r.params
|
46
|
+
authorization_currency = r.params['amount_currency_code']
|
47
|
+
options = options.merge(:currency => authorization_currency) if authorization_currency.present?
|
48
|
+
end
|
49
|
+
r.process{capture_request(money, authorization, options)}
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def void(authorization, options = {})
|
54
|
+
MultiResponse.run do |r|
|
55
|
+
r.process{inquire_request(authorization, options, "AUTHORISED")}
|
56
|
+
r.process{cancel_request(authorization, options)}
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def refund(money, authorization, options = {})
|
61
|
+
MultiResponse.run do |r|
|
62
|
+
r.process{inquire_request(authorization, options, "CAPTURED", "SETTLED")}
|
63
|
+
r.process{refund_request(money, authorization, options)}
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
private
|
68
|
+
|
69
|
+
def authorize_request(money, payment_method, options)
|
70
|
+
commit('authorize', build_authorization_request(money, payment_method, options), "AUTHORISED")
|
71
|
+
end
|
72
|
+
|
73
|
+
def capture_request(money, authorization, options)
|
74
|
+
commit('capture', build_capture_request(money, authorization, options), :ok)
|
75
|
+
end
|
76
|
+
|
77
|
+
def cancel_request(authorization, options)
|
78
|
+
commit('cancel', build_void_request(authorization, options), :ok)
|
79
|
+
end
|
80
|
+
|
81
|
+
def inquire_request(authorization, options, *success_criteria)
|
82
|
+
commit('inquiry', build_order_inquiry_request(authorization, options), *success_criteria)
|
83
|
+
end
|
84
|
+
|
85
|
+
def refund_request(money, authorization, options)
|
86
|
+
commit('refund', build_refund_request(money, authorization, options), :ok)
|
87
|
+
end
|
88
|
+
|
89
|
+
def build_request
|
90
|
+
xml = Builder::XmlMarkup.new :indent => 2
|
91
|
+
xml.instruct! :xml, :encoding => 'ISO-8859-1'
|
92
|
+
xml.declare! :DOCTYPE, :paymentService, :PUBLIC, "-//WorldPay//DTD WorldPay PaymentService v1//EN", "http://dtd.wp3.rbsworldpay.com/paymentService_v1.dtd"
|
93
|
+
xml.tag! 'paymentService', 'version' => "1.4", 'merchantCode' => @options[:login] do
|
94
|
+
yield xml
|
95
|
+
end
|
96
|
+
xml.target!
|
97
|
+
end
|
98
|
+
|
99
|
+
def build_order_modify_request(authorization)
|
100
|
+
build_request do |xml|
|
101
|
+
xml.tag! 'modify' do
|
102
|
+
xml.tag! 'orderModification', 'orderCode' => authorization do
|
103
|
+
yield xml
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
def build_order_inquiry_request(authorization, options)
|
110
|
+
build_request do |xml|
|
111
|
+
xml.tag! 'inquiry' do
|
112
|
+
xml.tag! 'orderInquiry', 'orderCode' => authorization
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
def build_authorization_request(money, payment_method, options)
|
118
|
+
build_request do |xml|
|
119
|
+
xml.tag! 'submit' do
|
120
|
+
xml.tag! 'order', {'orderCode' => options[:order_id], 'installationId' => @options[:inst_id]}.reject{|_,v| !v} do
|
121
|
+
xml.description(options[:description].blank? ? "Purchase" : options[:description])
|
122
|
+
add_amount(xml, money, options)
|
123
|
+
if options[:order_content]
|
124
|
+
xml.tag! 'orderContent' do
|
125
|
+
xml.cdata! options[:order_content]
|
126
|
+
end
|
127
|
+
end
|
128
|
+
add_payment_method(xml, money, payment_method, options)
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
def build_capture_request(money, authorization, options)
|
135
|
+
build_order_modify_request(authorization) do |xml|
|
136
|
+
xml.tag! 'capture' do
|
137
|
+
time = Time.now
|
138
|
+
xml.tag! 'date', 'dayOfMonth' => time.day, 'month' => time.month, 'year'=> time.year
|
139
|
+
add_amount(xml, money, options)
|
140
|
+
end
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
def build_void_request(authorization, options)
|
145
|
+
build_order_modify_request(authorization) do |xml|
|
146
|
+
xml.tag! 'cancel'
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
def build_refund_request(money, authorization, options)
|
151
|
+
build_order_modify_request(authorization) do |xml|
|
152
|
+
xml.tag! 'refund' do
|
153
|
+
add_amount(xml, money, options.merge(:debit_credit_indicator => "credit"))
|
154
|
+
end
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
def add_amount(xml, money, options)
|
159
|
+
currency = options[:currency] || currency(money)
|
160
|
+
amount = localized_amount(money, currency)
|
161
|
+
|
162
|
+
amount_hash = {
|
163
|
+
:value => amount,
|
164
|
+
'currencyCode' => currency,
|
165
|
+
'exponent' => 2
|
166
|
+
}
|
167
|
+
|
168
|
+
if options[:debit_credit_indicator]
|
169
|
+
amount_hash.merge!('debitCreditIndicator' => options[:debit_credit_indicator])
|
170
|
+
end
|
171
|
+
|
172
|
+
xml.tag! 'amount', amount_hash
|
173
|
+
end
|
174
|
+
|
175
|
+
def add_payment_method(xml, amount, payment_method, options)
|
176
|
+
if payment_method.is_a?(String)
|
177
|
+
xml.tag! 'payAsOrder', 'orderCode' => payment_method do
|
178
|
+
add_amount(xml, amount, options)
|
179
|
+
end
|
180
|
+
else
|
181
|
+
xml.tag! 'paymentDetails' do
|
182
|
+
xml.tag! CARD_CODES[card_brand(payment_method)] do
|
183
|
+
xml.tag! 'cardNumber', payment_method.number
|
184
|
+
xml.tag! 'expiryDate' do
|
185
|
+
xml.tag! 'date', 'month' => format(payment_method.month, :two_digits), 'year' => format(payment_method.year, :four_digits)
|
186
|
+
end
|
187
|
+
|
188
|
+
xml.tag! 'cardHolderName', payment_method.name
|
189
|
+
xml.tag! 'cvc', payment_method.verification_value
|
190
|
+
|
191
|
+
add_address(xml, 'cardAddress', (options[:billing_address] || options[:address]))
|
192
|
+
end
|
193
|
+
end
|
194
|
+
end
|
195
|
+
end
|
196
|
+
|
197
|
+
def add_address(xml, element, address)
|
198
|
+
return if address.nil?
|
199
|
+
|
200
|
+
xml.tag! element do
|
201
|
+
xml.tag! 'address' do
|
202
|
+
if m = /^\s*([^\s]+)\s+(.+)$/.match(address[:name])
|
203
|
+
xml.tag! 'firstName', m[1]
|
204
|
+
xml.tag! 'lastName', m[2]
|
205
|
+
end
|
206
|
+
if m = /^\s*(\d+)\s+(.+)$/.match(address[:address1])
|
207
|
+
xml.tag! 'street', m[2]
|
208
|
+
house_number = m[1]
|
209
|
+
else
|
210
|
+
xml.tag! 'street', address[:address1]
|
211
|
+
end
|
212
|
+
xml.tag! 'houseName', address[:address2] if address[:address2]
|
213
|
+
xml.tag! 'houseNumber', house_number if house_number.present?
|
214
|
+
xml.tag! 'postalCode', (address[:zip].present? ? address[:zip] : "0000")
|
215
|
+
xml.tag! 'city', address[:city] if address[:city]
|
216
|
+
xml.tag! 'state', (address[:state].present? ? address[:state] : 'N/A')
|
217
|
+
xml.tag! 'countryCode', address[:country]
|
218
|
+
xml.tag! 'telephoneNumber', address[:phone] if address[:phone]
|
219
|
+
end
|
220
|
+
end
|
221
|
+
end
|
222
|
+
|
223
|
+
def parse(action, xml)
|
224
|
+
parse_element({:action => action}, REXML::Document.new(xml))
|
225
|
+
end
|
226
|
+
|
227
|
+
def parse_element(raw, node)
|
228
|
+
node.attributes.each do |k, v|
|
229
|
+
raw["#{node.name.underscore}_#{k.underscore}".to_sym] = v
|
230
|
+
end
|
231
|
+
if node.has_elements?
|
232
|
+
raw[node.name.underscore.to_sym] = true unless node.name.blank?
|
233
|
+
node.elements.each{|e| parse_element(raw, e) }
|
234
|
+
else
|
235
|
+
raw[node.name.underscore.to_sym] = node.text unless node.text.nil?
|
236
|
+
end
|
237
|
+
raw
|
238
|
+
end
|
239
|
+
|
240
|
+
def commit(action, request, *success_criteria)
|
241
|
+
xmr = ssl_post(url, request, 'Content-Type' => 'text/xml', 'Authorization' => encoded_credentials)
|
242
|
+
raw = parse(action, xmr)
|
243
|
+
success, message = success_and_message_from(raw, success_criteria)
|
244
|
+
|
245
|
+
Response.new(
|
246
|
+
success,
|
247
|
+
message,
|
248
|
+
raw,
|
249
|
+
:authorization => authorization_from(raw),
|
250
|
+
:test => test?)
|
251
|
+
|
252
|
+
rescue ActiveMerchant::ResponseError => e
|
253
|
+
if e.response.code.to_s == "401"
|
254
|
+
return Response.new(false, "Invalid credentials", {}, :test => test?)
|
255
|
+
else
|
256
|
+
raise e
|
257
|
+
end
|
258
|
+
end
|
259
|
+
|
260
|
+
def url
|
261
|
+
test? ? self.test_url : self.live_url
|
262
|
+
end
|
263
|
+
|
264
|
+
# success_criteria can be:
|
265
|
+
# - a string or an array of strings (if one of many responses)
|
266
|
+
# - An array of strings if one of many responses could be considered a
|
267
|
+
# success.
|
268
|
+
def success_and_message_from(raw, success_criteria)
|
269
|
+
success = (success_criteria.include?(raw[:last_event]) || raw[:ok].present?)
|
270
|
+
if success
|
271
|
+
message = "SUCCESS"
|
272
|
+
else
|
273
|
+
message = (raw[:iso8583_return_code_description] || raw[:error] || required_status_message(raw, success_criteria))
|
274
|
+
end
|
275
|
+
|
276
|
+
[ success, message ]
|
277
|
+
end
|
278
|
+
|
279
|
+
def required_status_message(raw, success_criteria)
|
280
|
+
if(!success_criteria.include?(raw[:last_event]))
|
281
|
+
"A transaction status of #{success_criteria.collect{|c| "'#{c}'"}.join(" or ")} is required."
|
282
|
+
end
|
283
|
+
end
|
284
|
+
|
285
|
+
def authorization_from(raw)
|
286
|
+
pair = raw.detect{|k,v| k.to_s =~ /_order_code$/}
|
287
|
+
(pair ? pair.last : nil)
|
288
|
+
end
|
289
|
+
|
290
|
+
def encoded_credentials
|
291
|
+
credentials = "#{@options[:login]}:#{@options[:password]}"
|
292
|
+
"Basic #{[credentials].pack('m').strip}"
|
293
|
+
end
|
294
|
+
|
295
|
+
def localized_amount(money, currency)
|
296
|
+
amount = amount(money)
|
297
|
+
return amount unless CURRENCIES_WITHOUT_FRACTIONS.include?(currency.to_s)
|
298
|
+
|
299
|
+
amount.to_i / 100 * 100
|
300
|
+
end
|
301
|
+
end
|
302
|
+
end
|
303
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module ActiveMerchant
|
2
|
+
module Billing
|
3
|
+
autoload :Gateway, 'active_merchant/billing/gateway'
|
4
|
+
|
5
|
+
Dir[File.dirname(__FILE__) + '/gateways/**/*.rb'].each do |f|
|
6
|
+
# Get camelized class name
|
7
|
+
filename = File.basename(f, '.rb')
|
8
|
+
# Add _gateway suffix
|
9
|
+
gateway_name = filename + '_gateway'
|
10
|
+
# Camelize the string to get the class name
|
11
|
+
gateway_class = gateway_name.camelize
|
12
|
+
|
13
|
+
# Register for autoloading
|
14
|
+
autoload gateway_class, f
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module ActiveMerchant #:nodoc:
|
2
|
+
module Billing #:nodoc:
|
3
|
+
module Integrations #:nodoc:
|
4
|
+
module A1agregator
|
5
|
+
class Helper < ActiveMerchant::Billing::Integrations::Helper
|
6
|
+
|
7
|
+
# public key
|
8
|
+
mapping :account, 'key'
|
9
|
+
|
10
|
+
mapping :amount, 'cost'
|
11
|
+
|
12
|
+
mapping :order, 'order_id'
|
13
|
+
|
14
|
+
mapping :customer, :email => 'email',
|
15
|
+
:phone => 'phone_number'
|
16
|
+
|
17
|
+
# payment description
|
18
|
+
mapping :credential2, 'name'
|
19
|
+
|
20
|
+
mapping :credential3, 'comment'
|
21
|
+
|
22
|
+
# on error
|
23
|
+
# 1 - raise error
|
24
|
+
# 0 - redirect
|
25
|
+
mapping :credential4, 'verbose'
|
26
|
+
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|