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.
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.
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.2.1
Explicitly dis-allow cache on API views
0.2.0
Add setting to allow configuring how many payment types may be used on an order
Add hook for setting the ownership information on an order during placement
Prevent PaymentEvent.reference from ever being None
0.1.5
Fix bug where order number wouldn’t be recycled for a declined order
0.1.4
Add context to payment method serializers
0.1.3
Simplify dependencies
0.1.2
Allow PaymentMethods to handle 0.00-amount transactions
0.1.1
Send confirmation message upon order authorization
Add pep8 linting
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
Hashes for django-oscar-api-checkout-0.2.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 57ef9dced02d8cf3edf189b3b14df0a755d743053e8d36f003301c36926d5b27 |
|
MD5 | 0cf368c7604f917a16cdba8654a42a40 |
|
BLAKE2b-256 | bbc68053ffd9a9dc81627cd17951f195cce8bfe9feeaf96f8e7715af39880752 |
Hashes for django-oscar-api-checkout-0.2.1.macosx-10.11-x86_64.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 032921e62eed819098719e51f5daa4df1119dc1f4ff54fea93995cdcd10304c2 |
|
MD5 | 732a1a5e255fe949a087c94aa40b7bc8 |
|
BLAKE2b-256 | 0f2f295a98db8498f47b5c2537fb907b7ed24fdf3a9716d3a33500c0631116da |