Package: django-oscar-docdata
Payment gateway integration forDocdata Paymentsindjango-oscar.
DocData Payments is a large payment gateway based in The Netherlands that supports more than
40 international payment methods.InstallationInstall via pip:pipinstalldjango-oscar-docdataConfigurationConfigure the application:DOCDATA_MERCHANT_NAMECredentials as supplied by the payment provider.DOCDATA_MERCHANT_PASSWORDCredentials as supplied by the payment provider.DOCDATA_PROFILEThe payment-methods profile that is created in the Docdata Backoffice.
By default, this is named “standard”.DOCDATA_TESTINGWhether or not to run in testing mode. Defaults toTrue.Add tourls.py:fromoscar_docdata.dashboard.appimportapplicationasdocdata_dashboard_appurlpatterns+=[url(r'^api/docdata/',include('oscar_docdata.urls')),url(r'^dashboard/docdata/',include(docdata_dashboard_app.urls)),]Add tosettings.py:OSCAR_DASHBOARD_NAVIGATION[2]['children'].insert(1,{'label':_('Docdata Orders'),'url_name':'docdata-order-list',})While developing, enabling logging forsudsandoscar_docdatais recommended to see
detailed information:LOGGING={# ...'loggers':{# ...'suds.transport':{'handlers':['console'],'level':'DEBUG','propagate':True,},'oscar_docdata':{'handlers':['mail_admins','console'],'level':'DEBUG','propagate':True,},},}Extra: subaccount supportDocdata allows creating multiple accounts under the same contract.  This is called a “sub account”.
Each account has it’s own connections to VISA/MasterCard/PayPal/etc.
This module supports such use-case.When you fill in theDOCDATA_MERCHANT_PASSWORDSdictionary,
orders submitted to any of these merchants can be displayed in the admin,
and they can receive status updates. Each key/value is a merchant-name/password pair.When no subaccounts are configured, only the orders submitted by the current merchant can be displayed in the admin.
This supports a multi-tennant database structure, while each tennant only sees their own orders.Integration into your projectPlease view thesandbox applicationhow to integrate the application.
This includes the project-specific decisions such as:How to create payment events.How to create a custom facade classWhich fields to map to the “house number” field. (e.g.line2,line3or a custom field).Whether to cancel an order when the customer aborted the payment.When to submit confirmation emails.Local development and running the testsYou can use the included Makefile to install a development environment and to run the flake8
checker and the testrunner. Make sure you do this inside a virtualenv:gitclonegit@github.com:django-oscar/django-oscar-docdata.gitcddjango-oscar-docdatamakeinstallmakelintmaketestRunning the Sandbox applicationIt is possible to run thesandbox applicationto test this package and to see if your
Docdata credentials work. You can set theDOCDATA_MERCHANT_NAME,DOCDATA_MERCHANT_PASSWORDandDOCDATA_PROFILEenvironment variables before runningmanage.py:# creates a local sqlite database./sandbox/manage.pymigrate# loads some sample products (books)./sandbox/manage.pyoscar_import_cataloguesandbox/fixtures/books.csv# so you can fill out your shipping address./sandbox/manage.pyloaddatasandbox/fixtures/countries.json# run the sandbox installation with the docdata merchant username, password and profileDOCDATA_MERCHANT_NAME=merchantDOCDATA_MERCHANT_PASSWORD=merchantDOCDATA_PROFILE=test./sandbox/manage.pyrunserverDocdata is really keen on having unique merchant order ids. Why is not really clear as they don’t
use this references (they use their own). To avoid conflicts, the sandbox app adds the current datetime
as a prefix.Docdata’s payment menu allows you to choose a payment method available so you don’t need this in
the checkout application. You can disable the sandbox payment method selection with the following
environment variable:SKIP_PAYMENT_CHOICES=1Configuration of the Docdata BackofficeMake sure the following settings are configured:The “Payment Method names” need to be added to a profile (default value ofDOCDATA_PROFILEis “standard”).The notification URL and return URL need to be set. Example values:Success:http://example.org/api/docdata/update_order/?callback=SUCCESS&order_id=Cancelled:http://example.org/api/docdata/update_order/?callback=CANCELLED&order_id=Error:http://example.org/api/docdata/update_order/?callback=ERROR&order_id=Pending:http://example.org/api/docdata/update_order/?callback=PENDING&order_id=Update URL:http://example.org/api/docdata/update_order/?order_id=Docdata Payment Service SpecificationSee thepaymentServicespecification for
detailed technical information.CaveatsWhile working with the Docdata 1.0, 1.2 and 1.3 API, we found the following limitations:Address fields are oriented towards Dutch address standards.
Passing international address fields is hard, or requires hacking, for example:Faking the house number (because the US address fields have no official field for that).Streets have a limit of 35 characters, so the “Address Line 1” should be truncated.Passing invalid address fields could cause PayPal, VISA or MasterCard transactions to fail.PayPal payments may fail when the “state” field is invalid (e.g. because of a typo). This is a check done by PayPal. Docdata however, passes that responsibility to the merchant (you).The<billTo><address><state>field is typically ignored. Provide it via<invoice><shipTo><address><state>. Seriously.The individual payment objects have a status value, but the payment cluster does not.
This means that there is no global status value to read.
If an order has been cancelled before starting a payment, there is no way to tell from the API.
The only way this can be detected, is when the customer presses the “Back to shop” link, which calls the cancel callback url.
You may want to catch thereturn_view_calledsignal for this.Determining that an order has been paid happens by comparing “received >= expected”.
This could break with currency conversions.
Again, because the payment cluster status is not exposed in the API.
As workaround, there is aDOCDATA_PAYMENT_SUCCESS_MARGINsetting to add a margin of 100 cents.Be prepared to have XSD validation errors for bad input. For example, a bad postcode, house number or exceeding a max length leads to errors like:REQUEST_DATA_INCORRECT
XML request does not match XSD. The data is: cvc-type.3.1.3: The value 'This is a wonderful product and campaign! Wish you a lot of luck!' of element 'ns0:description' is not validWe hope this will be addressed by Docdata Payments in future versions of the API.