If you haven’t already done so, please read the quickstart for an overview of the payment process and a quick example on usage of this module.
Main Methods / Public Interface¶
Gateway(resource, alias[, currency=414, lang='ENG'])¶
This is the main class that creates parses the terminal resource file and creates the gateway link in order to initiate the payment process.
- resource (str) – The full path name the the resource file provided by the payment processor
- alias (str) – The alias for the terminal. See your payment processor for more information
- currency (int) – The ISO 4217 numeric code for the currency of the transaction. See ISO 4217 for more.
- lang (str) – The language supported by the gateway. See your payment processor’s documentation for the languages supported. Defaults to ‘ENG’ for US English.
sanitize(s) → string¶
Returns the string stripped of characters not allowed in the transaction id or the UDF (user defined fields)
The following characters are stripped:
Symbol Hex Name ~ x7E TILDE ` x60 LEFT SINGLE QUOTATION MARK, GRAVE ACCENT ! x21 EXCLAMATION POINT (bang) # x23 NUMBER SIGN (pound sign) $ x24 DOLLAR SIGN % x25 PERCENT SIGN ^ x5E CIRCUMFLEX ACCENT x7C VERTICAL LINE (pipe) x5C REVERSE SLANT (REVERSE SOLIDUS, backslash, backslant) : x3A COLON ‘ x27 APOSTROPHE, RIGHT SINGLE QUOTATION MARK, ACUTE ACCENT (single quote) “ x22 QUOTATION MARK, DIAERESIS / x2F SLANT (SOLIDUS, slash) Parameters: s (str) – The string to be sanitized Returns: Sanitized string, with characters not allowed removed Return type: str
get_payment_url() → dict¶
This function returns a two element dictionary with the paymentID and the paymentURL that is needed to redirect the user to the gateway.
In order to call this method, the gateway needs to be correctly initialized and configured.
Raises: ValueError – if the object is not configured correctly Returns: A dictionary of payment id and payment url from the gateway Return type: dict
Properties are used to set various gateway parameters, and to ensure that all parameters are correctly sanitized.
All properties are accessed from instances of the gateway object.
Set or get the user defined fields (UDF). Please note the following restrictions:
|error_url||The fully qualified URL to the error handler for the gateway. See the quickstart for more information||Required|
|amount||The amount for this transaction, this should be a floating point number. The default and the minimum is 1.0. Invalid values will raise a TypeError.||Required|
|trackid||The tracking id for this transaction. It must be a unique value. Like the udf fields, it is also sanitized. A default value based on the current timestamp is generated if not provided.||Optional|
|response_url||The fully qualified URL for all affirmative responses from the gateway. See quickstart||Required|