Classes

Transaction details

class TeliumAsk
__init__(pos_number, answer_flag, transaction_type, payment_mode, currency_numeric, delay, authorization, amount)
Parameters:

This object is meant to be translated into a bytes sequence and transferred to your terminal.

encode()
Returns:Raw string array with payment information
Return type:str
Raises:SequenceDoesNotMatchLengthException – Will be raised if the string sequence doesn’t match required length. Check your instance params.

Translate object into a string sequence ready to be sent to device.

static decode(data)
Parameters:

data (bytes) – Raw bytes sequence to be converted into TeliumAsk instance.

Returns:

Create a new TeliumAsk.

Return type:

TeliumAsk

Raises:

Create a new instance of TeliumAsk from a bytes sequence previously generated with encode(). This is no use in a production environment.

static new_payment(amount, payment_mode='debit', target_currency='USD', checkout_unique_id='1', wait_for_transaction_to_end=True, collect_payment_source_info=True, force_bank_verification=False)
Parameters:
  • amount (float) – Amount requested
  • payment_mode (str) – Specify transaction type. (debit, credit or refund)
  • target_currency (str) – Target currency, must be written in letters. (EUR, USD, etc..)
  • checkout_unique_id (str) – Unique checkout identifer.
  • wait_for_transaction_to_end (bool) – Set to True if you need valid transaction status otherwise, set it to False.
  • collect_payment_source_info (bool) – If you want to retrieve specifics data about payment source identification.
  • force_bank_verification (bool) – Set it to True if your business need to enforce payment verification.
Returns:

Ready to use TeliumAsk instance

Return type:

TeliumAsk

Create new TeliumAsk in order to prepare payment. Most commonly used.

Transaction results

class TeliumResponse
__init__(pos_number, transaction_result, amount, payment_mode, report, currency_numeric, private)
Parameters:
  • pos_number (str) – Checkout unique identifier from ‘01’ to ‘99’.
  • transaction_result (int) – Transaction result.
  • amount (float) – Payment authorized/acquired amount.
  • payment_mode (str) – Type of payment support.
  • report (str) – Contains payment source unique identifier like credit-card numbers when fullsized report is enabled.
  • currency_numeric (str) – Currency ISO format.
  • private (str) – If supported by your device, contains transaction unique identifier.
has_succeeded
Getter:True if transaction has been authorized, False otherwise.
Type:bool
report
Getter:Contain data like the card numbers for instance. Should be handled wisely.
Type:str
transaction_id
Getter:If supported by your device, contains transaction unique identifier.
Type:bool
card_id
Getter:Read card numbers if available.
Type:str|None
card_id_sha512
Getter:Return payment source id hash repr (sha512)
Type:str|None
card_type
Getter:Return if available payment card type
Type:payment_card_identifier.PaymentCard|None

Device management

class Telium
__init__(path='/dev/ttyACM0', baudrate=9600, timeout=1, open_on_create=True, debugging=False)
Parameters:
  • path – Device path.
  • baudrate (int) – Baud rate such as 9600 or 115200 etc. Constructor do recommend to set it as 9600.
  • timeout (float) – Set a read timeout value.
  • open_on_create (bool) – Specify if device should be immedialty opened on instance creation.
  • debugging (bool) – Set it to True if you want to diagnose your device. Will print to stdout bunch of useful data.

The port is immediately opened on object creation if open_on_create toggle is True.

path is the device path: depending on operating system. e.g. /dev/ttyACM0 on GNU/Linux or COM3 on Windows. Please be aware that a proper driver is needed on Windows in order to create an emulated serial device.

Possible values for the parameter timeout which controls the behavior of the device instance:

  • timeout = None: wait forever / until requested number of bytes are received, not recommended.
  • timeout = 0: non-blocking mode, return immediately in any case, returning zero or more, up to the requested number of bytes, use it only when your computer is really fast unless you don’t care about reliability.
  • timeout = x: set timeout to x seconds (float allowed) returns immediately when the requested number of bytes are available, otherwise wait until the timeout expires and return all bytes that were received until then.
static get()
Returns:Fresh new Telium instance or None
Return type:Telium|None

Auto-create a new instance of Telium. The device path will be inferred based on most common location. This won’t be reliable if you have more than one emulated serial device plugged-in. Does not work on NT platform.

ask(telium_ask)
Parameters:telium_ask (TeliumAsk) – Payment details
Returns:True if device has accepted it, False otherwise.
Return type:bool

Initialize payment to terminal

verify(telium_ask)
Parameters:telium_ask (TeliumAsk) – Payment details previously used on ask()
Returns:Transaction results as TeliumResponse, None if nothing was caught from device.
Return type:TeliumResponse|None

Wait for answer and convert it to TeliumResponse.

close()
Returns:True if device was previously opened and now closed. False otherwise.
Return type:bool

Close device if currently opened. Recommended practice, don’t let Python close it from garbage collector.

timeout
Getter:Current timeout set on read.
Type:float

Native serial proxy class

Use this class instead of Telium if you’re using native serial conn, see examples.

class TeliumNativeSerial