Skip to main content

An extension on top of django-oscar-api providing a more flexible checkout API with a pluggable payment methods interface.

Project description

build coverage license kit format

An extension on top of django-oscar-api providing a more flexible checkout API with a pluggable payment methods interface.

Compatible Payment Plugins

  • django-oscar-cybersource: Provides order payment using Cybersource Secure Acceptance Silent Order POST for PCI SAQ A-EP compliant credit card processing.

  • django-oscar-wfrs: Provides order payment using financing via the Wells Fargo Retail Services SOAP API.

Installation

  1. Install django-oscar-api using the documentation.

  2. Install the django-oscar-api-checkout package.:

    $ pip install django-oscar-api-checkout
  3. Add oscarapicheckout to your INSTALLED_APPS:

    # myproject/settings.py
    ...
    INSTALLED_APPS = [
        ...
        'oscarapicheckout',
    ] + get_core_apps([])
    ...
  4. Configure Oscar’s order status pipeline.:

    # myproject/settings.py
    ...
    # Needed by oscarapicheckout
    ORDER_STATUS_PENDING = 'Pending'
    ORDER_STATUS_PAYMENT_DECLINED = 'Payment Declined'
    ORDER_STATUS_AUTHORIZED = 'Authorized'
    
    # Other statuses
    ORDER_STATUS_SHIPPED = 'Shipped'
    ORDER_STATUS_CANCELED = 'Canceled'
    
    # Pipeline Config
    OSCAR_INITIAL_ORDER_STATUS = ORDER_STATUS_PENDING
    OSCARAPI_INITIAL_ORDER_STATUS = ORDER_STATUS_PENDING
    OSCAR_ORDER_STATUS_PIPELINE = {
        ORDER_STATUS_PENDING: (ORDER_STATUS_PAYMENT_DECLINED, ORDER_STATUS_AUTHORIZED, ORDER_STATUS_CANCELED),
        ORDER_STATUS_PAYMENT_DECLINED: (ORDER_STATUS_AUTHORIZED, ORDER_STATUS_CANCELED),
        ORDER_STATUS_AUTHORIZED: (ORDER_STATUS_SHIPPED, ORDER_STATUS_CANCELED),
        ORDER_STATUS_SHIPPED: (),
        ORDER_STATUS_CANCELED: (),
    }
    
    OSCAR_INITIAL_LINE_STATUS = ORDER_STATUS_PENDING
    OSCAR_LINE_STATUS_PIPELINE = {
        ORDER_STATUS_PENDING: (ORDER_STATUS_SHIPPED, ORDER_STATUS_CANCELED),
        ORDER_STATUS_SHIPPED: (),
        ORDER_STATUS_CANCELED: (),
    }
  5. Configure what payment methods are enabled and who can use them.:

    # myproject/settings.py
    ...
    API_ENABLED_PAYMENT_METHODS = [
        {
            'method': 'oscarapicheckout.methods.Cash',
            'permission': 'oscarapicheckout.permissions.StaffOnly',
        },
        {
            'method': 'some.other.methods.CreditCard',
            'permission': 'oscarapicheckout.permissions.Public',
        },
    ]
  6. Add oscarapicheckout to your root URL configuration directly before oscarapi.:

    # myproject/urls.py
    ...
    from django.apps import apps
    from oscarapi.app import application as oscar_api
    from oscarapicheckout.app import application as oscar_api_checkout
    
    urlpatterns = patterns('',
        ...
        url(r'^api/', include(apps.get_app_config("oscarapicheckout").urls[0])), # Must be before oscar_api.urls
        url(r'^api/', include(oscar_api.urls)),
        ...
    )

Usage

These are the basic steps to add an item to the basket and checkout using the API.

  1. Add an item to the basket.:

    POST /api/basket/add-product/
    
    {
        "url": "/api/products/1/",
        "quantity": 1
    }
  2. List the payment methods available to the current user.:

    GET /api/checkout/payment-methods/
  3. Submit the order, specifying which payment method(s) to use.:

    POST /api/checkout/
    
    {
        "guest_email": "joe@example.com",
        "basket": "/api/baskets/1/",
        "shipping_address": {
            "first_name": "Joe",
            "last_name": "Schmoe",
            "line1": "234 5th Ave",
            "line4": "Manhattan",
            "postcode": "10001",
            "state": "NY",
            "country": "/api/countries/US/",
            "phone_number": "+1 (717) 467-1111",
        },
        "billing_address": {
            "first_name": "Joe",
            "last_name": "Schmoe",
            "line1": "234 5th Ave",
            "line4": "Manhattan",
            "postcode": "10001",
            "state": "NY",
            "country": "/api/countries/US/",
            "phone_number": "+1 (717) 467-1111",
        },
        "payment": {
            "cash": {
                "enabled": true,
                "amount": "10.00",
            },
            "creditcard": {
                "enabled": true,
                "pay_balance": true,
            }
        }
    }
  4. Check the status of each enabled payment option.:

    GET /api/checkout/payment-states/

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django_oscar_api_checkout-3.5.1.tar.gz (32.2 kB view details)

Uploaded Source

Built Distribution

File details

Details for the file django_oscar_api_checkout-3.5.1.tar.gz.

File metadata

File hashes

Hashes for django_oscar_api_checkout-3.5.1.tar.gz
Algorithm Hash digest
SHA256 4964cd70a9c5b5e71aa3f62d5092691099fbbd67295b53fea92cbe75b64899c3
MD5 6e0d57e739294839b0261b7c28d62a8f
BLAKE2b-256 e1d25603c1df870f4e09c73a128fd82d69e2f35deb50e027f7caed567979919e

See more details on using hashes here.

Provenance

File details

Details for the file django_oscar_api_checkout-3.5.1-py3-none-any.whl.

File metadata

File hashes

Hashes for django_oscar_api_checkout-3.5.1-py3-none-any.whl
Algorithm Hash digest
SHA256 fbe8da56e117eb765e057ba57f2f9b5d0685d0189ee4453017c53c70ba03d5e9
MD5 004285c22e7f8543b1fefbdbdee3d5e1
BLAKE2b-256 edda3d3c56d372274a0368e02b76278893007263451ea0906c8e08b0a1bb0e26

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page