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,137 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
|
3
|
+
module ActiveMerchant #:nodoc:
|
4
|
+
module Billing #:nodoc:
|
5
|
+
module Integrations #:nodoc:
|
6
|
+
module Quickpay
|
7
|
+
class Notification < ActiveMerchant::Billing::Integrations::Notification
|
8
|
+
def complete?
|
9
|
+
status == '000'
|
10
|
+
end
|
11
|
+
|
12
|
+
def item_id
|
13
|
+
params['ordernumber']
|
14
|
+
end
|
15
|
+
|
16
|
+
def transaction_id
|
17
|
+
params['transaction']
|
18
|
+
end
|
19
|
+
|
20
|
+
def received_at
|
21
|
+
time = params['time']
|
22
|
+
# If time only contains 12 integers then it's pre v5 format
|
23
|
+
time = "20#{params['time']}" if /[0-9]{12}/.match(params['time'])
|
24
|
+
Time.parse(time)
|
25
|
+
end
|
26
|
+
|
27
|
+
def gross
|
28
|
+
"%.2f" % (gross_cents / 100.0)
|
29
|
+
end
|
30
|
+
|
31
|
+
def gross_cents
|
32
|
+
params['amount'].to_i
|
33
|
+
end
|
34
|
+
|
35
|
+
def status
|
36
|
+
params['qpstat']
|
37
|
+
end
|
38
|
+
|
39
|
+
def currency
|
40
|
+
params['currency']
|
41
|
+
end
|
42
|
+
|
43
|
+
# Provide access to raw fields from quickpay
|
44
|
+
%w(
|
45
|
+
msgtype
|
46
|
+
ordernumber
|
47
|
+
state
|
48
|
+
chstat
|
49
|
+
chstatmsg
|
50
|
+
qpstat
|
51
|
+
qpstatmsg
|
52
|
+
merchant
|
53
|
+
merchantemail
|
54
|
+
cardtype
|
55
|
+
cardnumber
|
56
|
+
cardhash
|
57
|
+
cardexpire
|
58
|
+
splitpayment
|
59
|
+
fraudprobability
|
60
|
+
fraudremarks
|
61
|
+
fraudreport
|
62
|
+
fee
|
63
|
+
).each do |attr|
|
64
|
+
define_method(attr) do
|
65
|
+
params[attr]
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
MD5_CHECK_FIELDS = [
|
70
|
+
:msgtype,
|
71
|
+
:ordernumber,
|
72
|
+
:amount,
|
73
|
+
:currency,
|
74
|
+
:time,
|
75
|
+
:state,
|
76
|
+
:qpstat,
|
77
|
+
:qpstatmsg,
|
78
|
+
:chstat,
|
79
|
+
:chstatmsg,
|
80
|
+
:merchant,
|
81
|
+
:merchantemail,
|
82
|
+
:transaction,
|
83
|
+
:cardtype,
|
84
|
+
:cardnumber,
|
85
|
+
:cardhash,
|
86
|
+
:cardexpire,
|
87
|
+
:splitpayment,
|
88
|
+
:fraudprobability,
|
89
|
+
:fraudremarks,
|
90
|
+
:fraudreport,
|
91
|
+
:fee
|
92
|
+
]
|
93
|
+
|
94
|
+
def generate_md5string
|
95
|
+
MD5_CHECK_FIELDS.map { |key| params[key.to_s] } * "" + @options[:credential2].to_s
|
96
|
+
end
|
97
|
+
|
98
|
+
def generate_md5check
|
99
|
+
Digest::MD5.hexdigest(generate_md5string)
|
100
|
+
end
|
101
|
+
|
102
|
+
# Quickpay doesn't do acknowledgements of callback notifications
|
103
|
+
# Instead it uses and MD5 hash of all parameters
|
104
|
+
def acknowledge
|
105
|
+
generate_md5check == params['md5check']
|
106
|
+
end
|
107
|
+
|
108
|
+
# Take the posted data and move the relevant data into a hash
|
109
|
+
def parse(post)
|
110
|
+
# 30 + 12
|
111
|
+
#------------------------------8a827a0e6829
|
112
|
+
#Content-Disposition: form-data; name="msgtype"
|
113
|
+
#
|
114
|
+
#subscribe
|
115
|
+
#------------------------------8a827a0e6829
|
116
|
+
#Content-Disposition: form-data; name="ordernumber"
|
117
|
+
#
|
118
|
+
#BILP94406
|
119
|
+
|
120
|
+
if post =~ /-{20,40}\w{6,24}/
|
121
|
+
@raw = post.to_s
|
122
|
+
post.split(/-{20,40}\w{6,24}[\n\r]*/m).each do |part|
|
123
|
+
part.scan(/([^\n\r]+)[\n\r]+([^\n\r]*)/m) do |header, value|
|
124
|
+
if header.match(/name=["'](.*)["']/)
|
125
|
+
params[$1] = value.strip
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
129
|
+
else
|
130
|
+
super
|
131
|
+
end
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|
137
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module ActiveMerchant #:nodoc:
|
2
|
+
module Billing #:nodoc:
|
3
|
+
module Integrations #:nodoc:
|
4
|
+
module Quickpay
|
5
|
+
autoload :Helper, File.dirname(__FILE__) + '/quickpay/helper.rb'
|
6
|
+
autoload :Notification, File.dirname(__FILE__) + '/quickpay/notification.rb'
|
7
|
+
|
8
|
+
mattr_accessor :service_url
|
9
|
+
self.service_url = 'https://secure.quickpay.dk/form/'
|
10
|
+
|
11
|
+
def self.notification(post, options = {})
|
12
|
+
Notification.new(post)
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.return(post, options = {})
|
16
|
+
Return.new(post, options)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module ActiveMerchant #:nodoc:
|
2
|
+
module Billing #:nodoc:
|
3
|
+
module Integrations #:nodoc:
|
4
|
+
module Rbkmoney
|
5
|
+
class Helper < ActiveMerchant::Billing::Integrations::Helper
|
6
|
+
mapping :account, 'eshopId'
|
7
|
+
mapping :amount, 'recipientAmount'
|
8
|
+
|
9
|
+
# NOTE: rbkmoney uses outdated currency code 'RUR'
|
10
|
+
mapping :currency, 'recipientCurrency'
|
11
|
+
|
12
|
+
mapping :order, 'orderId'
|
13
|
+
|
14
|
+
mapping :customer, :email => 'user_email'
|
15
|
+
|
16
|
+
mapping :credential2, 'serviceName'
|
17
|
+
mapping :credential3, 'successUrl'
|
18
|
+
mapping :credential4, 'failUrl'
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,91 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
|
3
|
+
module ActiveMerchant #:nodoc:
|
4
|
+
module Billing #:nodoc:
|
5
|
+
module Integrations #:nodoc:
|
6
|
+
module Rbkmoney
|
7
|
+
class Notification < ActiveMerchant::Billing::Integrations::Notification
|
8
|
+
%w(
|
9
|
+
eshopId
|
10
|
+
paymentId
|
11
|
+
orderId
|
12
|
+
eshopAccount
|
13
|
+
serviceName
|
14
|
+
recipientAmount
|
15
|
+
recipientCurrency
|
16
|
+
paymentStatus
|
17
|
+
userName
|
18
|
+
userEmail
|
19
|
+
paymentData
|
20
|
+
secretKey
|
21
|
+
hash
|
22
|
+
).each do |param_name|
|
23
|
+
define_method(param_name.underscore){ params[param_name] }
|
24
|
+
end
|
25
|
+
|
26
|
+
def complete?
|
27
|
+
(payment_status == '5')
|
28
|
+
end
|
29
|
+
|
30
|
+
def test?
|
31
|
+
false
|
32
|
+
end
|
33
|
+
|
34
|
+
def status
|
35
|
+
case payment_status
|
36
|
+
when '3'
|
37
|
+
'pending'
|
38
|
+
when '5'
|
39
|
+
'completed'
|
40
|
+
else 'unknown'
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def user_fields
|
45
|
+
params.inject({}) do |fields, (k,v)|
|
46
|
+
if /\AuserField_[\d+]\z/.match(k)
|
47
|
+
fields[k] = v
|
48
|
+
end
|
49
|
+
fields
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
alias_method :client_id, :eshop_id
|
54
|
+
alias_method :item_id, :order_id
|
55
|
+
alias_method :transaction_id, :payment_id
|
56
|
+
alias_method :received_at, :payment_data
|
57
|
+
alias_method :payer_email, :user_email
|
58
|
+
alias_method :gross, :recipient_amount
|
59
|
+
alias_method :currency, :recipient_currency
|
60
|
+
|
61
|
+
def acknowledge
|
62
|
+
string = [
|
63
|
+
eshop_id,
|
64
|
+
order_id,
|
65
|
+
service_name,
|
66
|
+
eshop_account,
|
67
|
+
recipient_amount,
|
68
|
+
recipient_currency,
|
69
|
+
payment_status,
|
70
|
+
user_name,
|
71
|
+
user_email,
|
72
|
+
payment_data,
|
73
|
+
@options[:secret]
|
74
|
+
].join '::'
|
75
|
+
|
76
|
+
signature = case hash.to_s.length
|
77
|
+
when 32
|
78
|
+
Digest::MD5.hexdigest(string)
|
79
|
+
when 128
|
80
|
+
Digest::SHA512.hexdigest(string)
|
81
|
+
else
|
82
|
+
return false
|
83
|
+
end
|
84
|
+
|
85
|
+
signature == hash
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/rbkmoney/helper.rb'
|
2
|
+
require File.dirname(__FILE__) + '/rbkmoney/notification.rb'
|
3
|
+
|
4
|
+
module ActiveMerchant #:nodoc:
|
5
|
+
module Billing #:nodoc:
|
6
|
+
module Integrations #:nodoc:
|
7
|
+
module Rbkmoney
|
8
|
+
mattr_accessor :service_url
|
9
|
+
self.service_url = 'https://rbkmoney.ru/acceptpurchase.aspx'
|
10
|
+
|
11
|
+
def self.notification(*args)
|
12
|
+
Notification.new(*args)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
module ActiveMerchant #:nodoc:
|
2
|
+
module Billing #:nodoc:
|
3
|
+
module Integrations #:nodoc:
|
4
|
+
class Return
|
5
|
+
attr_accessor :params
|
6
|
+
attr_reader :notification
|
7
|
+
|
8
|
+
def initialize(query_string, options = {})
|
9
|
+
@params = parse(query_string)
|
10
|
+
@options = options
|
11
|
+
end
|
12
|
+
|
13
|
+
# Successful by default. Overridden in the child class
|
14
|
+
def success?
|
15
|
+
true
|
16
|
+
end
|
17
|
+
|
18
|
+
# Not cancelled by default. Overridden in the child class.
|
19
|
+
def cancelled?
|
20
|
+
false
|
21
|
+
end
|
22
|
+
|
23
|
+
def message
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
def parse(query_string)
|
28
|
+
return {} if query_string.blank?
|
29
|
+
|
30
|
+
query_string.split('&').inject({}) do |memo, chunk|
|
31
|
+
next if chunk.empty?
|
32
|
+
key, value = chunk.split('=', 2)
|
33
|
+
next if key.empty?
|
34
|
+
value = value.nil? ? nil : CGI.unescape(value)
|
35
|
+
memo[CGI.unescape(key)] = value
|
36
|
+
memo
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module ActiveMerchant #:nodoc:
|
2
|
+
module Billing #:nodoc:
|
3
|
+
module Integrations #:nodoc:
|
4
|
+
module Robokassa
|
5
|
+
module Common
|
6
|
+
def generate_signature_string
|
7
|
+
custom_param_keys = params.keys.select {|key| key =~ /^shp/}.sort
|
8
|
+
custom_params = custom_param_keys.map {|key| "#{key}=#{params[key]}"}
|
9
|
+
[main_params, secret, custom_params.compact].flatten.join(':')
|
10
|
+
end
|
11
|
+
|
12
|
+
def generate_signature
|
13
|
+
Digest::MD5.hexdigest(generate_signature_string)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
module ActiveMerchant #:nodoc:
|
2
|
+
module Billing #:nodoc:
|
3
|
+
module Integrations #:nodoc:
|
4
|
+
module Robokassa
|
5
|
+
class Helper < ActiveMerchant::Billing::Integrations::Helper
|
6
|
+
include Common
|
7
|
+
|
8
|
+
def initialize(order, account, options = {})
|
9
|
+
@md5secret = options.delete(:secret)
|
10
|
+
super
|
11
|
+
end
|
12
|
+
|
13
|
+
def form_fields
|
14
|
+
@fields.merge(ActiveMerchant::Billing::Integrations::Robokassa.signature_parameter_name => generate_signature)
|
15
|
+
end
|
16
|
+
|
17
|
+
def main_params
|
18
|
+
[:account, :amount, :order].map {|key| @fields[mappings[key]]}
|
19
|
+
end
|
20
|
+
|
21
|
+
def params
|
22
|
+
@fields
|
23
|
+
end
|
24
|
+
|
25
|
+
def secret
|
26
|
+
@md5secret
|
27
|
+
end
|
28
|
+
|
29
|
+
def method_missing(method_id, *args)
|
30
|
+
method_id = method_id.to_s.gsub(/=$/, '')
|
31
|
+
|
32
|
+
# support for robokassa custom parameters
|
33
|
+
if method_id =~ /^shp/
|
34
|
+
add_field method_id, args.last
|
35
|
+
end
|
36
|
+
|
37
|
+
super
|
38
|
+
end
|
39
|
+
|
40
|
+
mapping :account, 'MrchLogin'
|
41
|
+
mapping :amount, 'OutSum'
|
42
|
+
mapping :currency, 'IncCurrLabel'
|
43
|
+
mapping :order, 'InvId'
|
44
|
+
mapping :description, 'Desc'
|
45
|
+
mapping :email, 'Email'
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
module ActiveMerchant #:nodoc:
|
2
|
+
module Billing #:nodoc:
|
3
|
+
module Integrations #:nodoc:
|
4
|
+
module Robokassa
|
5
|
+
class Notification < ActiveMerchant::Billing::Integrations::Notification
|
6
|
+
include Common
|
7
|
+
|
8
|
+
def self.recognizes?(params)
|
9
|
+
params.has_key?('InvId') && params.has_key?('OutSum')
|
10
|
+
end
|
11
|
+
|
12
|
+
def complete?
|
13
|
+
true
|
14
|
+
end
|
15
|
+
|
16
|
+
def amount
|
17
|
+
BigDecimal.new(gross)
|
18
|
+
end
|
19
|
+
|
20
|
+
def item_id
|
21
|
+
params['InvId']
|
22
|
+
end
|
23
|
+
|
24
|
+
def security_key
|
25
|
+
params[ActiveMerchant::Billing::Integrations::Robokassa.signature_parameter_name].to_s.downcase
|
26
|
+
end
|
27
|
+
|
28
|
+
def gross
|
29
|
+
params['OutSum']
|
30
|
+
end
|
31
|
+
|
32
|
+
def status
|
33
|
+
'success'
|
34
|
+
end
|
35
|
+
|
36
|
+
def secret
|
37
|
+
@options[:secret]
|
38
|
+
end
|
39
|
+
|
40
|
+
def main_params
|
41
|
+
[gross, item_id]
|
42
|
+
end
|
43
|
+
|
44
|
+
def acknowledge
|
45
|
+
security_key == generate_signature
|
46
|
+
end
|
47
|
+
|
48
|
+
def success_response(*args)
|
49
|
+
"OK#{item_id}"
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module ActiveMerchant #:nodoc:
|
2
|
+
module Billing #:nodoc:
|
3
|
+
module Integrations #:nodoc:
|
4
|
+
module Robokassa
|
5
|
+
class Return < ActiveMerchant::Billing::Integrations::Return
|
6
|
+
def item_id
|
7
|
+
@params['InvId']
|
8
|
+
end
|
9
|
+
|
10
|
+
def amount
|
11
|
+
@params['OutSum']
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
module ActiveMerchant #:nodoc:
|
2
|
+
module Billing #:nodoc:
|
3
|
+
module Integrations #:nodoc:
|
4
|
+
|
5
|
+
# Documentation: http://robokassa.ru/Doc/En/Interface.aspx
|
6
|
+
module Robokassa
|
7
|
+
autoload :Helper, File.dirname(__FILE__) + '/robokassa/helper.rb'
|
8
|
+
autoload :Notification, File.dirname(__FILE__) + '/robokassa/notification.rb'
|
9
|
+
autoload :Return, File.dirname(__FILE__) + '/robokassa/return.rb'
|
10
|
+
autoload :Common, File.dirname(__FILE__) + '/robokassa/common.rb'
|
11
|
+
|
12
|
+
# Overwrite this if you want to change the Robokassa test url
|
13
|
+
mattr_accessor :test_url
|
14
|
+
self.test_url = 'http://test.robokassa.ru/Index.aspx'
|
15
|
+
|
16
|
+
# Overwrite this if you want to change the Robokassa production url
|
17
|
+
mattr_accessor :production_url
|
18
|
+
self.production_url = 'https://merchant.roboxchange.com/Index.aspx'
|
19
|
+
|
20
|
+
mattr_accessor :signature_parameter_name
|
21
|
+
self.signature_parameter_name = 'SignatureValue'
|
22
|
+
|
23
|
+
def self.service_url
|
24
|
+
mode = ActiveMerchant::Billing::Base.integration_mode
|
25
|
+
case mode
|
26
|
+
when :production
|
27
|
+
self.production_url
|
28
|
+
when :test
|
29
|
+
self.test_url
|
30
|
+
else
|
31
|
+
raise StandardError, "Integration mode set to an invalid value: #{mode}"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.helper(order, account, options = {})
|
36
|
+
Helper.new(order, account, options)
|
37
|
+
end
|
38
|
+
|
39
|
+
def self.notification(query_string, options = {})
|
40
|
+
Notification.new(query_string, options)
|
41
|
+
end
|
42
|
+
|
43
|
+
def self.return(query_string)
|
44
|
+
Return.new(query_string)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module ActiveMerchant #:nodoc:
|
2
|
+
module Billing #:nodoc:
|
3
|
+
module Integrations #:nodoc:
|
4
|
+
module SagePayForm
|
5
|
+
module Encryption
|
6
|
+
def sage_encrypt(plaintext, key)
|
7
|
+
Base64.strict_encode64(sage_encrypt_xor(plaintext, key))
|
8
|
+
end
|
9
|
+
|
10
|
+
def sage_decrypt(ciphertext, key)
|
11
|
+
sage_encrypt_xor(Base64.decode64(ciphertext), key)
|
12
|
+
end
|
13
|
+
|
14
|
+
def sage_encrypt_salt(min, max)
|
15
|
+
length = rand(max - min + 1) + min
|
16
|
+
SecureRandom.base64(length + 4)[0, length]
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def sage_encrypt_xor(data, key)
|
22
|
+
raise 'No key provided' if key.blank?
|
23
|
+
|
24
|
+
key *= (data.bytesize.to_f / key.bytesize.to_f).ceil
|
25
|
+
key = key[0, data.bytesize]
|
26
|
+
|
27
|
+
data.bytes.zip(key.bytes).map { |b1, b2| (b1 ^ b2).chr }.join
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,136 @@
|
|
1
|
+
require 'uri'
|
2
|
+
|
3
|
+
module ActiveMerchant #:nodoc:
|
4
|
+
module Billing #:nodoc:
|
5
|
+
module Integrations #:nodoc:
|
6
|
+
module SagePayForm
|
7
|
+
class Helper < ActiveMerchant::Billing::Integrations::Helper
|
8
|
+
include Encryption
|
9
|
+
|
10
|
+
mapping :credential2, 'EncryptKey'
|
11
|
+
|
12
|
+
mapping :account, 'Vendor'
|
13
|
+
mapping :amount, 'Amount'
|
14
|
+
mapping :currency, 'Currency'
|
15
|
+
|
16
|
+
mapping :order, 'VendorTxCode'
|
17
|
+
|
18
|
+
mapping :customer,
|
19
|
+
:first_name => 'BillingFirstnames',
|
20
|
+
:last_name => 'BillingSurname',
|
21
|
+
:email => 'CustomerEMail',
|
22
|
+
:phone => 'BillingPhone',
|
23
|
+
:send_email_confirmation => 'SendEmail'
|
24
|
+
|
25
|
+
mapping :billing_address,
|
26
|
+
:city => 'BillingCity',
|
27
|
+
:address1 => 'BillingAddress1',
|
28
|
+
:address2 => 'BillingAddress2',
|
29
|
+
:state => 'BillingState',
|
30
|
+
:zip => 'BillingPostCode',
|
31
|
+
:country => 'BillingCountry'
|
32
|
+
|
33
|
+
mapping :shipping_address,
|
34
|
+
:city => 'DeliveryCity',
|
35
|
+
:address1 => 'DeliveryAddress1',
|
36
|
+
:address2 => 'DeliveryAddress2',
|
37
|
+
:state => 'DeliveryState',
|
38
|
+
:zip => 'DeliveryPostCode',
|
39
|
+
:country => 'DeliveryCountry'
|
40
|
+
|
41
|
+
mapping :return_url, 'SuccessURL'
|
42
|
+
mapping :description, 'Description'
|
43
|
+
|
44
|
+
class_attribute :referrer_id
|
45
|
+
|
46
|
+
def shipping_address(params = {})
|
47
|
+
@shipping_address_set = true unless params.empty?
|
48
|
+
|
49
|
+
params.each do |k, v|
|
50
|
+
field = mappings[:shipping_address][k]
|
51
|
+
add_field(field, v) unless field.nil?
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def map_billing_address_to_shipping_address
|
56
|
+
%w(City Address1 Address2 State PostCode Country).each do |field|
|
57
|
+
fields["Delivery#{field}"] = fields["Billing#{field}"]
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def form_fields
|
62
|
+
map_billing_address_to_shipping_address unless @shipping_address_set
|
63
|
+
|
64
|
+
fields['DeliveryFirstnames'] ||= fields['BillingFirstnames']
|
65
|
+
fields['DeliverySurname'] ||= fields['BillingSurname']
|
66
|
+
|
67
|
+
fields['FailureURL'] ||= fields['SuccessURL']
|
68
|
+
|
69
|
+
fields['BillingPostCode'] ||= "0000"
|
70
|
+
fields['DeliveryPostCode'] ||= "0000"
|
71
|
+
|
72
|
+
crypt_skip = ['Vendor', 'EncryptKey', 'SendEmail']
|
73
|
+
crypt_skip << 'BillingState' unless fields['BillingCountry'] == 'US'
|
74
|
+
crypt_skip << 'DeliveryState' unless fields['DeliveryCountry'] == 'US'
|
75
|
+
crypt_skip << 'CustomerEMail' unless fields['SendEmail']
|
76
|
+
key = fields['EncryptKey']
|
77
|
+
@crypt ||= create_crypt_field(fields.except(*crypt_skip), key)
|
78
|
+
|
79
|
+
result = {
|
80
|
+
'VPSProtocol' => '2.23',
|
81
|
+
'TxType' => 'PAYMENT',
|
82
|
+
'Vendor' => @fields['Vendor'],
|
83
|
+
'Crypt' => @crypt
|
84
|
+
}
|
85
|
+
result['ReferrerID'] = referrer_id if referrer_id
|
86
|
+
result
|
87
|
+
end
|
88
|
+
|
89
|
+
private
|
90
|
+
|
91
|
+
def create_crypt_field(fields, key)
|
92
|
+
parts = fields.map { |k, v| "#{k}=#{sanitize(k, v)}" unless v.nil? }.compact.shuffle
|
93
|
+
parts.unshift(sage_encrypt_salt(key.length, key.length * 2))
|
94
|
+
sage_encrypt(parts.join('&'), key)
|
95
|
+
end
|
96
|
+
|
97
|
+
def sanitize(key, value)
|
98
|
+
reject = exact = nil
|
99
|
+
|
100
|
+
case key
|
101
|
+
when /URL$/
|
102
|
+
# allow all
|
103
|
+
when 'VendorTxCode'
|
104
|
+
reject = /[^A-Za-z0-9{}._-]+/
|
105
|
+
when /[Nn]ames?$/
|
106
|
+
reject = %r{[^[:alpha:] /\\.'-]+}
|
107
|
+
when /(?:Address[12]|City)$/
|
108
|
+
reject = %r{[^[:alnum:] +'/\\:,.\n()-]+}
|
109
|
+
when /PostCode$/
|
110
|
+
reject = /[^A-Za-z0-9 -]+/
|
111
|
+
when /Phone$/
|
112
|
+
reject = /[^0-9A-Za-z+ ()-]+/
|
113
|
+
when 'Currency'
|
114
|
+
exact = /^[A-Z]{3}$/
|
115
|
+
when /State$/
|
116
|
+
exact = /^[A-Z]{2}$/
|
117
|
+
when 'Description'
|
118
|
+
value = value[0...100]
|
119
|
+
else
|
120
|
+
reject = /&+/
|
121
|
+
end
|
122
|
+
|
123
|
+
if exact
|
124
|
+
raise ArgumentError, "Invalid value for #{key}: #{value.inspect}" unless value =~ exact
|
125
|
+
value
|
126
|
+
elsif reject
|
127
|
+
value.gsub(reject, ' ')
|
128
|
+
else
|
129
|
+
value
|
130
|
+
end
|
131
|
+
end
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|