Package: django-oscar-datacash
This package provides integration with the payment gateway,DataCash.  It is designed to
work seamlessly with the e-commerce frameworkdjango-oscarbut can be used without
Oscar.It also supports batch fraud screening using The3rdMan.PyPI homepageGetting startedSandboxWhen following the below instructions, it may be helpful to browse the sandbox
folder above as this is an example Oscar install which has been integrated with
Datacash.InstallationFrom PyPi:pip install django-oscar-datacashor from Github:pip install git+git://github.com/tangentlabs/django-oscar-datacash.git#egg=django-oscar-datacashAdd'datacash'toINSTALLED_APPSand run:./manage.py migrate datacashto create the appropriate database tables.ConfigurationEdit yoursettings.pyto set the following settings:DATACASH_HOST = 'testserver.datacash.com'
DATACASH_CLIENT = '...'
DATACASH_PASSWORD = '...'
DATACASH_CURRENCY = 'GBP'There are other settings available (see below).  Obviously, you’ll need to
specify different settings in your test environment as opposed to your
production environment.Integration into checkoutYou’ll need to use a subclass ofoscar.apps.checkout.views.PaymentDetailsViewwithin your own
checkout views.  SeeOscar’s documentationon how to create a local version of the checkout app.Override thehandle_paymentmethod (which does nothing by default) and add your integration code. Seethe sandbox sitefor an example of integrating Datacash payments
into an Oscar site.LoggingThe gateway modules uses the named loggerdatacash.The3rdMan callbacks use the named loggerdatacash.the3rdman.  It is
recommended that you usedjango.utils.log.AdminMailHandlerwith this logger
to ensure error emails are sent out for 500 responses.Integration trouble-shootingMany Datacash features require your merchant account to be configured correctly.
For instance, the default Datacash set-up won’t include:Payments using historic transactionsSplit settlementsWhen investigating problems, make sure your Datacash account is set-up
correctly.Integration with The3rdManUsing realtime fraud services requires submitting a dict of relevant data as part
of the initial transaction.  A helper method is provided that will extract all
it needs from Oscar’s models:fromdatacash.the3rdmanimportbuild_data_dictfraud_data=build_data_dict(request=request,order_number='1234',basket=request.basket,email=emailshipping_address=shipping_address,billing_addres=billing_address)then pass this data as a named argument when creating the transaction:ref=Facade().pre_authorise(...,the3rdman_data=fraud_data)To receive the callback, include the following in yoururls.py:urlpatterns=patterns('',...(r'^datacash/',include('datacash.urls')),...)When a fraud response is received, a custom signal is raised which your client
code should listen for.  Example:fromdjango.dispatchimportreceiverfromdatacash.the3rdmanimportsignals@receiver(signals.response_received)defhandle_fraud_response(sender,response,**kwargs):# Do something with responsePackages structureThere are two key components:GatewayThe classdatacash.gateway.Gatewayprovides fine-grained access to the
various DataCash APIs, which involve constructing XML requests and decoding XML
responses.  All calls return adatacash.gateway.Responseinstance which
provides dictionary-like access to the attributes of the response.Example calls:fromdecimalimportDecimalasDfromdatacash.gatewayimportGatewaygateway=Gateway()# Single stage processingresponse=gateway.auth(amount=D('100.00'),currency='GBP',merchant_reference='AA_1234',card_number='4500203021916406',expiry_date='10/14',ccv='345')response=gateway.refund(amount=D('100.00'),currency='GBP',merchant_reference='AA_1234',card_number='4500203021916406',expiry_date='10/14',ccv='345')# Two-stage processing (using pre-registered card)response=gateway.pre(amount=D('50.00'),currency='GBP',previous_txn_reference='3000000088888888')response=gateway.fulfill(amount=D('50.00'),currency='GBP',txn_reference=response['datacash_reference'])The gateway object know nothing of Oscar’s classes and can be used in a stand-alone
manner.FacadeThe classdatacash.facade.Facadewraps the above gateway object and provides a
less granular API, as well as saving instances ofdatacash.models.OrderTransactionto
provide an audit trail for Datacash activity.SettingsDATACASH_HOST- Host of DataCash serverDATACASH_CLIENT- UsernameDATACASH_PASSWORD- PasswordDATACASH_CURRENCY- Currency to use for transactionsDATACASH_USE_CV2AVS- Whether to pass CV2AVS dataDATACASH_CAPTURE_METHOD- The ‘capture method’ to use.  Defaults to ‘ecomm’.ContributingTo work ondjango-oscar-datacash, clone the repo, set up a virtualenv and install
in develop mode:make installThe test suite can then be run using:./runtests.pyThere is a sandbox Oscar site that can be used for development.  Create it
with:make sandboxand browse it with:python sandbox/manage.py runserverMagic card numbers are available on the Datacash site:https://testserver.datacash.com/software/download.cgi?show=magicnumbersHere’s an example:1000010000000007Have fun!Changelog0.8.3Added support for Python 30.8.2Added support for Django 1.70.8.1Drop use of deprecated bankcard attribute0.8Ensure compatibility with Oscar 0.7Drop support for Oscar 0.4 and 0.50.7Ensure compatibility with Django 1.6 and Oscar 0.60.6.2Ensure templates are compatible with Django 1.5Ensure tests pass with Oscar 0.60.6.1Format country codes in fraud submission.  They must be 3 digits.0.6Allow the transaction currency to be set pre transaction.  This is to support
the new multi-currency features of Oscar 0.6.0.5.3Fix logging formatting bug0.5.2Remove uniqueness constraint for 3rdman responseAdd links to Gatekeeper from dashboard0.5.1Adjust how the response type of callback is determined0.5Add support for The3rdMan fraud screening0.4.2Fix mis-handling of datetimes introduced in 0.4.10.4.1Handle bankcard dates passed asdatetime.datetimeinstances instead of
strings.  This is a compatability fix for Oscar 0.6 development.0.4Oscar 0.5 support0.3.5 / 2012-07-08Merchants passwords now removed from saved raw request XMLA random int is now appended to the merchant ref to avoid having duplicates0.3.4 / 2012-07-08Minor tweak to sort order of transactions in dashboard0.3.2, 0.3.3 / 2012-06-13Updated packaging to include HTML templates0.3.1 / 2012-06-12Added handling for split shipment payments0.3 / 2012-05-10Added sandbox siteAdded dashboard view of transactions0.2.3 / 2012-05-09Added admin.pyAdded travis.ci support0.2.2 / 2012-02-14Fixed bug with currency in refund transactions0.2.1 / 2012-02-7Fixed issue with submitting currency attribute for historic transactions