Welcome to SagePay payment gateway package for django-oscar’s documentation!

This package provides integration between django-oscar 0.6 or above and SagePay Direct payment gateway.

This project is a work in progress and still in development.

A direct integration enables you to collect your customers’ payment information on your own secure servers and securely pass card details across to SagePay to carry out authorisation and store them safely. This means that you can completely tailor the payment process to suit your business requirements.

Note

To use SagePay Direct method you will need a 128-bit SSL certificate to secure your payment pages.

Note

There is currently no support for form or server integrations.

Contents:

Installation and Configuration Guide

Installing Package

To get the latest stable release from PyPi:

$ pip install django-oscar-sagepay

To get the latest commit from GitHub:

$ pip install -e git+git://https://github.com/sparky300/django-oscar-sagepay.git#egg=sagepay

Add sagepay to your INSTALLED_APPS:

INSTALLED_APPS = (
   ...,
   'sagepay',
   )

Add the sagepay URLs to your urls.py:

urlpatterns = patterns('',
  ...
  url(r'^sagepay/', include('sagepay.urls')),
  )

Then migrate your database:

./manage.py migrate sagepay

Configuration Settings

In order to test your integration first create a Sage Pay Simulator Account. Once this has been created you will be given the following...

  • Vendor Name
  • User Name
  • Password

Add the settings from the details you were given:

SAGEPAY_VENDOR = 'YOUR_VENDOR_NAME'
SAGEPAY_PASSWORD = 'YOUR_PASSWORD'
SAGEPAY_CURRENCY = 'GBP'
SAGEPAY_VPS_PROTOCOL = '2.23'
# Options are Live, Test and Simulator
SAGEPAY_MODE = 'Simulator'

Note that both currency and protocol are optional settings, if not set defaults will be used.

Integration into checkout

You will first need to create a local version of Oscar’s checkout app. See Oscar’s documentation on how to create a local version.

You’ll then need to use a subclass of sagepay.views.SagePayDetailsView within your own checkout views.:

from sagepay.views import SagePayDetailsView

class PaymentDetailsView(SagePayDetailsView):
    pass

SagePayDetailsView is actually a subclass of Oscar’s own oscar.apps.checkout.views.PaymentDetailsView class.

Testing in Sandbox

Sandbox Installation

At the time of writing this django-oscar does not have a pip install for version 0.6 or above. Because of this I have removed django-oscar from the setup.py list of requirements. You will need to first install Oscar 0.6 directly from github i.e. git clone git@github.com:tangentlabs/django-oscar.git.

To run the plugin in sandbox mode please perform the following steps:

$ virtualenv django-env
$ source django-env/bin/activate
$ make sandbox
$ sandbox/manage.py runserver
$ make clean

SagePay Test Credit Card Numbers

This is a list of the SagePay test credit card numbers you can use to test transactions in SagePay Direct when in test and simulator mode.

There are many different test credit card numbers available to use with the SagePay test server and at each stage you must ensure you enter the numbers and other details required correctly - failure to do so will return a Not Matched message.

  • Visa - 4929000000006
  • Visa Delta (Debit) - 4462000000000003
  • Visa Electron UK Debit - 4917300000000008
  • Mastercard - 5404000000000001
  • UK Maestro - 5641820000000005
  • International Maestro - 300000000000000004
  • American Express - 374200000000004
  • Japan Credit Bureau (JCB) - 3569990000000009
  • Diners Club - 36000000000008
  • Laser Cards - 6304990000000000044

Please note that these Sage Pay test card numbers cannot be used on the live server, where a real debit or credit card must be used to put through a test transaction.

  • Expiry Date: any date in the future
  • CV2: 123
  • Billing Address: 88 (you only have to use this on the first line)
  • Billing Postcode: 412
  • 3D Secure Password: password (not used in version 0.1 of django-oscar-sagepay)

Checkout Mode Banner

django-oscar-sagepay ships with an optional custom tag that displays a banner dictating what checkout mode you are running. For example, if you are running in simulator mode i.e. SAGEPAY_MODE = 'Simulator' a message banner could be displayed on the payment details view.

Adding the Checkout Banner

The banner is not installed by default and is entirely optional. To add the checkout banner simply add the tage to the required view:

{% load checkout_mode_tag %}
{{ bankcard_form.as_table }}

Another example would be to add the custom tag the payment details template:

{% load checkout_mode_tag %}
{% block payment_details_content %}
{% banner %}

<form action="{% url 'checkout:preview' %}" class="form-stacked" method="POST">
    {% csrf_token %}
    {{ bankcard_form.as_table }}
</form>
{% endblock %}

Indices and tables