Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 145 lines (96 sloc) 4.203 kb
f071c1a @codeinthehole Created readme - rest of initial code to follow shortly
codeinthehole authored
1 =================================
2 Datacash package for django-oscar
3 =================================
d0b931a @codeinthehole Updated tests to use a mock for DC responses
codeinthehole authored
4
606faab @codeinthehole Updated documentation
codeinthehole authored
5 This package provides integration with the payment gateway, DataCash. It is designed to
6 integrate seamlessly with the e-commerce framework `django-oscar`_ but can be used without
7 using oscar.
8
3c1a3ad @codeinthehole Switched the exception that the facade raises
codeinthehole authored
9 .. _`django-oscar`: https://github.com/tangentlabs/django-oscar
10
606faab @codeinthehole Updated documentation
codeinthehole authored
11 Getting started
12 ===============
13
d0b931a @codeinthehole Updated tests to use a mock for DC responses
codeinthehole authored
14 Installation
15 ------------
16
606faab @codeinthehole Updated documentation
codeinthehole authored
17 From PyPi::
d0b931a @codeinthehole Updated tests to use a mock for DC responses
codeinthehole authored
18
19 pip install django-oscar-datacash
20
21 or from Github::
22
23 pip install -e git://github.com/tangentlabs/django-oscar-datacash.git#egg=django-oscar-datacash
24
25 Add ``datacash`` to ``INSTALLED_APPS`` and run::
26
27 ./manage.py migrate datacash
28
606faab @codeinthehole Updated documentation
codeinthehole authored
29 to create the appropriate database tables.
30
31 Configuration
32 -------------
33
34 Edit your ``settings.py`` to set the following settings::
35
36 DATACASH_HOST = 'testserver.datacash.com'
37 DATACASH_CLIENT = '...'
38 DATACASH_PASSWORD = '...'
3c1a3ad @codeinthehole Switched the exception that the facade raises
codeinthehole authored
39 DATACASH_CURRENCY = 'GBP
40
41 There are other settings available (see below).
606faab @codeinthehole Updated documentation
codeinthehole authored
42
43 Integration into checkout
44 -------------------------
45
46 You'll need to use a subclass of ``oscar.apps.checkout.views.PaymentDetails`` within your own
47 checkout views. Override the ``handle_payment`` method add your integration code. An example
48 integration might look like::
49
50 # myshop.checkout.views
51 from oscar.apps.checkout.views import PaymentDetails as OscarPaymentDetails
52 from oscar.apps.payment.utils import Bankcard
53 from datacash.facade import Facade
54
55 ...
56
57 class PaymentDetails(OscarPaymentDetails):
58
59 def handle_payment(self, order_number, total, **kwargs):
60 # Create bankcard object
61 ...
62 facade = Facade()
63 facade.authorise(order_number, total, bankcard)
64
65 Oscar's view will handle the various exceptions that can get raised. See DataCash's documentation
66 for further details on the various processing models that are available.
67
68 Packages structure
69 ==================
70
3c1a3ad @codeinthehole Switched the exception that the facade raises
codeinthehole authored
71 There are two key components:
606faab @codeinthehole Updated documentation
codeinthehole authored
72
73 Gateway
74 -------
75
76 The class ``datacash.gateway.Gateway`` provides fine-grained access to the
77 various DataCash APIs, which involve constructing XML requests and decoding XML
78 responses. All calls return a ``datacash.gateway.Response`` instance which
79 provides dictionary-like access to the attributes of the response.
80
81 Example calls::
82
83 from decimal import Decimal as D
84 from datacash.gateway import Gateway
85
86 gateway = Gateway()
87
88 # Single stage processing
89 response = gateway.auth(amount=D('100.00'), currency='GBP',
90 merchant_reference='AA_1234',
91 card_number='4500203021916406',
92 expiry_date='10/14',
93 ccv='345')
94
95 response = gateway.refund(amount=D('100.00'), currency='GBP',
96 merchant_reference='AA_1234',
97 card_number='4500203021916406',
98 expiry_date='10/14',
99 ccv='345')
100
101 # Two-stage processing (using pre-registered card)
102 response = gateway.pre(amount=D('50.00'), currency='GBP',
103 previous_txn_reference='3000000088888888')
104 response = gateway.fulfill(amount=D('50.00'), currency='GBP',
105 txn_reference=response['datacash_reference'])
106
107 The gateway object know nothing of Oscar's classes and can be used in a stand-alone
108 manner.
109
110 Facade
111 ------
112
113 The class ``datacash.facade.Facade`` wraps the above gateway object and provides a
114 less granular API, as well as saving instances of ``datacash.models.OrderTransaction`` to
115 provide an audit trail for Datacash activity.
d0b931a @codeinthehole Updated tests to use a mock for DC responses
codeinthehole authored
116
117 Settings
606faab @codeinthehole Updated documentation
codeinthehole authored
118 ========
d0b931a @codeinthehole Updated tests to use a mock for DC responses
codeinthehole authored
119
72b7ef7 @codeinthehole Added support for cancellations
codeinthehole authored
120 * ``DATACASH_HOST`` - Host of DataCash server
121
122 * ``DATACASH_CLIENT`` - Username
123
124 * ``DATACASH_PASSWORD`` - Password
125
126 * ``DATACASH_CURRENCY`` - Currency to use for transactions
71c2158 @codeinthehole Added test for CV2AVS
codeinthehole authored
127
128 * ``DATACASH_USE_CV2AVS`` - Whether to pass CV2AVS data
73b6d07 @codeinthehole Added notes for contributors and a requirements file
codeinthehole authored
129
130 Contributing
131 ============
132
133 To work on ``django-oscar-datacash``, clone the repo, set up a virtualenv and install
134 in develop mode::
135
136 python setup.py develop
137
138 then install the testing dependencies::
139
140 pip install -r requirements.txt
141
142 The test suite can then be run using::
143
144 ./run_tests.py
Something went wrong with that request. Please try again.