diff --git a/README.rst b/README.rst index 536b3d3..306dc73 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': '122242607', # 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 ~~~~~~~~~~~~~~~~ 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 766b0f0..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], @@ -262,7 +263,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', 'WEB')), + ('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