From e3bdf377be6aadb170e7e491309924f13a1e66d5 Mon Sep 17 00:00:00 2001 From: Gavin Wahl Date: Fri, 20 Jul 2012 11:39:22 -0600 Subject: [PATCH 1/4] authorize.net echeck xml --- dinero/gateways/authorizenet_gateway.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/dinero/gateways/authorizenet_gateway.py b/dinero/gateways/authorizenet_gateway.py index 766b0f0..15f7843 100644 --- a/dinero/gateways/authorizenet_gateway.py +++ b/dinero/gateways/authorizenet_gateway.py @@ -262,7 +262,24 @@ def _transaction_xml(self, price, options): ])) return xml + def _payment_check_xml(self, options): + return OrderedDict([ + ('bankAccount', OrderedDict([ + ('accountType', options['account_type']), + ('routingNumber', options['routing_number']), + ('accountNumber', options['account_number']), + ('nameOnAccount', options['name']), + # don't know what this default should be + ('echeckType', options.get('check_type', 'PPD')), + ('bankName', options.get('bank_name')), + ]) + ), + ]) + def _payment_xml(self, options): + if 'check' in options: + return self._payment_check_xml(options['check']) + year = str(options.get('year', '0')) if year != 'XXXX' and int(year) < 100: century = date.today().year // 100 From 91468f54c0f4d4f056488e84159a78d5bec973f3 Mon Sep 17 00:00:00 2001 From: Gavin Wahl Date: Tue, 25 Sep 2012 12:15:09 -0600 Subject: [PATCH 2/4] echeck example --- README.rst | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/README.rst b/README.rst index 536b3d3..ac1aeec 100644 --- a/README.rst +++ b/README.rst @@ -84,6 +84,23 @@ Transaction objects:: transaction.refund() + +E-Checks +^^^^^^^^ +Only authorize.net is supported for now. + +:: + transaction = dinero.Transaction.create(100, + check={ + 'account_type': 'checking', # 'checking', 'savings', 'businessChecking' + 'routing_number': '12242607', # must be a valid routing number, even during testing. + 'account_number': '411111111', + 'name': 'John Doe', + 'check_type': 'WEB', #optional, WEB is the default + 'bank_name': 'Bank of Dinero', + }) + + Customer Objects ~~~~~~~~~~~~~~~~ From 5a2b1138851d87dc73d007b55c910c911705affb Mon Sep 17 00:00:00 2001 From: Gavin Wahl Date: Tue, 25 Sep 2012 12:15:16 -0600 Subject: [PATCH 3/4] update defaults, catch more exceptions --- dinero/exceptions.py | 3 +++ dinero/gateways/authorizenet_gateway.py | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/dinero/exceptions.py b/dinero/exceptions.py index 85176d0..5cf1060 100644 --- a/dinero/exceptions.py +++ b/dinero/exceptions.py @@ -69,6 +69,9 @@ class RefundError(PaymentError): class InvalidTransactionError(PaymentError): pass +class RoutingNumberError(PaymentError): + pass + ##| ##| CUSTOMER diff --git a/dinero/gateways/authorizenet_gateway.py b/dinero/gateways/authorizenet_gateway.py index 15f7843..8cb6eb2 100644 --- a/dinero/gateways/authorizenet_gateway.py +++ b/dinero/gateways/authorizenet_gateway.py @@ -147,6 +147,7 @@ def get_first_of(dict, possibilities, default=None): RESPONSE_CODE_EXCEPTION_MAP = { + '9': [RoutingNumberError], '8': [ExpiryError], '6': [InvalidCardError], '37': [InvalidCardError], @@ -270,7 +271,7 @@ def _payment_check_xml(self, options): ('accountNumber', options['account_number']), ('nameOnAccount', options['name']), # don't know what this default should be - ('echeckType', options.get('check_type', 'PPD')), + ('echeckType', options.get('check_type', 'WEB')), ('bankName', options.get('bank_name')), ]) ), From 704e76611a8ac33865533da0ad6e876316239d7a Mon Sep 17 00:00:00 2001 From: Gavin Wahl Date: Tue, 25 Sep 2012 16:17:57 -0600 Subject: [PATCH 4/4] broke the routing number --- README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rst b/README.rst index ac1aeec..306dc73 100644 --- a/README.rst +++ b/README.rst @@ -93,7 +93,7 @@ Only authorize.net is supported for now. transaction = dinero.Transaction.create(100, check={ 'account_type': 'checking', # 'checking', 'savings', 'businessChecking' - 'routing_number': '12242607', # must be a valid routing number, even during testing. + 'routing_number': '122242607', # must be a valid routing number, even during testing. 'account_number': '411111111', 'name': 'John Doe', 'check_type': 'WEB', #optional, WEB is the default