MyChoice2Pay Django
Overview
MyChoice2Pay Django provides integration access to the MyChoice2Pay API through django framework.
Requirements
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 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)
Metadata
Release files for mc2p-django 0.1.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| mc2p-django-0.1.6.tar.gz | 6.7 kB | Without provenance | Details |
Release files / mc2p-django-0.1.6.tar.gz
| Download URL | mc2p-django-0.1.6.tar.gz |
|---|---|
| Size | 6.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c0662812d803bdef3f371ea7499c594a54671d15b682f548246607ca897edbf2
|
|
BLAKE2b-256 checksum How to use checksums |
ef7a40251eb6a1d39e3259f24b015cc66a9285633d98f2e21c237908d972adee
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.12
|
Security for mc2p-django 0.1.6
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.