An extension on top of django-oscar-api providing a more flexible checkout API with a pluggable payment methods interface.
Project description
An extension on top of django-oscar-api providing a more flexible checkout API with a pluggable payment methods interface.
Installation
Install django-oscar-api using the documentation.
Install the django-oscar-api-checkout package.:
$ pip install django-oscar-api-checkout
Add oscarapicheckout to your INSTALLED_APPS:
# myproject/settings.py ... INSTALLED_APPS = [ ... 'oscarapicheckout', ] + get_core_apps([]) ...
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: (), }
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', }, ]
Add oscarapicheckout to your root URL configuration directly before oscarapi.:
# myproject/urls.py ... from oscarapi.app import application as oscar_api from oscarapicheckout.app import application as oscar_api_checkout urlpatterns = patterns('', ... url(r'^api/', include(oscar_api_checkout.urls)), # 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.
Add an item to the basket.:
POST /api/basket/add-product/ { "url": "/api/products/1/", "quantity": 1 }
List the payment methods available to the current user.:
GET /api/checkout/payment-methods/
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, } } }
Check the status of each enabled payment option.:
GET /api/checkout/payment-states/
Changelog
0.1.0
Initial release.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file django-oscar-api-checkout-0.1.2.tar.gz
.
File metadata
- Download URL: django-oscar-api-checkout-0.1.2.tar.gz
- Upload date:
- Size: 16.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1d04965bf6915fa429013077943fc1a714478e2a03fbb02f8b787d6eec11e0db |
|
MD5 | 1df743a9f46f634d3da25bc96cb40763 |
|
BLAKE2b-256 | ded989474b4a869c3e90ef71612aa62035cf71f53aeea8941ab7d7d25cb8480c |
File details
Details for the file django_oscar_api_checkout-0.1.2-py3-none-any.whl
.
File metadata
- Download URL: django_oscar_api_checkout-0.1.2-py3-none-any.whl
- Upload date:
- Size: 22.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d03430b446f565c3f7174c81f9af57f5305c1f2051980fc297be995f4f86df1a |
|
MD5 | 68af3950874b17721259c240d6eb37e6 |
|
BLAKE2b-256 | 021e648d1cee41239dda7125d824ea0bce10c47528ae55ae618da0c53282bad8 |