MyChoice2Pay Python
Overview
MyChoice2Pay Python provides integration access to the MyChoice2Pay API.
Installation
You can install using pip:
pip install --upgrade mc2p-python
or easy_install
easy_install --upgrade mc2p-python
or to install from source, run:
python setup.py install
Quick Start Example
from mc2p import MC2P
mc2p = MC2PClient('KEY', 'SECRET_KEY')
# Create transaction
transaction = mc2p.Transaction({
"currency": "EUR",
"products": [{
"amount": 1,
"product_id": "PRODUCT-ID"
}]
})
# or with product details
transaction = mc2p.Transaction({
"currency": "EUR",
"products": [{
"amount": 1,
"product": {
"name": "Product",
"price": 5
}
}]
})
transaction.save()
transaction.pay_url # Send user to this url to pay
transaction.iframe_url # Use this url to show an iframe in your site
# Get plans
plans_paginator = mc2p.plan.list()
plans_paginator.count
plans_paginator.results # Application's plans
plans_paginator.get_next_list()
# Get product, change and save
product = mc2p.Product.get("PRODUCT-ID")
product.price = 10
product.save()
# Create and delete tax
tax = mc2p.Tax({
"name": "Tax",
"percent": 5
})
tax.save()
tax.delete()
# Check if transaction was paid
transaction = mc2p.Transaction.get("TRANSACTION-ID")
transaction.status == 'D' # Paid
# Create subscription
subscription = mc2p.Subscription({
"currency": "EUR",
"plan_id": "PLAN-ID",
"note": "Note example"
})
# or with plan details
subscription = mc2p.Subscription({
"currency": "EUR",
"plan": {
"name": "Plan",
"price": 5,
"duration": 1,
"unit": "M",
"recurring": True
},
"note": "Note example"
})
subscription.save()
subscription.pay_url # Send user to this url to pay
subscription.iframe_url # Use this url to show an iframe in your site
# Receive a notification
notification_data = mc2p.NotificationData(JSON_DICT_RECEIVED_FROM_MYCHOICE2PAY)
notification_data.status == 'D' # Paid
notification_data.transaction # Transaction Paid
notification_data.sale # Sale generated
Exceptions
from mc2p.errors import InvalidRequestError
# Incorrect data
shipping = mc2p.Shipping({
"name": "Normal shipping",
"price": "text" # Price must be number
})
try:
shipping.save()
except InvalidRequestError as e:
e._message # Status code of error
e.json_body # Info from server
e.resource # Resource used to make the server request
e.resource_id # Resource id requested
Metadata
Release files for mc2p-python 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-python-0.1.6.tar.gz | 10.1 kB | Without provenance | Details |
Release files / mc2p-python-0.1.6.tar.gz
| Download URL | mc2p-python-0.1.6.tar.gz |
|---|---|
| Size | 10.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
703eb2f067b21461f1dbe0e10542366c4c0a2fd15375fadbec160912e184ecb1
|
|
BLAKE2b-256 checksum How to use checksums |
867a64be61dba74744961d9186953822704edd456e07afb745a6791aa25bc0fa
|
| 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.1
|
Security for mc2p-python 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.