mattbauer-activemerchant 1.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG +459 -0
- data/CONTRIBUTERS +118 -0
- data/MIT-LICENSE +20 -0
- data/README +134 -0
- data/Rakefile +153 -0
- data/gem-public_cert.pem +20 -0
- data/init.rb +3 -0
- data/lib/active_merchant.rb +60 -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 +68 -0
- data/lib/active_merchant/billing/credit_card.rb +159 -0
- data/lib/active_merchant/billing/credit_card_formatting.rb +21 -0
- data/lib/active_merchant/billing/credit_card_methods.rb +125 -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 +158 -0
- data/lib/active_merchant/billing/gateways.rb +3 -0
- data/lib/active_merchant/billing/gateways/authorize_net.rb +657 -0
- data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +703 -0
- data/lib/active_merchant/billing/gateways/beanstream.rb +102 -0
- data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +233 -0
- data/lib/active_merchant/billing/gateways/beanstream_interac.rb +54 -0
- data/lib/active_merchant/billing/gateways/bogus.rb +98 -0
- data/lib/active_merchant/billing/gateways/braintree.rb +17 -0
- data/lib/active_merchant/billing/gateways/card_stream.rb +230 -0
- data/lib/active_merchant/billing/gateways/cyber_source.rb +406 -0
- data/lib/active_merchant/billing/gateways/data_cash.rb +595 -0
- data/lib/active_merchant/billing/gateways/efsnet.rb +229 -0
- data/lib/active_merchant/billing/gateways/elavon.rb +106 -0
- data/lib/active_merchant/billing/gateways/eway.rb +277 -0
- data/lib/active_merchant/billing/gateways/exact.rb +222 -0
- data/lib/active_merchant/billing/gateways/first_pay.rb +172 -0
- data/lib/active_merchant/billing/gateways/instapay.rb +164 -0
- data/lib/active_merchant/billing/gateways/linkpoint.rb +396 -0
- data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +154 -0
- data/lib/active_merchant/billing/gateways/merchant_ware.rb +283 -0
- data/lib/active_merchant/billing/gateways/modern_payments.rb +36 -0
- data/lib/active_merchant/billing/gateways/modern_payments_cim.rb +214 -0
- data/lib/active_merchant/billing/gateways/moneris.rb +295 -0
- data/lib/active_merchant/billing/gateways/moneris_usa.rb +258 -0
- data/lib/active_merchant/billing/gateways/net_registry.rb +189 -0
- data/lib/active_merchant/billing/gateways/netbilling.rb +168 -0
- data/lib/active_merchant/billing/gateways/ogone.rb +259 -0
- data/lib/active_merchant/billing/gateways/pay_junction.rb +392 -0
- data/lib/active_merchant/billing/gateways/pay_secure.rb +120 -0
- data/lib/active_merchant/billing/gateways/payflow.rb +236 -0
- data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +207 -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_express.rb +138 -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 +230 -0
- data/lib/active_merchant/billing/gateways/paypal.rb +121 -0
- data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +325 -0
- data/lib/active_merchant/billing/gateways/paypal/paypal_express_response.rb +38 -0
- data/lib/active_merchant/billing/gateways/paypal_ca.rb +13 -0
- data/lib/active_merchant/billing/gateways/paypal_express.rb +130 -0
- data/lib/active_merchant/billing/gateways/paypal_express_common.rb +20 -0
- data/lib/active_merchant/billing/gateways/plugnpay.rb +292 -0
- data/lib/active_merchant/billing/gateways/psigate.rb +214 -0
- data/lib/active_merchant/billing/gateways/psl_card.rb +306 -0
- data/lib/active_merchant/billing/gateways/quickpay.rb +213 -0
- data/lib/active_merchant/billing/gateways/realex.rb +200 -0
- data/lib/active_merchant/billing/gateways/sage.rb +146 -0
- data/lib/active_merchant/billing/gateways/sage/sage_bankcard.rb +88 -0
- data/lib/active_merchant/billing/gateways/sage/sage_core.rb +110 -0
- data/lib/active_merchant/billing/gateways/sage/sage_virtual_check.rb +97 -0
- data/lib/active_merchant/billing/gateways/sage_pay.rb +308 -0
- data/lib/active_merchant/billing/gateways/secure_pay.rb +31 -0
- data/lib/active_merchant/billing/gateways/secure_pay_au.rb +157 -0
- data/lib/active_merchant/billing/gateways/secure_pay_tech.rb +113 -0
- data/lib/active_merchant/billing/gateways/skip_jack.rb +442 -0
- data/lib/active_merchant/billing/gateways/smart_ps.rb +254 -0
- data/lib/active_merchant/billing/gateways/trans_first.rb +127 -0
- data/lib/active_merchant/billing/gateways/transax.rb +26 -0
- data/lib/active_merchant/billing/gateways/trust_commerce.rb +418 -0
- data/lib/active_merchant/billing/gateways/usa_epay.rb +194 -0
- data/lib/active_merchant/billing/gateways/verifi.rb +228 -0
- data/lib/active_merchant/billing/gateways/viaklix.rb +189 -0
- data/lib/active_merchant/billing/gateways/wirecard.rb +318 -0
- data/lib/active_merchant/billing/integrations.rb +22 -0
- data/lib/active_merchant/billing/integrations/action_view_helper.rb +79 -0
- data/lib/active_merchant/billing/integrations/bogus.rb +22 -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/chronopay.rb +22 -0
- data/lib/active_merchant/billing/integrations/chronopay/helper.rb +81 -0
- data/lib/active_merchant/billing/integrations/chronopay/notification.rb +156 -0
- data/lib/active_merchant/billing/integrations/chronopay/return.rb +10 -0
- data/lib/active_merchant/billing/integrations/gestpay.rb +26 -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 +83 -0
- data/lib/active_merchant/billing/integrations/gestpay/return.rb +10 -0
- data/lib/active_merchant/billing/integrations/helper.rb +93 -0
- data/lib/active_merchant/billing/integrations/hi_trust.rb +26 -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/nochex.rb +87 -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/notification.rb +62 -0
- data/lib/active_merchant/billing/integrations/paypal.rb +40 -0
- data/lib/active_merchant/billing/integrations/paypal/helper.rb +119 -0
- data/lib/active_merchant/billing/integrations/paypal/notification.rb +154 -0
- data/lib/active_merchant/billing/integrations/paypal/return.rb +10 -0
- data/lib/active_merchant/billing/integrations/quickpay.rb +18 -0
- data/lib/active_merchant/billing/integrations/quickpay/helper.rb +72 -0
- data/lib/active_merchant/billing/integrations/quickpay/notification.rb +74 -0
- data/lib/active_merchant/billing/integrations/return.rb +35 -0
- data/lib/active_merchant/billing/integrations/two_checkout.rb +23 -0
- data/lib/active_merchant/billing/integrations/two_checkout/helper.rb +59 -0
- data/lib/active_merchant/billing/integrations/two_checkout/notification.rb +114 -0
- data/lib/active_merchant/billing/integrations/two_checkout/return.rb +17 -0
- data/lib/active_merchant/billing/response.rb +32 -0
- data/lib/active_merchant/lib/connection.rb +170 -0
- data/lib/active_merchant/lib/country.rb +319 -0
- data/lib/active_merchant/lib/error.rb +4 -0
- data/lib/active_merchant/lib/post_data.rb +22 -0
- data/lib/active_merchant/lib/posts_data.rb +47 -0
- data/lib/active_merchant/lib/requires_parameters.rb +16 -0
- data/lib/active_merchant/lib/utils.rb +18 -0
- data/lib/active_merchant/lib/validateable.rb +76 -0
- data/lib/certs/cacert.pem +7815 -0
- data/lib/support/gateway_support.rb +58 -0
- data/script/destroy +14 -0
- data/script/generate +14 -0
- data/test/fixtures.yml +353 -0
- data/test/remote/gateways/remote_authorize_net_cim_test.rb +459 -0
- data/test/remote/gateways/remote_authorize_net_test.rb +145 -0
- data/test/remote/gateways/remote_beanstream_interac_test.rb +53 -0
- data/test/remote/gateways/remote_beanstream_test.rb +150 -0
- data/test/remote/gateways/remote_braintree_test.rb +154 -0
- data/test/remote/gateways/remote_card_stream_test.rb +148 -0
- data/test/remote/gateways/remote_cyber_source_test.rb +144 -0
- data/test/remote/gateways/remote_data_cash_test.rb +357 -0
- data/test/remote/gateways/remote_efsnet_test.rb +81 -0
- data/test/remote/gateways/remote_elavon_test.rb +66 -0
- data/test/remote/gateways/remote_eway_test.rb +74 -0
- data/test/remote/gateways/remote_exact_test.rb +60 -0
- data/test/remote/gateways/remote_first_pay_test.rb +87 -0
- data/test/remote/gateways/remote_instapay_test.rb +61 -0
- data/test/remote/gateways/remote_linkpoint_test.rb +112 -0
- data/test/remote/gateways/remote_merchant_e_solutions_test.rb +173 -0
- data/test/remote/gateways/remote_merchant_ware_test.rb +113 -0
- data/test/remote/gateways/remote_modern_payments_cim_test.rb +58 -0
- data/test/remote/gateways/remote_modern_payments_test.rb +43 -0
- data/test/remote/gateways/remote_moneris_test.rb +118 -0
- data/test/remote/gateways/remote_moneris_usa_test.rb +115 -0
- data/test/remote/gateways/remote_net_registry_test.rb +85 -0
- data/test/remote/gateways/remote_netbilling_test.rb +70 -0
- data/test/remote/gateways/remote_ogone_test.rb +108 -0
- data/test/remote/gateways/remote_pay_junction_test.rb +143 -0
- data/test/remote/gateways/remote_pay_secure_test.rb +39 -0
- data/test/remote/gateways/remote_payflow_express_test.rb +50 -0
- data/test/remote/gateways/remote_payflow_test.rb +237 -0
- data/test/remote/gateways/remote_payflow_uk_test.rb +173 -0
- data/test/remote/gateways/remote_payment_express_test.rb +136 -0
- data/test/remote/gateways/remote_paypal_express_test.rb +49 -0
- data/test/remote/gateways/remote_paypal_test.rb +178 -0
- data/test/remote/gateways/remote_plugnpay_test.rb +72 -0
- data/test/remote/gateways/remote_psigate_test.rb +50 -0
- data/test/remote/gateways/remote_psl_card_test.rb +125 -0
- data/test/remote/gateways/remote_quickpay_test.rb +190 -0
- data/test/remote/gateways/remote_realex_test.rb +224 -0
- data/test/remote/gateways/remote_sage_bankcard_test.rb +109 -0
- data/test/remote/gateways/remote_sage_pay_test.rb +219 -0
- data/test/remote/gateways/remote_sage_test.rb +87 -0
- data/test/remote/gateways/remote_sage_virtual_check_test.rb +62 -0
- data/test/remote/gateways/remote_secure_pay_au_test.rb +40 -0
- data/test/remote/gateways/remote_secure_pay_tech_test.rb +37 -0
- data/test/remote/gateways/remote_secure_pay_test.rb +28 -0
- data/test/remote/gateways/remote_skipjack_test.rb +105 -0
- data/test/remote/gateways/remote_trans_first_test.rb +34 -0
- data/test/remote/gateways/remote_transax_test.rb +112 -0
- data/test/remote/gateways/remote_trust_commerce_test.rb +152 -0
- data/test/remote/gateways/remote_usa_epay_test.rb +46 -0
- data/test/remote/gateways/remote_verifi_test.rb +107 -0
- data/test/remote/gateways/remote_viaklix_test.rb +43 -0
- data/test/remote/gateways/remote_wirecard_test.rb +111 -0
- data/test/remote/integrations/remote_gestpay_integration_test.rb +37 -0
- data/test/remote/integrations/remote_paypal_integration_test.rb +26 -0
- data/test/test_helper.rb +182 -0
- data/test/unit/avs_result_test.rb +59 -0
- data/test/unit/base_test.rb +55 -0
- data/test/unit/check_test.rb +88 -0
- data/test/unit/connection_test.rb +129 -0
- data/test/unit/country_code_test.rb +33 -0
- data/test/unit/country_test.rb +64 -0
- data/test/unit/credit_card_formatting_test.rb +19 -0
- data/test/unit/credit_card_methods_test.rb +179 -0
- data/test/unit/credit_card_test.rb +318 -0
- data/test/unit/cvv_result_test.rb +33 -0
- data/test/unit/expiry_date_test.rb +32 -0
- data/test/unit/gateways/authorize_net_cim_test.rb +638 -0
- data/test/unit/gateways/authorize_net_test.rb +290 -0
- data/test/unit/gateways/beanstream_interac_test.rb +51 -0
- data/test/unit/gateways/beanstream_test.rb +108 -0
- data/test/unit/gateways/bogus_test.rb +46 -0
- data/test/unit/gateways/braintree_test.rb +126 -0
- data/test/unit/gateways/card_stream_test.rb +90 -0
- data/test/unit/gateways/cyber_source_test.rb +188 -0
- data/test/unit/gateways/data_cash_test.rb +133 -0
- data/test/unit/gateways/efsnet_test.rb +123 -0
- data/test/unit/gateways/elavon_test.rb +139 -0
- data/test/unit/gateways/eway_test.rb +118 -0
- data/test/unit/gateways/exact_test.rb +156 -0
- data/test/unit/gateways/first_pay_test.rb +125 -0
- data/test/unit/gateways/gateway_test.rb +48 -0
- data/test/unit/gateways/instapay_test.rb +102 -0
- data/test/unit/gateways/linkpoint_test.rb +167 -0
- data/test/unit/gateways/merchant_e_solutions_test.rb +169 -0
- data/test/unit/gateways/merchant_ware_test.rb +188 -0
- data/test/unit/gateways/modern_payments_cim_test.rb +171 -0
- data/test/unit/gateways/moneris_test.rb +185 -0
- data/test/unit/gateways/moneris_usa_test.rb +183 -0
- data/test/unit/gateways/net_registry_test.rb +416 -0
- data/test/unit/gateways/netbilling_test.rb +54 -0
- data/test/unit/gateways/ogone_test.rb +256 -0
- data/test/unit/gateways/pay_junction_test.rb +123 -0
- data/test/unit/gateways/pay_secure_test.rb +71 -0
- data/test/unit/gateways/payflow_express_test.rb +173 -0
- data/test/unit/gateways/payflow_express_uk_test.rb +86 -0
- data/test/unit/gateways/payflow_test.rb +305 -0
- data/test/unit/gateways/payflow_uk_test.rb +30 -0
- data/test/unit/gateways/payment_express_test.rb +195 -0
- data/test/unit/gateways/paypal_express_test.rb +382 -0
- data/test/unit/gateways/paypal_test.rb +569 -0
- data/test/unit/gateways/plugnpay_test.rb +86 -0
- data/test/unit/gateways/psigate_test.rb +169 -0
- data/test/unit/gateways/psl_card_test.rb +64 -0
- data/test/unit/gateways/quickpay_test.rb +112 -0
- data/test/unit/gateways/realex_test.rb +151 -0
- data/test/unit/gateways/sage_bankcard_test.rb +162 -0
- data/test/unit/gateways/sage_pay_test.rb +139 -0
- data/test/unit/gateways/sage_virtual_check_test.rb +71 -0
- data/test/unit/gateways/secure_pay_au_test.rb +207 -0
- data/test/unit/gateways/secure_pay_tech_test.rb +44 -0
- data/test/unit/gateways/secure_pay_test.rb +87 -0
- data/test/unit/gateways/skip_jack_test.rb +133 -0
- data/test/unit/gateways/trans_first_test.rb +112 -0
- data/test/unit/gateways/trust_commerce_test.rb +90 -0
- data/test/unit/gateways/usa_epay_test.rb +128 -0
- data/test/unit/gateways/verifi_test.rb +96 -0
- data/test/unit/gateways/viaklix_test.rb +78 -0
- data/test/unit/gateways/wirecard_test.rb +250 -0
- data/test/unit/generators/test_gateway_generator.rb +46 -0
- data/test/unit/generators/test_generator_helper.rb +20 -0
- data/test/unit/generators/test_integration_generator.rb +53 -0
- data/test/unit/integrations/action_view_helper_test.rb +50 -0
- data/test/unit/integrations/bogus_module_test.rb +20 -0
- data/test/unit/integrations/chronopay_module_test.rb +13 -0
- data/test/unit/integrations/gestpay_module_test.rb +14 -0
- data/test/unit/integrations/helpers/bogus_helper_test.rb +28 -0
- data/test/unit/integrations/helpers/chronopay_helper_test.rb +67 -0
- data/test/unit/integrations/helpers/gestpay_helper_test.rb +100 -0
- data/test/unit/integrations/helpers/hi_trust_helper_test.rb +16 -0
- data/test/unit/integrations/helpers/nochex_helper_test.rb +53 -0
- data/test/unit/integrations/helpers/paypal_helper_test.rb +171 -0
- data/test/unit/integrations/helpers/quickpay_helper_test.rb +40 -0
- data/test/unit/integrations/helpers/two_checkout_helper_test.rb +92 -0
- data/test/unit/integrations/hi_trust_module_test.rb +13 -0
- data/test/unit/integrations/nochex_module_test.rb +13 -0
- data/test/unit/integrations/notifications/chronopay_notification_test.rb +66 -0
- data/test/unit/integrations/notifications/gestpay_notification_test.rb +60 -0
- data/test/unit/integrations/notifications/hi_trust_notification_test.rb +59 -0
- data/test/unit/integrations/notifications/nochex_notification_test.rb +51 -0
- data/test/unit/integrations/notifications/notification_test.rb +54 -0
- data/test/unit/integrations/notifications/paypal_notification_test.rb +85 -0
- data/test/unit/integrations/notifications/quickpay_notification_test.rb +69 -0
- data/test/unit/integrations/notifications/two_checkout_notification_test.rb +55 -0
- data/test/unit/integrations/paypal_module_test.rb +28 -0
- data/test/unit/integrations/quickpay_module_test.rb +9 -0
- data/test/unit/integrations/returns/chronopay_return_test.rb +11 -0
- data/test/unit/integrations/returns/gestpay_return_test.rb +10 -0
- data/test/unit/integrations/returns/hi_trust_return_test.rb +24 -0
- data/test/unit/integrations/returns/nochex_return_test.rb +10 -0
- data/test/unit/integrations/returns/paypal_return_test.rb +10 -0
- data/test/unit/integrations/returns/return_test.rb +11 -0
- data/test/unit/integrations/returns/two_checkout_return_test.rb +24 -0
- data/test/unit/integrations/two_checkout_module_test.rb +13 -0
- data/test/unit/post_data_test.rb +55 -0
- data/test/unit/posts_data_test.rb +48 -0
- data/test/unit/response_test.rb +28 -0
- data/test/unit/utils_test.rb +7 -0
- data/test/unit/validateable_test.rb +60 -0
- metadata +396 -0
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
module ActiveMerchant
|
|
2
|
+
module Billing
|
|
3
|
+
# Gateway for netregistry.com.au.
|
|
4
|
+
#
|
|
5
|
+
# Note that NetRegistry itself uses gateway service providers. At the
|
|
6
|
+
# time of this writing, there are at least two (Quest and Ingenico).
|
|
7
|
+
# This module has only been tested with Quest.
|
|
8
|
+
#
|
|
9
|
+
# Also note that NetRegistry does not offer a test mode, nor does it
|
|
10
|
+
# have support for the authorize/capture/void functionality by default
|
|
11
|
+
# (you may arrange for this as described in "Programming for
|
|
12
|
+
# NetRegistry's E-commerce Gateway." [http://rubyurl.com/hNG]), and no
|
|
13
|
+
# #void functionality is documented. As a result, the #authorize and
|
|
14
|
+
# #capture have not yet been tested through a live gateway, and #void
|
|
15
|
+
# will raise an error.
|
|
16
|
+
#
|
|
17
|
+
# If you have this functionality enabled, please consider contributing
|
|
18
|
+
# to ActiveMerchant by writing tests/code for these methods, and
|
|
19
|
+
# submitting a patch.
|
|
20
|
+
#
|
|
21
|
+
# In addition to the standard ActiveMerchant functionality, the
|
|
22
|
+
# response will contain a 'receipt' parameter
|
|
23
|
+
# (response.params['receipt']) if a receipt was issued by the gateway.
|
|
24
|
+
class NetRegistryGateway < Gateway
|
|
25
|
+
URL = 'https://4tknox.au.com/cgi-bin/themerchant.au.com/ecom/external2.pl'
|
|
26
|
+
|
|
27
|
+
FILTERED_PARAMS = [ 'card_no', 'card_expiry', 'receipt_array' ]
|
|
28
|
+
|
|
29
|
+
self.supported_countries = ['AU']
|
|
30
|
+
|
|
31
|
+
# Note that support for Diners, Amex, and JCB require extra
|
|
32
|
+
# steps in setting up your account, as detailed in
|
|
33
|
+
# "Programming for NetRegistry's E-commerce Gateway."
|
|
34
|
+
# [http://rubyurl.com/hNG]
|
|
35
|
+
self.supported_cardtypes = [:visa, :master, :diners_club, :american_express, :jcb]
|
|
36
|
+
self.display_name = 'NetRegistry'
|
|
37
|
+
self.homepage_url = 'http://www.netregistry.com.au'
|
|
38
|
+
|
|
39
|
+
TRANSACTIONS = {
|
|
40
|
+
:authorization => 'preauth',
|
|
41
|
+
:purchase => 'purchase',
|
|
42
|
+
:capture => 'completion',
|
|
43
|
+
:status => 'status',
|
|
44
|
+
:credit => 'refund'
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
# Create a new NetRegistry gateway.
|
|
48
|
+
#
|
|
49
|
+
# Options :login and :password must be given.
|
|
50
|
+
def initialize(options = {})
|
|
51
|
+
requires!(options, :login, :password)
|
|
52
|
+
@options = options
|
|
53
|
+
super
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
# Note that #authorize and #capture only work if your account
|
|
57
|
+
# vendor is St George, and if your account has been setup as
|
|
58
|
+
# described in "Programming for NetRegistry's E-commerce
|
|
59
|
+
# Gateway." [http://rubyurl.com/hNG]
|
|
60
|
+
def authorize(money, credit_card, options = {})
|
|
61
|
+
params = {
|
|
62
|
+
'AMOUNT' => amount(money),
|
|
63
|
+
'CCNUM' => credit_card.number,
|
|
64
|
+
'CCEXP' => expiry(credit_card)
|
|
65
|
+
}
|
|
66
|
+
add_request_details(params, options)
|
|
67
|
+
commit(:authorization, params)
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
# Note that #authorize and #capture only work if your account
|
|
71
|
+
# vendor is St George, and if your account has been setup as
|
|
72
|
+
# described in "Programming for NetRegistry's E-commerce
|
|
73
|
+
# Gateway." [http://rubyurl.com/hNG]
|
|
74
|
+
def capture(money, authorization, options = {})
|
|
75
|
+
requires!(options, :credit_card)
|
|
76
|
+
credit_card = options[:credit_card]
|
|
77
|
+
|
|
78
|
+
params = {
|
|
79
|
+
'PREAUTHNUM' => authorization,
|
|
80
|
+
'AMOUNT' => amount(money),
|
|
81
|
+
'CCNUM' => credit_card.number,
|
|
82
|
+
'CCEXP' => expiry(credit_card)
|
|
83
|
+
}
|
|
84
|
+
add_request_details(params, options)
|
|
85
|
+
commit(:capture, params)
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
def purchase(money, credit_card, options = {})
|
|
89
|
+
params = {
|
|
90
|
+
'AMOUNT' => amount(money),
|
|
91
|
+
'CCNUM' => credit_card.number,
|
|
92
|
+
'CCEXP' => expiry(credit_card)
|
|
93
|
+
}
|
|
94
|
+
add_request_details(params, options)
|
|
95
|
+
commit(:purchase, params)
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
def credit(money, identification, options = {})
|
|
99
|
+
params = {
|
|
100
|
+
'AMOUNT' => amount(money),
|
|
101
|
+
'TXNREF' => identification
|
|
102
|
+
}
|
|
103
|
+
add_request_details(params, options)
|
|
104
|
+
commit(:credit, params)
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
# Specific to NetRegistry.
|
|
108
|
+
#
|
|
109
|
+
# Run a 'status' command. This lets you view the status of a
|
|
110
|
+
# completed transaction.
|
|
111
|
+
#
|
|
112
|
+
def status(identification)
|
|
113
|
+
params = {
|
|
114
|
+
'TXNREF' => identification
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
commit(:status, params)
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
private
|
|
121
|
+
def add_request_details(params, options)
|
|
122
|
+
params['COMMENT'] = options[:description] unless options[:description].blank?
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
# Return the expiry for the given creditcard in the required
|
|
126
|
+
# format for a command.
|
|
127
|
+
def expiry(credit_card)
|
|
128
|
+
month = format(credit_card.month, :two_digits)
|
|
129
|
+
year = format(credit_card.year , :two_digits)
|
|
130
|
+
"#{month}/#{year}"
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
# Post the a request with the given parameters and return the
|
|
134
|
+
# response object.
|
|
135
|
+
#
|
|
136
|
+
# Login and password are added automatically, and the comment is
|
|
137
|
+
# omitted if nil.
|
|
138
|
+
def commit(action, params)
|
|
139
|
+
# get gateway response
|
|
140
|
+
response = parse( ssl_post(URL, post_data(action, params)) )
|
|
141
|
+
|
|
142
|
+
Response.new(response['status'] == 'approved', message_from(response), response,
|
|
143
|
+
:authorization => authorization_from(response, action)
|
|
144
|
+
)
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
def post_data(action, params)
|
|
148
|
+
params['COMMAND'] = TRANSACTIONS[action]
|
|
149
|
+
params['LOGIN'] = "#{@options[:login]}/#{@options[:password]}"
|
|
150
|
+
URI.encode(params.map{|k,v| "#{k}=#{v}"}.join('&'))
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
def parse(response)
|
|
154
|
+
params = {}
|
|
155
|
+
|
|
156
|
+
lines = response.split("\n")
|
|
157
|
+
|
|
158
|
+
# Just incase there is no real response returned
|
|
159
|
+
params['status'] = lines[0]
|
|
160
|
+
params['response_text'] = lines[1]
|
|
161
|
+
|
|
162
|
+
started = false
|
|
163
|
+
lines.each do |line|
|
|
164
|
+
if started
|
|
165
|
+
key, val = line.chomp.split(/=/, 2)
|
|
166
|
+
params[key] = val unless FILTERED_PARAMS.include?(key)
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
started = line.chomp =~ /^\.$/ unless started
|
|
170
|
+
end
|
|
171
|
+
|
|
172
|
+
params
|
|
173
|
+
end
|
|
174
|
+
|
|
175
|
+
def message_from(response)
|
|
176
|
+
response['response_text']
|
|
177
|
+
end
|
|
178
|
+
|
|
179
|
+
def authorization_from(response, command)
|
|
180
|
+
case command
|
|
181
|
+
when :purchase
|
|
182
|
+
response['txn_ref']
|
|
183
|
+
when :authorization
|
|
184
|
+
response['transaction_no']
|
|
185
|
+
end
|
|
186
|
+
end
|
|
187
|
+
end
|
|
188
|
+
end
|
|
189
|
+
end
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
module ActiveMerchant #:nodoc:
|
|
2
|
+
module Billing #:nodoc:
|
|
3
|
+
class NetbillingGateway < Gateway
|
|
4
|
+
URL = 'https://secure.netbilling.com:1402/gw/sas/direct3.1'
|
|
5
|
+
|
|
6
|
+
TRANSACTIONS = {
|
|
7
|
+
:authorization => 'A',
|
|
8
|
+
:purchase => 'S',
|
|
9
|
+
:referenced_credit => 'R',
|
|
10
|
+
:unreferenced_credit => 'C',
|
|
11
|
+
:capture => 'D'
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
SUCCESS_CODES = [ '1', 'T' ]
|
|
15
|
+
SUCCESS_MESSAGE = 'The transaction was approved'
|
|
16
|
+
FAILURE_MESSAGE = 'The transaction failed'
|
|
17
|
+
TEST_LOGIN = '104901072025'
|
|
18
|
+
|
|
19
|
+
self.display_name = 'NETbilling'
|
|
20
|
+
self.homepage_url = 'http://www.netbilling.com'
|
|
21
|
+
self.supported_countries = ['US']
|
|
22
|
+
self.supported_cardtypes = [:visa, :master, :american_express, :discover, :jcb, :diners_club]
|
|
23
|
+
|
|
24
|
+
def initialize(options = {})
|
|
25
|
+
requires!(options, :login)
|
|
26
|
+
@options = options
|
|
27
|
+
super
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def authorize(money, credit_card, options = {})
|
|
31
|
+
post = {}
|
|
32
|
+
add_amount(post, money)
|
|
33
|
+
add_invoice(post, options)
|
|
34
|
+
add_credit_card(post, credit_card)
|
|
35
|
+
add_address(post, credit_card, options)
|
|
36
|
+
add_customer_data(post, options)
|
|
37
|
+
|
|
38
|
+
commit(:authorization, money, post)
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def purchase(money, credit_card, options = {})
|
|
42
|
+
post = {}
|
|
43
|
+
add_amount(post, money)
|
|
44
|
+
add_invoice(post, options)
|
|
45
|
+
add_credit_card(post, credit_card)
|
|
46
|
+
add_address(post, credit_card, options)
|
|
47
|
+
add_customer_data(post, options)
|
|
48
|
+
|
|
49
|
+
commit(:purchase, money, post)
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def capture(money, authorization, options = {})
|
|
53
|
+
post = {}
|
|
54
|
+
add_reference(post, authorization)
|
|
55
|
+
commit(:capture, money, post)
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def test?
|
|
59
|
+
@options[:login] == TEST_LOGIN || super
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
private
|
|
63
|
+
def add_amount(post, money)
|
|
64
|
+
post[:amount] = amount(money)
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def add_reference(post, reference)
|
|
68
|
+
post[:orig_id] = reference
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def add_customer_data(post, options)
|
|
72
|
+
post[:cust_email] = options[:email]
|
|
73
|
+
post[:cust_ip] = options[:ip]
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def add_address(post, credit_card, options)
|
|
77
|
+
if billing_address = options[:billing_address] || options[:address]
|
|
78
|
+
post[:bill_street] = billing_address[:address1]
|
|
79
|
+
post[:cust_phone] = billing_address[:phone]
|
|
80
|
+
post[:bill_zip] = billing_address[:zip]
|
|
81
|
+
post[:bill_city] = billing_address[:city]
|
|
82
|
+
post[:bill_country] = billing_address[:country]
|
|
83
|
+
post[:bill_state] = billing_address[:state]
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
if shipping_address = options[:shipping_address]
|
|
87
|
+
first_name, last_name = parse_first_and_last_name(shipping_address[:name])
|
|
88
|
+
|
|
89
|
+
post[:ship_name1] = first_name
|
|
90
|
+
post[:ship_name2] = last_name
|
|
91
|
+
post[:ship_street] = shipping_address[:address1]
|
|
92
|
+
post[:ship_zip] = shipping_address[:zip]
|
|
93
|
+
post[:ship_city] = shipping_address[:city]
|
|
94
|
+
post[:ship_country] = shipping_address[:country]
|
|
95
|
+
post[:ship_state] = shipping_address[:state]
|
|
96
|
+
end
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
def add_invoice(post, options)
|
|
100
|
+
post[:description] = options[:description]
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
def add_credit_card(post, credit_card)
|
|
104
|
+
post[:bill_name1] = credit_card.first_name
|
|
105
|
+
post[:bill_name2] = credit_card.last_name
|
|
106
|
+
post[:card_number] = credit_card.number
|
|
107
|
+
post[:card_expire] = expdate(credit_card)
|
|
108
|
+
post[:card_cvv2] = credit_card.verification_value
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
def parse(body)
|
|
112
|
+
results = {}
|
|
113
|
+
body.split(/&/).each do |pair|
|
|
114
|
+
key,val = pair.split(/=/)
|
|
115
|
+
results[key.to_sym] = CGI.unescape(val)
|
|
116
|
+
end
|
|
117
|
+
results
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
def commit(action, money, parameters)
|
|
121
|
+
response = parse(ssl_post(URL, post_data(action, parameters)))
|
|
122
|
+
|
|
123
|
+
Response.new(success?(response), message_from(response), response,
|
|
124
|
+
:test => test_response?(response),
|
|
125
|
+
:authorization => response[:trans_id],
|
|
126
|
+
:avs_result => { :code => response[:avs_code]},
|
|
127
|
+
:cvv_result => response[:cvv2_code]
|
|
128
|
+
)
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
def test_response?(response)
|
|
132
|
+
!!(test? || response[:auth_msg] =~ /TEST/)
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
def success?(response)
|
|
136
|
+
SUCCESS_CODES.include?(response[:status_code])
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
def message_from(response)
|
|
140
|
+
success?(response) ? SUCCESS_MESSAGE : (response[:auth_msg] || FAILURE_MESSAGE)
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
def expdate(credit_card)
|
|
144
|
+
year = sprintf("%.4i", credit_card.year)
|
|
145
|
+
month = sprintf("%.2i", credit_card.month)
|
|
146
|
+
|
|
147
|
+
"#{month}#{year[-2..-1]}"
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
def post_data(action, parameters = {})
|
|
151
|
+
parameters[:account_id] = @options[:login]
|
|
152
|
+
parameters[:pay_type] = 'C'
|
|
153
|
+
parameters[:tran_type] = TRANSACTIONS[action]
|
|
154
|
+
|
|
155
|
+
parameters.reject{|k,v| v.blank?}.collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join("&")
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
def parse_first_and_last_name(value)
|
|
159
|
+
name = value.to_s.split(' ')
|
|
160
|
+
|
|
161
|
+
last_name = name.pop || ''
|
|
162
|
+
first_name = name.join(' ')
|
|
163
|
+
[ first_name, last_name ]
|
|
164
|
+
end
|
|
165
|
+
end
|
|
166
|
+
end
|
|
167
|
+
end
|
|
168
|
+
|
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
require 'rexml/document'
|
|
2
|
+
|
|
3
|
+
module ActiveMerchant #:nodoc:
|
|
4
|
+
module Billing #:nodoc:
|
|
5
|
+
# = Ogone DirectLink Gateway
|
|
6
|
+
#
|
|
7
|
+
# DirectLink is the API version of the Ogone Payment Platform. It allows server to server
|
|
8
|
+
# communication between Ogone systems and your e-commerce website.
|
|
9
|
+
#
|
|
10
|
+
# This implementation follows the specification provided in the DirectLink integration
|
|
11
|
+
# guide version 2.4 (December 2008), available here:
|
|
12
|
+
# https://secure.ogone.com/ncol/Ogone_DirectLink_EN.pdf
|
|
13
|
+
#
|
|
14
|
+
# It also features aliases, which allow to store/unstore credit cards, as specified in
|
|
15
|
+
# the Alias Manager Option guide version 2.2 available here:
|
|
16
|
+
# https://secure.ogone.com/ncol/Ogone_Alias_EN.pdf
|
|
17
|
+
#
|
|
18
|
+
# It was last tested on Release 04.79 of Ogone e-Commerce (dated 11/02/2009).
|
|
19
|
+
#
|
|
20
|
+
# For any questions or comments, please contact Nicolas Jacobeus (nj@belighted.com).
|
|
21
|
+
#
|
|
22
|
+
# == Example use:
|
|
23
|
+
#
|
|
24
|
+
# gateway = ActiveMerchant::Billing::OgoneGateway.new(
|
|
25
|
+
# :login => "my_ogone_psp_id",
|
|
26
|
+
# :user => "my_ogone_user_id",
|
|
27
|
+
# :password => "my_ogone_pswd",
|
|
28
|
+
# :signature => "my_ogone_sha1_signature" # extra security, only if you configured your Ogone environment so
|
|
29
|
+
# )
|
|
30
|
+
#
|
|
31
|
+
# # set up credit card obj as in main ActiveMerchant example
|
|
32
|
+
# creditcard = ActiveMerchant::Billing::CreditCard.new(
|
|
33
|
+
# :type => 'visa',
|
|
34
|
+
# :number => '4242424242424242',
|
|
35
|
+
# :month => 8,
|
|
36
|
+
# :year => 2009,
|
|
37
|
+
# :first_name => 'Bob',
|
|
38
|
+
# :last_name => 'Bobsen'
|
|
39
|
+
# )
|
|
40
|
+
#
|
|
41
|
+
# # run request
|
|
42
|
+
# response = gateway.purchase(1000, creditcard, :order_id => "1") # charge 10 EUR
|
|
43
|
+
#
|
|
44
|
+
# If you don't provide an :order_id, the gateway will generate a random one for you.
|
|
45
|
+
#
|
|
46
|
+
# puts response.success? # Check whether the transaction was successful
|
|
47
|
+
# puts response.message # Retrieve the message returned by Ogone
|
|
48
|
+
# puts response.authorization # Retrieve the unique transaction ID returned by Ogone
|
|
49
|
+
#
|
|
50
|
+
# To use the alias feature, simply add :alias in the options hash:
|
|
51
|
+
#
|
|
52
|
+
# gateway.purchase(1000, creditcard, :order_id => "1", :alias => "myawesomecustomer") # associates the alias to that creditcard
|
|
53
|
+
# gateway.purchase(2000, nil, :order_id => "2", :alias => "myawesomecustomer") # don't need to know the creditcard for subsequent orders
|
|
54
|
+
#
|
|
55
|
+
class OgoneGateway < Gateway
|
|
56
|
+
|
|
57
|
+
URLS = {
|
|
58
|
+
:test => { :order => 'https://secure.ogone.com/ncol/test/orderdirect.asp',
|
|
59
|
+
:maintenance => 'https://secure.ogone.com/ncol/test/maintenancedirect.asp' },
|
|
60
|
+
:production => { :order => 'https://secure.ogone.com/ncol/prod/orderdirect.asp',
|
|
61
|
+
:maintenance => 'https://secure.ogone.com/ncol/prod/maintenancedirect.asp' }
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
CVV_MAPPING = { 'OK' => 'M',
|
|
65
|
+
'KO' => 'N',
|
|
66
|
+
'NO' => 'P' }
|
|
67
|
+
|
|
68
|
+
AVS_MAPPING = { 'OK' => 'M',
|
|
69
|
+
'KO' => 'N',
|
|
70
|
+
'NO' => 'R' }
|
|
71
|
+
SUCCESS_MESSAGE = "The transaction was successful"
|
|
72
|
+
|
|
73
|
+
self.supported_countries = ['BE', 'DE', 'FR', 'NL', 'AT', 'CH']
|
|
74
|
+
# also supports Airplus and UATP
|
|
75
|
+
self.supported_cardtypes = [:visa, :master, :american_express, :diners_club, :discover, :jcb, :maestro]
|
|
76
|
+
self.homepage_url = 'http://www.ogone.com/'
|
|
77
|
+
self.display_name = 'Ogone'
|
|
78
|
+
self.default_currency = 'EUR'
|
|
79
|
+
self.money_format = :cents
|
|
80
|
+
|
|
81
|
+
def initialize(options = {})
|
|
82
|
+
requires!(options, :login, :user, :password)
|
|
83
|
+
@options = options
|
|
84
|
+
super
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
# Verify and reserve the specified amount on the account, without actually doing the transaction.
|
|
88
|
+
def authorize(money, payment_source, options = {})
|
|
89
|
+
post = {}
|
|
90
|
+
add_invoice(post, options)
|
|
91
|
+
add_payment_source(post, payment_source, options)
|
|
92
|
+
add_address(post, payment_source, options)
|
|
93
|
+
add_customer_data(post, options)
|
|
94
|
+
add_money(post, money, options)
|
|
95
|
+
commit('RES', post)
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
# Verify and transfer the specified amount.
|
|
99
|
+
def purchase(money, payment_source, options = {})
|
|
100
|
+
post = {}
|
|
101
|
+
add_invoice(post, options)
|
|
102
|
+
add_payment_source(post, payment_source, options)
|
|
103
|
+
add_address(post, payment_source, options)
|
|
104
|
+
add_customer_data(post, options)
|
|
105
|
+
add_money(post, money, options)
|
|
106
|
+
commit('SAL', post)
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
# Complete a previously authorized transaction.
|
|
110
|
+
def capture(money, authorization, options = {})
|
|
111
|
+
post = {}
|
|
112
|
+
add_authorization(post, reference_from(authorization))
|
|
113
|
+
add_invoice(post, options)
|
|
114
|
+
add_customer_data(post, options)
|
|
115
|
+
add_money(post, money, options)
|
|
116
|
+
commit('SAL', post)
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
# Cancels a previously authorized transaction.
|
|
120
|
+
def void(identification, options = {})
|
|
121
|
+
post = {}
|
|
122
|
+
add_authorization(post, reference_from(identification))
|
|
123
|
+
commit('DES', post)
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
# Credit the specified account by a specific amount.
|
|
127
|
+
def credit(money, identification_or_credit_card, options = {})
|
|
128
|
+
if reference_transaction?(identification_or_credit_card)
|
|
129
|
+
# Referenced credit: refund of a settled transaction
|
|
130
|
+
perform_reference_credit(money, identification_or_credit_card, options)
|
|
131
|
+
else # must be a credit card or card reference
|
|
132
|
+
perform_non_referenced_credit(money, identification_or_credit_card, options)
|
|
133
|
+
end
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
private
|
|
137
|
+
def reference_from(authorization)
|
|
138
|
+
authorization.split(";").first
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
def reference_transaction?(identifier)
|
|
142
|
+
return false unless identifier.is_a?(String)
|
|
143
|
+
reference, action = identifier.split(";")
|
|
144
|
+
!action.nil?
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
def perform_reference_credit(money, payment_target, options = {})
|
|
148
|
+
post = {}
|
|
149
|
+
add_authorization(post, reference_from(payment_target))
|
|
150
|
+
add_money(post, money, options)
|
|
151
|
+
commit('RFD', post)
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
def perform_non_referenced_credit(money, payment_target, options = {})
|
|
155
|
+
# Non-referenced credit: acts like a reverse purchase
|
|
156
|
+
post = {}
|
|
157
|
+
add_invoice(post, options)
|
|
158
|
+
add_payment_source(post, payment_target, options)
|
|
159
|
+
add_address(post, payment_target, options)
|
|
160
|
+
add_customer_data(post, options)
|
|
161
|
+
add_money(post, money, options)
|
|
162
|
+
commit('RFD', post)
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
def add_payment_source(post, payment_source, options)
|
|
166
|
+
if payment_source.is_a?(String)
|
|
167
|
+
add_alias(post, payment_source)
|
|
168
|
+
add_eci(post, '9')
|
|
169
|
+
else
|
|
170
|
+
add_alias(post, options[:store])
|
|
171
|
+
add_creditcard(post, payment_source)
|
|
172
|
+
end
|
|
173
|
+
end
|
|
174
|
+
|
|
175
|
+
def add_eci(post, eci)
|
|
176
|
+
add_pair post, 'ECI', eci
|
|
177
|
+
end
|
|
178
|
+
|
|
179
|
+
def add_alias(post, _alias)
|
|
180
|
+
add_pair post, 'ALIAS', _alias
|
|
181
|
+
end
|
|
182
|
+
|
|
183
|
+
def add_authorization(post, authorization)
|
|
184
|
+
add_pair post, 'PAYID', authorization
|
|
185
|
+
end
|
|
186
|
+
|
|
187
|
+
def add_money(post, money, options)
|
|
188
|
+
add_pair post, 'currency', options[:currency] || currency(money)
|
|
189
|
+
add_pair post, 'amount', amount(money)
|
|
190
|
+
end
|
|
191
|
+
|
|
192
|
+
def add_customer_data(post, options)
|
|
193
|
+
add_pair post, 'EMAIL', options[:email]
|
|
194
|
+
add_pair post, 'REMOTE_ADDR', options[:ip]
|
|
195
|
+
end
|
|
196
|
+
|
|
197
|
+
def add_address(post, creditcard, options)
|
|
198
|
+
return unless options[:billing_address]
|
|
199
|
+
add_pair post, 'Owneraddress', options[:billing_address][:address1]
|
|
200
|
+
add_pair post, 'OwnerZip', options[:billing_address][:zip]
|
|
201
|
+
add_pair post, 'ownertown', options[:billing_address][:city]
|
|
202
|
+
add_pair post, 'ownercty', options[:billing_address][:country]
|
|
203
|
+
add_pair post, 'ownertelno', options[:billing_address][:phone]
|
|
204
|
+
end
|
|
205
|
+
|
|
206
|
+
def add_invoice(post, options)
|
|
207
|
+
add_pair post, 'orderID', options[:order_id] || generate_unique_id[0...30]
|
|
208
|
+
add_pair post, 'COM', options[:description]
|
|
209
|
+
end
|
|
210
|
+
|
|
211
|
+
def add_creditcard(post, creditcard)
|
|
212
|
+
add_pair post, 'CN', creditcard.name
|
|
213
|
+
add_pair post, 'CARDNO', creditcard.number
|
|
214
|
+
add_pair post, 'ED', "%02d%02s" % [creditcard.month, creditcard.year.to_s[-2..-1]]
|
|
215
|
+
add_pair post, 'CVC', creditcard.verification_value
|
|
216
|
+
end
|
|
217
|
+
|
|
218
|
+
def parse(body)
|
|
219
|
+
xml = REXML::Document.new(body)
|
|
220
|
+
xml.root.attributes
|
|
221
|
+
end
|
|
222
|
+
|
|
223
|
+
def commit(action, parameters)
|
|
224
|
+
add_pair parameters, 'PSPID', @options[:login]
|
|
225
|
+
add_pair parameters, 'USERID', @options[:user]
|
|
226
|
+
add_pair parameters, 'PSWD', @options[:password]
|
|
227
|
+
url = URLS[test? ? :test : :production][parameters['PAYID'] ? :maintenance : :order ]
|
|
228
|
+
response = parse(ssl_post(url, post_data(action, parameters)))
|
|
229
|
+
options = { :authorization => [response["PAYID"], action].join(";"),
|
|
230
|
+
:test => test?,
|
|
231
|
+
:avs_result => { :code => AVS_MAPPING[response["AAVCheck"]] },
|
|
232
|
+
:cvv_result => CVV_MAPPING[response["CVCCheck"]] }
|
|
233
|
+
Response.new(successful?(response), message_from(response), response, options)
|
|
234
|
+
end
|
|
235
|
+
|
|
236
|
+
def successful?(response)
|
|
237
|
+
response["NCERROR"] == "0"
|
|
238
|
+
end
|
|
239
|
+
|
|
240
|
+
def message_from(response)
|
|
241
|
+
successful?(response) ? SUCCESS_MESSAGE : response["NCERRORPLUS"].to_s.strip.gsub("|", ", ")
|
|
242
|
+
end
|
|
243
|
+
|
|
244
|
+
def post_data(action, parameters = {})
|
|
245
|
+
add_pair parameters, 'Operation' , action
|
|
246
|
+
if @options[:signature] # the user wants a SHA-1 signature
|
|
247
|
+
string = ['orderID','amount','currency','CARDNO','PSPID','Operation','ALIAS'].map{|s|parameters[s]}.join + @options[:signature]
|
|
248
|
+
add_pair parameters, 'SHASign' , Digest::SHA1.hexdigest(string)
|
|
249
|
+
end
|
|
250
|
+
parameters.collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join("&")
|
|
251
|
+
end
|
|
252
|
+
|
|
253
|
+
def add_pair(post, key, value, options = {})
|
|
254
|
+
post[key] = value if !value.blank? || options[:required]
|
|
255
|
+
end
|
|
256
|
+
|
|
257
|
+
end
|
|
258
|
+
end
|
|
259
|
+
end
|