# MyChoice2Pay Django
# Overview
MyChoice2Pay Django provides integration access to the MyChoice2Pay API through django framework.
# Requirements
* [Django][django]
* [MyChoice2Pay Python][mc2p-python]
# Installation
Install using `pip`...
pip install mc2p-django
Add `'django_mc2p'` to your `INSTALLED_APPS` setting.
INSTALLED_APPS = (
...
'django_mc2p',
...
)
Add django_mc2p urls:
urlpatterns = patterns('',
...
url(r'^mc2p/', include('django_mc2p.urls'))
...
)
# Configuration
After execute migrations you must define KEY and SECRET KEY in administration site, section MyChoice2Pay Configuration.
You can obtain KEY and SECRET KEY from [MyChoice2Pay][mychoice2pay-site] site.
# Quick Example
### Basic transaction
# Sending user to pay
from django_mc2p import MC2PClient
mc2p = MC2PClient()
transaction = mc2p.Transaction({
"currency": "EUR",
"order_id": "order id",
"products": [{
"amount": 1,
"product": {
"name": "Product",
"price": 50
}
}],
"notify_url": "https://www.example.com" + reverse('mc2p-notify'),
"return_url": "https://www.example.com/your-return-url/",
"cancel_return": "https://www.example.com/your-cancel-url/"
})
transaction.save()
transaction.pay_url # Send user to this url to pay
# After user pay a notification will be sent to notify_url
from django_mc2p.constants import MC2P_PAYMENT_DONE
from django_mc2p.signals import notification_received
def check_payment(sender, **kwargs):
notification_data = sender
if notification_data.type == MC2P_TYPE_TRANSACTION and notification_data.status == MC2P_PAYMENT_DONE:
transaction = notification_data.transaction
sale = notification_data.sale
order_id = notification_data.order_id
# Use transaction, sale and order_id to check all the data and confirm the payment in your system
notification_received.connect(check_payment)
### Basic subscription
# Sending user to pay a subscription
from django_mc2p import MC2PClient
mc2p = MC2PClient()
subscription = mc2p.Subscription({
"currency": "EUR",
"order_id": "order id",
"plan": {
"name": "Plan",
"price": 5,
"duration": 1,
"unit": "M",
"recurring": true
},
"notify_url": "https://www.example.com" + reverse('mc2p-notify'),
"return_url": "https://www.example.com/your-return-url/",
"cancel_return": "https://www.example.com/your-cancel-url/"
})
subscription.save()
subscription.pay_url # Send user to this url to pay
# After user pay a notification will be sent to notify_url
from django_mc2p.constants import MC2P_PAYMENT_DONE
from django_mc2p.signals import notification_received
def check_payment(sender, **kwargs):
notification_data = sender
if notification_data.type == MC2P_TYPE_SUBSCRIPTION and notification_data.status == MC2P_PAYMENT_DONE:
subscription = notification_data.subscription
sale = notification_data.sale
order_id = notification_data.order_id
# Use subscription, sale and order_id to check all the data and confirm the payment in your system
notification_received.connect(check_payment)
[django]: https://www.djangoproject.com/
[mc2p-python]: https://github.com/mc2p/mc2p-python
[mychoice2pay-site]: https://www.mychoice2pay.com/
Raw data
{
"_id": null,
"home_page": "https://github.com/mc2p/mc2p-django",
"name": "mc2p-django",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "mychoice2pay,payments",
"author": "MyChoice2Pay",
"author_email": "support@mychoice2pay.com",
"download_url": "https://files.pythonhosted.org/packages/ef/7a/40251eb6a1d39e3259f24b015cc66a9285633d98f2e21c237908d972adee/mc2p-django-0.1.6.tar.gz",
"platform": null,
"description": "# MyChoice2Pay Django\n\n\n# Overview\n\nMyChoice2Pay Django provides integration access to the MyChoice2Pay API through django framework.\n\n\n# Requirements\n\n* [Django][django]\n* [MyChoice2Pay Python][mc2p-python]\n\n# Installation\n\nInstall using `pip`...\n\n pip install mc2p-django\n\nAdd `'django_mc2p'` to your `INSTALLED_APPS` setting.\n\n INSTALLED_APPS = (\n ...\n 'django_mc2p',\n ...\n )\n\nAdd django_mc2p urls:\n\n urlpatterns = patterns('',\n ...\n url(r'^mc2p/', include('django_mc2p.urls'))\n ...\n )\n\n# Configuration\n\nAfter execute migrations you must define KEY and SECRET KEY in administration site, section MyChoice2Pay Configuration.\n\nYou can obtain KEY and SECRET KEY from [MyChoice2Pay][mychoice2pay-site] site.\n\n# Quick Example\n\n### Basic transaction\n\n # Sending user to pay\n from django_mc2p import MC2PClient\n \n mc2p = MC2PClient()\n transaction = mc2p.Transaction({\n \"currency\": \"EUR\",\n \"order_id\": \"order id\",\n \"products\": [{\n \"amount\": 1,\n \"product\": {\n \"name\": \"Product\",\n \"price\": 50\n }\n }],\n \"notify_url\": \"https://www.example.com\" + reverse('mc2p-notify'),\n \"return_url\": \"https://www.example.com/your-return-url/\",\n \"cancel_return\": \"https://www.example.com/your-cancel-url/\"\n })\n transaction.save()\n transaction.pay_url # Send user to this url to pay\n \n # After user pay a notification will be sent to notify_url\n from django_mc2p.constants import MC2P_PAYMENT_DONE\n from django_mc2p.signals import notification_received\n \n def check_payment(sender, **kwargs):\n notification_data = sender\n if notification_data.type == MC2P_TYPE_TRANSACTION and notification_data.status == MC2P_PAYMENT_DONE:\n transaction = notification_data.transaction\n sale = notification_data.sale\n order_id = notification_data.order_id\n # Use transaction, sale and order_id to check all the data and confirm the payment in your system\n notification_received.connect(check_payment)\n\n### Basic subscription\n\n # Sending user to pay a subscription\n from django_mc2p import MC2PClient\n \n mc2p = MC2PClient()\n subscription = mc2p.Subscription({\n \"currency\": \"EUR\",\n \"order_id\": \"order id\",\n \"plan\": {\n \"name\": \"Plan\",\n \"price\": 5,\n \"duration\": 1,\n \"unit\": \"M\",\n \"recurring\": true\n },\n \"notify_url\": \"https://www.example.com\" + reverse('mc2p-notify'),\n \"return_url\": \"https://www.example.com/your-return-url/\",\n \"cancel_return\": \"https://www.example.com/your-cancel-url/\"\n })\n subscription.save()\n subscription.pay_url # Send user to this url to pay\n \n # After user pay a notification will be sent to notify_url\n from django_mc2p.constants import MC2P_PAYMENT_DONE\n from django_mc2p.signals import notification_received\n \n def check_payment(sender, **kwargs):\n notification_data = sender\n if notification_data.type == MC2P_TYPE_SUBSCRIPTION and notification_data.status == MC2P_PAYMENT_DONE:\n subscription = notification_data.subscription\n sale = notification_data.sale\n order_id = notification_data.order_id\n # Use subscription, sale and order_id to check all the data and confirm the payment in your system\n notification_received.connect(check_payment)\n\n[django]: https://www.djangoproject.com/\n[mc2p-python]: https://github.com/mc2p/mc2p-python\n[mychoice2pay-site]: https://www.mychoice2pay.com/\n",
"bugtrack_url": null,
"license": "BSD",
"summary": "MyChoice2Pay Django Bindings",
"version": "0.1.6",
"project_urls": {
"Download": "https://github.com/mc2p/mc2p-django/archive/v0.1.6.tar.gz",
"Homepage": "https://github.com/mc2p/mc2p-django"
},
"split_keywords": [
"mychoice2pay",
"payments"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "ef7a40251eb6a1d39e3259f24b015cc66a9285633d98f2e21c237908d972adee",
"md5": "d9ad052a8db1dbeeb2ffab05e74c8b14",
"sha256": "c0662812d803bdef3f371ea7499c594a54671d15b682f548246607ca897edbf2"
},
"downloads": -1,
"filename": "mc2p-django-0.1.6.tar.gz",
"has_sig": false,
"md5_digest": "d9ad052a8db1dbeeb2ffab05e74c8b14",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 6695,
"upload_time": "2024-02-09T17:45:18",
"upload_time_iso_8601": "2024-02-09T17:45:18.024777Z",
"url": "https://files.pythonhosted.org/packages/ef/7a/40251eb6a1d39e3259f24b015cc66a9285633d98f2e21c237908d972adee/mc2p-django-0.1.6.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-02-09 17:45:18",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "mc2p",
"github_project": "mc2p-django",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "mc2p-django"
}