Skip to content

Latest commit

 

History

History
74 lines (62 loc) · 2.25 KB

README.md

File metadata and controls

74 lines (62 loc) · 2.25 KB

django-admitad

Build Status codecov Python versions Pypi

Django reusable app for integration with Admitad CPA via postback requests

Requirements

Installation

$ pip install django-admitad

Configuration

To enable django-admitad for your project you need to add admitad to INSTALLED_APPS:

INSTALLED_APPS = [
    ...
    'admitad'
]

You also need to configure some Admitad CPA settings:

ADMITAD_COMPAIN_CODE = 'example_compain'
ADMITAD_POSTBACK_URL = 'https://ad.admitad.com/r'
ADMITAD_POSTBACK_KEY = 'example_postback_key'

Don't forget to run migrations:

$ python manage.py makemigrations
$ python manage.py migrate

Usage

To send a postback requests, you need to create an Order and Item objects:

from admitad.gateway import Order, Item

item = Item(internal_id=1, item_price=100, tariff_code=1, quantity=2)
order = Order(internal_id=1, admitad_uid='12345', action_code=1)

And add Item objects to Order:

order.add_item(item)

Items can also be directly transferred to the order:

items = [Item(internal_id=1, item_price=100, tariff_code=1, quantity=2)]
order = Order(internal_id=1, admitad_uid='12345', action_code=1, items=items)

And finally send postback requests

order.send_postback_requests()

All sent requests and parameters are saved to the database and are accessible from the admin test

Changelog

Available here

TODO

  • Celery integration
  • Integration tests & test coverage (>90%)
  • Support for old versions of Python/Django

License

MIT