johnideal-activemerchant 1.4.4
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/.gitignore +2 -0
- data/CHANGELOG +448 -0
- data/CONTRIBUTERS +106 -0
- data/MIT-LICENSE +20 -0
- data/README +134 -0
- data/Rakefile +167 -0
- data/VERSION +1 -0
- data/activemerchant.gemspec +484 -0
- data/gem-public_cert.pem +20 -0
- data/generators/gateway/USAGE +5 -0
- data/generators/gateway/gateway_generator.rb +61 -0
- data/generators/gateway/templates/gateway.rb +77 -0
- data/generators/gateway/templates/gateway_test.rb +49 -0
- data/generators/gateway/templates/remote_gateway_test.rb +57 -0
- data/generators/integration/USAGE +5 -0
- data/generators/integration/integration_generator.rb +68 -0
- data/generators/integration/templates/helper.rb +34 -0
- data/generators/integration/templates/helper_test.rb +54 -0
- data/generators/integration/templates/integration.rb +18 -0
- data/generators/integration/templates/module_test.rb +9 -0
- data/generators/integration/templates/notification.rb +100 -0
- data/generators/integration/templates/notification_test.rb +41 -0
- data/init.rb +3 -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/authorize_net.rb +657 -0
- data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +703 -0
- data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +233 -0
- data/lib/active_merchant/billing/gateways/beanstream.rb +102 -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/eway.rb +277 -0
- data/lib/active_merchant/billing/gateways/exact.rb +222 -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 +205 -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/pay_junction.rb +392 -0
- data/lib/active_merchant/billing/gateways/pay_secure.rb +120 -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.rb +236 -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/paymentech_orbital/paymentech_orbital_response.rb +72 -0
- data/lib/active_merchant/billing/gateways/paymentech_orbital.rb +170 -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.rb +108 -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/protx.rb +307 -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/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.rb +146 -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 +165 -0
- data/lib/active_merchant/billing/gateways/wirecard.rb +318 -0
- data/lib/active_merchant/billing/gateways.rb +3 -0
- data/lib/active_merchant/billing/integrations/action_view_helper.rb +79 -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 +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/chronopay.rb +22 -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/gestpay.rb +26 -0
- data/lib/active_merchant/billing/integrations/helper.rb +93 -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 +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 +87 -0
- data/lib/active_merchant/billing/integrations/notification.rb +62 -0
- data/lib/active_merchant/billing/integrations/paypal/helper.rb +118 -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/paypal.rb +40 -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/quickpay.rb +18 -0
- data/lib/active_merchant/billing/integrations/return.rb +35 -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/integrations/two_checkout.rb +23 -0
- data/lib/active_merchant/billing/integrations.rb +22 -0
- data/lib/active_merchant/billing/response.rb +32 -0
- data/lib/active_merchant/lib/connection.rb +171 -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/active_merchant.rb +60 -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 +335 -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_eway_test.rb +74 -0
- data/test/remote/gateways/remote_exact_test.rb +60 -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 +82 -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_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_paymentech_orbital_test.rb +57 -0
- data/test/remote/gateways/remote_paypal_express_test.rb +49 -0
- data/test/remote/gateways/remote_paypal_test.rb +167 -0
- data/test/remote/gateways/remote_plugnpay_test.rb +72 -0
- data/test/remote/gateways/remote_protx_test.rb +219 -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_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 +170 -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/eway_test.rb +118 -0
- data/test/unit/gateways/exact_test.rb +156 -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 +158 -0
- data/test/unit/gateways/net_registry_test.rb +416 -0
- data/test/unit/gateways/netbilling_test.rb +54 -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/paymentech_orbital_test.rb +117 -0
- data/test/unit/gateways/paypal_express_test.rb +382 -0
- data/test/unit/gateways/paypal_test.rb +520 -0
- data/test/unit/gateways/plugnpay_test.rb +86 -0
- data/test/unit/gateways/protx_test.rb +139 -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_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 +162 -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 +503 -0
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
require 'rexml/document'
|
|
2
|
+
|
|
3
|
+
module ActiveMerchant #:nodoc:
|
|
4
|
+
module Billing #:nodoc:
|
|
5
|
+
|
|
6
|
+
# In NZ DPS supports ANZ, Westpac, National Bank, ASB and BNZ.
|
|
7
|
+
# In Australia DPS supports ANZ, NAB, Westpac, CBA, St George and Bank of South Australia.
|
|
8
|
+
# The Maybank in Malaysia is supported and the Citibank for Singapore.
|
|
9
|
+
class PaymentExpressGateway < Gateway
|
|
10
|
+
self.default_currency = 'NZD'
|
|
11
|
+
# PS supports all major credit cards; Visa, Mastercard, Amex, Diners, BankCard & JCB.
|
|
12
|
+
# Various white label cards can be accepted as well; Farmers, AirNZCard and Elders etc.
|
|
13
|
+
# Please note that not all acquirers and Eftpos networks can support some of these card types.
|
|
14
|
+
# VISA, Mastercard, Diners Club and Farmers cards are supported
|
|
15
|
+
#
|
|
16
|
+
# However, regular accounts with DPS only support VISA and Mastercard
|
|
17
|
+
self.supported_cardtypes = [ :visa, :master, :american_express, :diners_club, :jcb ]
|
|
18
|
+
|
|
19
|
+
self.supported_countries = [ 'AU', 'MY', 'NZ', 'SG', 'ZA', 'GB', 'US' ]
|
|
20
|
+
|
|
21
|
+
self.homepage_url = 'http://www.paymentexpress.com/'
|
|
22
|
+
self.display_name = 'PaymentExpress'
|
|
23
|
+
|
|
24
|
+
URL = 'https://www.paymentexpress.com/pxpost.aspx'
|
|
25
|
+
|
|
26
|
+
APPROVED = '1'
|
|
27
|
+
|
|
28
|
+
TRANSACTIONS = {
|
|
29
|
+
:purchase => 'Purchase',
|
|
30
|
+
:credit => 'Refund',
|
|
31
|
+
:authorization => 'Auth',
|
|
32
|
+
:capture => 'Complete',
|
|
33
|
+
:validate => 'Validate'
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
# We require the DPS gateway username and password when the object is created.
|
|
37
|
+
def initialize(options = {})
|
|
38
|
+
# A DPS username and password must exist
|
|
39
|
+
requires!(options, :login, :password)
|
|
40
|
+
# Make the options an instance variable
|
|
41
|
+
@options = options
|
|
42
|
+
super
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
# Funds are transferred immediately.
|
|
46
|
+
def purchase(money, payment_source, options = {})
|
|
47
|
+
request = build_purchase_or_authorization_request(money, payment_source, options)
|
|
48
|
+
commit(:purchase, request)
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
# NOTE: Perhaps in options we allow a transaction note to be inserted
|
|
52
|
+
# Verifies that funds are available for the requested card and amount and reserves the specified amount.
|
|
53
|
+
# See: http://www.paymentexpress.com/technical_resources/ecommerce_nonhosted/pxpost.html#Authcomplete
|
|
54
|
+
def authorize(money, payment_source, options = {})
|
|
55
|
+
request = build_purchase_or_authorization_request(money, payment_source, options)
|
|
56
|
+
commit(:authorization, request)
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
# Transfer pre-authorized funds immediately
|
|
60
|
+
# See: http://www.paymentexpress.com/technical_resources/ecommerce_nonhosted/pxpost.html#Authcomplete
|
|
61
|
+
def capture(money, identification, options = {})
|
|
62
|
+
request = build_capture_or_credit_request(money, identification, options)
|
|
63
|
+
commit(:capture, request)
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
# Refund funds to the card holder
|
|
67
|
+
def credit(money, identification, options = {})
|
|
68
|
+
requires!(options, :description)
|
|
69
|
+
|
|
70
|
+
request = build_capture_or_credit_request(money, identification, options)
|
|
71
|
+
commit(:credit, request)
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
# token based billing
|
|
75
|
+
|
|
76
|
+
# initiates a "Validate" transcation to store card data on payment express servers
|
|
77
|
+
# returns a "token" that can be used to rebill this card
|
|
78
|
+
# see: http://www.paymentexpress.com/technical_resources/ecommerce_nonhosted/pxpost.html#Tokenbilling
|
|
79
|
+
# PaymentExpress does not support unstoring a stored card.
|
|
80
|
+
def store(credit_card, options = {})
|
|
81
|
+
request = build_token_request(credit_card, options)
|
|
82
|
+
commit(:validate, request)
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
private
|
|
86
|
+
|
|
87
|
+
def build_purchase_or_authorization_request(money, payment_source, options)
|
|
88
|
+
result = new_transaction
|
|
89
|
+
|
|
90
|
+
if payment_source.is_a?(String)
|
|
91
|
+
add_billing_token(result, payment_source)
|
|
92
|
+
else
|
|
93
|
+
add_credit_card(result, payment_source)
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
add_amount(result, money, options)
|
|
97
|
+
add_invoice(result, options)
|
|
98
|
+
add_address_verification_data(result, options)
|
|
99
|
+
result
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
def build_capture_or_credit_request(money, identification, options)
|
|
103
|
+
result = new_transaction
|
|
104
|
+
|
|
105
|
+
add_amount(result, money, options)
|
|
106
|
+
add_invoice(result, options)
|
|
107
|
+
add_reference(result, identification)
|
|
108
|
+
result
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
def build_token_request(credit_card, options)
|
|
112
|
+
result = new_transaction
|
|
113
|
+
add_credit_card(result, credit_card)
|
|
114
|
+
add_amount(result, 100, options) #need to make an auth request for $1
|
|
115
|
+
add_token_request(result, options)
|
|
116
|
+
result
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
def add_credentials(xml)
|
|
120
|
+
xml.add_element("PostUsername").text = @options[:login]
|
|
121
|
+
xml.add_element("PostPassword").text = @options[:password]
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
def add_reference(xml, identification)
|
|
125
|
+
xml.add_element("DpsTxnRef").text = identification
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
def add_credit_card(xml, credit_card)
|
|
129
|
+
xml.add_element("CardHolderName").text = credit_card.name
|
|
130
|
+
xml.add_element("CardNumber").text = credit_card.number
|
|
131
|
+
xml.add_element("DateExpiry").text = format_date(credit_card.month, credit_card.year)
|
|
132
|
+
|
|
133
|
+
if credit_card.verification_value?
|
|
134
|
+
xml.add_element("Cvc2").text = credit_card.verification_value
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
if requires_start_date_or_issue_number?(credit_card)
|
|
138
|
+
xml.add_element("DateStart").text = format_date(credit_card.start_month, credit_card.start_year) unless credit_card.start_month.blank? || credit_card.start_year.blank?
|
|
139
|
+
xml.add_element("IssueNumber").text = credit_card.issue_number unless credit_card.issue_number.blank?
|
|
140
|
+
end
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
def add_billing_token(xml, token)
|
|
144
|
+
xml.add_element("DpsBillingId").text = token
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
def add_token_request(xml, options)
|
|
148
|
+
xml.add_element("BillingId").text = options[:billing_id] if options[:billing_id]
|
|
149
|
+
xml.add_element("EnableAddBillCard").text = 1
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
def add_amount(xml, money, options)
|
|
153
|
+
xml.add_element("Amount").text = amount(money)
|
|
154
|
+
xml.add_element("InputCurrency").text = options[:currency] || currency(money)
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
def add_transaction_type(xml, action)
|
|
158
|
+
xml.add_element("TxnType").text = TRANSACTIONS[action]
|
|
159
|
+
end
|
|
160
|
+
|
|
161
|
+
def add_invoice(xml, options)
|
|
162
|
+
xml.add_element("TxnId").text = options[:order_id].to_s.slice(0, 16) unless options[:order_id].blank?
|
|
163
|
+
xml.add_element("MerchantReference").text = options[:description] unless options[:description].blank?
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
def add_address_verification_data(xml, options)
|
|
167
|
+
address = options[:billing_address] || options[:address]
|
|
168
|
+
return if address.nil?
|
|
169
|
+
|
|
170
|
+
xml.add_element("EnableAvsData").text = 1
|
|
171
|
+
xml.add_element("AvsAction").text = 1
|
|
172
|
+
|
|
173
|
+
xml.add_element("AvsStreetAddress").text = address[:address1]
|
|
174
|
+
xml.add_element("AvsPostCode").text = address[:zip]
|
|
175
|
+
end
|
|
176
|
+
|
|
177
|
+
def new_transaction
|
|
178
|
+
REXML::Document.new.add_element("Txn")
|
|
179
|
+
end
|
|
180
|
+
|
|
181
|
+
# Take in the request and post it to DPS
|
|
182
|
+
def commit(action, request)
|
|
183
|
+
add_credentials(request)
|
|
184
|
+
add_transaction_type(request, action)
|
|
185
|
+
|
|
186
|
+
# Parse the XML response
|
|
187
|
+
response = parse( ssl_post(URL, request.to_s) )
|
|
188
|
+
|
|
189
|
+
# Return a response
|
|
190
|
+
PaymentExpressResponse.new(response[:success] == APPROVED, response[:response_text], response,
|
|
191
|
+
:test => response[:test_mode] == '1',
|
|
192
|
+
:authorization => response[:dps_txn_ref]
|
|
193
|
+
)
|
|
194
|
+
end
|
|
195
|
+
|
|
196
|
+
# Response XML documentation: http://www.paymentexpress.com/technical_resources/ecommerce_nonhosted/pxpost.html#XMLTxnOutput
|
|
197
|
+
def parse(xml_string)
|
|
198
|
+
response = {}
|
|
199
|
+
|
|
200
|
+
xml = REXML::Document.new(xml_string)
|
|
201
|
+
|
|
202
|
+
# Gather all root elements such as HelpText
|
|
203
|
+
xml.elements.each('Txn/*') do |element|
|
|
204
|
+
response[element.name.underscore.to_sym] = element.text unless element.name == 'Transaction'
|
|
205
|
+
end
|
|
206
|
+
|
|
207
|
+
# Gather all transaction elements and prefix with "account_"
|
|
208
|
+
# So we could access the MerchantResponseText by going
|
|
209
|
+
# response[account_merchant_response_text]
|
|
210
|
+
xml.elements.each('Txn/Transaction/*') do |element|
|
|
211
|
+
response[element.name.underscore.to_sym] = element.text
|
|
212
|
+
end
|
|
213
|
+
|
|
214
|
+
response
|
|
215
|
+
end
|
|
216
|
+
|
|
217
|
+
def format_date(month, year)
|
|
218
|
+
"#{format(month, :two_digits)}#{format(year, :two_digits)}"
|
|
219
|
+
end
|
|
220
|
+
end
|
|
221
|
+
|
|
222
|
+
class PaymentExpressResponse < Response
|
|
223
|
+
# add a method to response so we can easily get the token
|
|
224
|
+
# for Validate transactions
|
|
225
|
+
def token
|
|
226
|
+
@params["billing_id"] || @params["dps_billing_id"]
|
|
227
|
+
end
|
|
228
|
+
end
|
|
229
|
+
end
|
|
230
|
+
end
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
module ActiveMerchant
|
|
2
|
+
module Billing
|
|
3
|
+
class PaymentechOrbitalResponse
|
|
4
|
+
cattr_accessor :elements
|
|
5
|
+
|
|
6
|
+
self.elements = [
|
|
7
|
+
:industry_type, :message_type, :merchant_id,
|
|
8
|
+
:terminal_id, :card_brand, :account_num,
|
|
9
|
+
:order_id, :tx_ref_num, :tx_ref_idx, :proc_status,
|
|
10
|
+
:approval_status, :resp_code, :avs_resp_code,
|
|
11
|
+
:cvv2_resp_code, :auth_code, :status_msg, :resp_msg,
|
|
12
|
+
:customer_ref_num, :customer_name, :profile_proc_status,
|
|
13
|
+
:customer_profile_message, :resp_time
|
|
14
|
+
]
|
|
15
|
+
|
|
16
|
+
def initialize(doc, options={})
|
|
17
|
+
@doc = REXML::Document.new(doc)
|
|
18
|
+
@options = options
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def success?
|
|
22
|
+
proc_success? && approved?
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def proc_success?
|
|
26
|
+
proc_status == "0"
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def approved?
|
|
30
|
+
approval_status == "1"
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def authorization
|
|
34
|
+
approval_status
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def test?
|
|
38
|
+
@options[:test] || false
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def avs_result
|
|
42
|
+
@avs_result ||= AVSResult.new({:code => avs_resp_code})
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def cvv_result
|
|
46
|
+
@cvv_result ||= CVVResult.new({:code => cvv2_result_code})
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
private
|
|
50
|
+
def tagify(s)
|
|
51
|
+
s.to_s.gsub(/\/(.?)/) {
|
|
52
|
+
"::#{$1.upcase}"
|
|
53
|
+
}.gsub(/(?:^|_)(.)/) {
|
|
54
|
+
$1.upcase
|
|
55
|
+
}
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def value_at(sym)
|
|
59
|
+
node = REXML::XPath.first(@doc, "//#{tagify(sym)}")
|
|
60
|
+
node ? node.text : nil
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def method_missing(sym, *args, &blk)
|
|
64
|
+
if self.class.elements.include?(sym)
|
|
65
|
+
value_at(sym)
|
|
66
|
+
else
|
|
67
|
+
super(sym, *args, &blk)
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
end
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/paymentech_orbital/paymentech_orbital_response'
|
|
2
|
+
|
|
3
|
+
module ActiveMerchant #:nodoc:
|
|
4
|
+
module Billing #:nodoc:
|
|
5
|
+
class PaymentechOrbitalGateway < Gateway
|
|
6
|
+
cattr_accessor :enable_profile_management, :urls,
|
|
7
|
+
:currency_code, :currency_exponent
|
|
8
|
+
|
|
9
|
+
self.urls = {
|
|
10
|
+
:test => [
|
|
11
|
+
'https://orbitalvar1.paymentech.net/authorize',
|
|
12
|
+
'https://orbitalvar2.paymentech.net/authorize'
|
|
13
|
+
],
|
|
14
|
+
:live => [
|
|
15
|
+
'https://orbital1.paymentech.net/authorize',
|
|
16
|
+
'https://orbital2.paymentech.net/authorize'
|
|
17
|
+
]
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
# Currency information for the api.
|
|
21
|
+
self.currency_code = "840"
|
|
22
|
+
self.currency_exponent = "2"
|
|
23
|
+
|
|
24
|
+
# Money format
|
|
25
|
+
self.money_format = :cents
|
|
26
|
+
|
|
27
|
+
# The countries the gateway supports merchants from as 2 digit ISO country codes
|
|
28
|
+
self.supported_countries = ['US']
|
|
29
|
+
|
|
30
|
+
# The card types supported by the payment gateway
|
|
31
|
+
self.supported_cardtypes = [:visa, :master, :american_express, :discover]
|
|
32
|
+
|
|
33
|
+
# The homepage URL of the gateway
|
|
34
|
+
self.homepage_url = 'http://www.example.net/'
|
|
35
|
+
|
|
36
|
+
# The name of the gateway
|
|
37
|
+
self.display_name = 'Paymentect Orbital Gateway'
|
|
38
|
+
|
|
39
|
+
# Enable profile management?
|
|
40
|
+
self.enable_profile_management = true
|
|
41
|
+
|
|
42
|
+
def initialize(options = {})
|
|
43
|
+
requires!(options, :login, :password, :merchant_id, :bin, :terminal_id)
|
|
44
|
+
@options = options
|
|
45
|
+
super
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
[:login, :password, :merchant_id,
|
|
49
|
+
:bin, :terminal_id].each do |attr|
|
|
50
|
+
define_method(:"#{attr}") do
|
|
51
|
+
@options[:"#{attr}"]
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def authorize(money, creditcard, options = {})
|
|
56
|
+
request = build_request("NewOrder", money, options) do |xml|
|
|
57
|
+
add_credentials(xml, "A")
|
|
58
|
+
add_credit_card(xml, credit_card)
|
|
59
|
+
add_billing_address(xml, options[:billing_address]) if options[:billing_address]
|
|
60
|
+
add_profile_management(xml, options[:customer_ref_num]) if enable_profile_management?
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
commit('authonly', request)
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def purchase(money, credit_card=nil, options = {})
|
|
67
|
+
request = build_request("NewOrder", money, options) do |xml|
|
|
68
|
+
add_credentials(xml, "AC")
|
|
69
|
+
add_credit_card(xml, credit_card)
|
|
70
|
+
add_billing_address(xml, options[:billing_address]) if options[:billing_address]
|
|
71
|
+
add_profile_management(xml, options[:customer_ref_num]) if enable_profile_management?
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
commit('sale', request)
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
def capture(money, authorization, options = {})
|
|
78
|
+
commit('capture', money, post)
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
private
|
|
82
|
+
def build_request(request_type, money, options)
|
|
83
|
+
xml = Builder::XmlMarkup.new(:indent => 2)
|
|
84
|
+
|
|
85
|
+
xml.instruct!(:xml, :version => '1.0', :encoding => 'UTF-8')
|
|
86
|
+
xml.tag! "Request" do
|
|
87
|
+
xml.tag! request_type do
|
|
88
|
+
yield xml if block_given?
|
|
89
|
+
|
|
90
|
+
xml.tag! "OrderID", options[:order_id]
|
|
91
|
+
xml.tag! "Amount", money
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
xml.target!
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
def add_credentials(xml, message_type)
|
|
99
|
+
xml.tag! "OrbitalConnectionUsername", login
|
|
100
|
+
xml.tag! "OrbitalConnectionPassword", password
|
|
101
|
+
xml.tag! "IndustryType", "EC"
|
|
102
|
+
xml.tag! "MessageType", message_type
|
|
103
|
+
xml.tag! "BIN", bin
|
|
104
|
+
xml.tag! "MerchantID", merchant_id
|
|
105
|
+
xml.tag! "TerminalID", terminal_id
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
def add_credit_card(xml, credit_card=nil)
|
|
109
|
+
if credit_card
|
|
110
|
+
xml.tag! "CardBrand", card_brand(credit_card)
|
|
111
|
+
xml.tag! "AccountNum", credit_card.number
|
|
112
|
+
xml.tag! "Exp", "#{credit_card.month}#{credit_card.year}"
|
|
113
|
+
add_currency(xml)
|
|
114
|
+
xml.tag! "CardSecVal", credit_card.verification_value
|
|
115
|
+
else
|
|
116
|
+
xml.tag! "AccountNum", nil
|
|
117
|
+
add_currency(xml)
|
|
118
|
+
end
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
def add_currency(xml)
|
|
122
|
+
xml.tag! "CurrencyCode", self.class.currency_code
|
|
123
|
+
xml.tag! "CurrencyExponent", self.class.currency_exponent
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
def add_billing_address(xml, address)
|
|
127
|
+
xml.tag! "AVSzip", address[:zip]
|
|
128
|
+
xml.tag! "AVSaddress1", address[:address1]
|
|
129
|
+
xml.tag! "AVSaddress2", address[:address2]
|
|
130
|
+
xml.tag! "AVScity", address[:city]
|
|
131
|
+
xml.tag! "AVSstate", address[:state]
|
|
132
|
+
xml.tag! "AVSphoneNum" , address[:phone]
|
|
133
|
+
xml.tag! "AVSname", address[:name]
|
|
134
|
+
xml.tag! "AVScountryCode", address[:country]
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
def add_profile_management(xml, customer_ref_num=nil)
|
|
138
|
+
if customer_ref_num
|
|
139
|
+
xml.tag! "CustomerRefNum", customer_ref_num
|
|
140
|
+
else
|
|
141
|
+
xml.tag! "CustomerProfileFromOrderInd", "A"
|
|
142
|
+
xml.tag! "CustomerProfileOrderOverrideInd", "NO"
|
|
143
|
+
end
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
def commit(action, request)
|
|
147
|
+
resp = ssl_post(endpoint_url, request, {
|
|
148
|
+
"MIME-Version" => "1.0",
|
|
149
|
+
"Content-Type" => "Application/PTI46",
|
|
150
|
+
"Content-transfer-encoding" => "text",
|
|
151
|
+
"Request-number" => "1",
|
|
152
|
+
"Document-type" => "Request"
|
|
153
|
+
})
|
|
154
|
+
|
|
155
|
+
@response ||= PaymentechOrbitalResponse.new(resp, {
|
|
156
|
+
:test => test?
|
|
157
|
+
})
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
def endpoint_url
|
|
161
|
+
self.class.urls[Base.gateway_mode][0]
|
|
162
|
+
end
|
|
163
|
+
|
|
164
|
+
def enable_profile_management?
|
|
165
|
+
self.class.enable_profile_management
|
|
166
|
+
end
|
|
167
|
+
end
|
|
168
|
+
end
|
|
169
|
+
end
|
|
170
|
+
|