Skip to main content

MyChoice2Pay Python Bindings

Project description

MyChoice2Pay Python


MyChoice2Pay Python provides integration access to the MyChoice2Pay API.

Build Status Coverage Status Code Health


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 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.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.results # Application's plans

# Get product, change and save
product = mc2p.Product.get("PRODUCT-ID")
product.price = 10

# Create and delete tax
tax = mc2p.Tax({
    "name": "Tax",
    "percent": 5

# 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.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 # Sale generated


from mc2p.errors import InvalidRequestError

# Incorrect data
shipping = mc2p.Shipping({
    "name": "Normal shipping",
    "price": "text" # Price must be number
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    

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for mc2p-python, version 0.1.4
Filename, size File type Python version Upload date Hashes
Filename, size mc2p_python-0.1.4-py3-none-any.whl (12.0 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size mc2p-python-0.1.4.tar.gz (11.4 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page