Skip to main content

No project description provided

Project description

Python Telr Payment Gateway API

a simple module to integrate with telr api for python language

PyPI version

Overview

Installation

This module is a pip package for implement API's payment service of Telr. in order to use this module you have to install it by pip command or through setup.

pip install telr_payment

Import package into your project by:

from telr_payment.api import Telr

in order to use the module please consider looking at examples and documentations.

Usage

For easy implementations i have provided two simple examples, one for creating the transaction and one for checking which is like this

# order_sample.py
from telr_payment.api import Telr
from pprint import pprint

# if you dont want it to run in test mode change the test option according to docs
telr = Telr(auth_key = "YOUR_AUTH_KEY",store_id = "YOUR_STORE_ID",test=1)

order_response = telr.order(
    order_id = "ORDER_ID_TOKEN",
    amount=54.5,
    return_url= "http://domain.com/path/to/url",
    return_decl= "http://domain.com/path/to/url",
    return_can= "http://domain.com/path/to/url",
    description="testing"
)
pprint(order_response)
# check_sample.py
from telr_payment.api import Telr
from pprint import pprint

# if you dont want it to run in test mode change the test option according to docs
telr = Telr(auth_key = "YOUR_AUTH_KEY",store_id = "YOUR_STORE_ID",test=1)

status_response = telr.status(
    order_reference = "ORDER_REF_TOKEN"
)
pprint(status_response)

Status

The table of status of checking transaction

Order StatusDescription
1Pending
2Authorised (Transaction not captured, such as an AUTH transaction or a SALE
transaction which has been placed on hold)
3Paid (Transaction captured, SALE transaction, not placed on hold)
-1Expired
-2Cancelled
-3Declined

Test Cards

Card numberTypeCVVMPI
4000 0000 0000 0002Visa123No
4111 1111 1111 1111Visa123Yes
4444 3333 2222 1111Visa123Yes
4444 4244 4444 4440Visa123Yes
4444 4444 4444 4448Visa123Yes
4012 8888 8888 1881Visa123Yes
5105 1051 0510 5100Mastercard123No
5454 5454 5454 5454Mastercard123Yes
5555 5555 5555 4444Mastercard123Yes
5555 5555 5555 5557Mastercard123Yes
5581 5822 2222 2229Mastercard123Yes
5641 8209 0009 7002Maestro UK123Yes
6767 0957 4000 0005Solo123No
3434 343434 34343American Express1234No
3566 0020 2014 0006JCB123No
3111 1111 1111 1111MADA123No

The card security code (CVV) to use with the test cards is 123 (except for American Express, which should be 1234) for an authorised response, other codes will be declined.

Cards which show ‘Yes’ in the MPI column will use a simulated 3D Secure authentication page, allowing you to test the transaction flow when Verified by Visa or MasterCard SecureCode is used.

Order Creation Response Sample

successful

{'method': 'create',
 'order': {'ref': 'ORDER_REF_TOKEN',
           'url': 'https://secure.telr.com/gateway/process.html?o=ORDER_REF_TOKEN'},
 'trace': 'xxxx/xxxx/xxxxxxxx'}

Failed

{
  "method":"create",
  "error":{
    "message":"Exx: Error Name",
    "note":"Message according to error"
  }
}

Check Response Sample

Successful

 {'method': 'check',
 'order': {'amount': '4.50',
           'card': {'country': 'AE',
                    'expiry': {'month': x, 'year': xxxx},
                    'first6': 'xxxxxx',
                    'last4': 'xxxx',
                    'type': 'Visa Credit'},
           'cartid': 'ORDER_ID_TOKEN',
           'currency': 'AED',
           'customer': {'address': {'city': 'xxxxx',
                                    'country': 'AE',
                                    'line1': 'xxxx,xxx,xxx',
                                    'mobile': '1234567890'},
                        'email': 'test@test.com',
                        'name': {'forenames': 'FIRST_NAME', 'surname': 'LAST_NAME'}},
           'description': 'testing',
           'paymethod': 'Card',
           'ref': 'ORDER_REF_TOKEN',
           'status': {'code': 3, 'text': 'Paid'},
           'test': 1,
           'transaction': {'class': 'ECom',
                           'code': '924861',
                           'date': '04 Aug 2022 12:56 GST',
                           'message': 'Authorised',
                           'ref': 'REF_TOKEN',
                           'status': 'A',
                           'type': 'sale'}},
 'trace': 'xxxx/xxxx/xxxxxxxx'}

Pending

{'method': 'check',
 'order': {'amount': '54.50',
           'cartid': 'ORDER_ID_TOKEN',
           'currency': 'AED',
           'description': 'TRANSACTION_DESCRIPTION',
           'ref': 'ORDER_REF_TOKEN',
           'status': {'code': 1, 'text': 'Pending'},
           'test': 1,
           'url': 'https://secure.telr.com/gateway/process.html?o=ORDER_REF_TOKEN'},
 'trace': 'xxxx/xxxx/xxxxxxxx'}

Canceled

{'method': 'check',
 'order': {'amount': '54.50',
           'cartid': 'ORDER_ID_TOKEN',
           'currency': 'AED',
           'description': 'TRANSACTION_DESCRIPTION',
           'ref': 'ORDER_REF_TOKEN',
           'status': {'code': -2, 'text': 'Cancelled'},
           'test': 1},
 'trace': 'xxxx/xxxx/xxxxxxxx'}

References

Project details


Download files

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

Source Distribution

telr_payment-0.1.3.1.tar.gz (5.8 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page