Skip to main content

Omise Python Library

Build Status Python Versions PyPi Version

Please raise an issue or contact support@pn.ooo if you have a question regarding this library and the functionality it provides.

Security Warning

Please do NOT use Omise Python library versions less than 0.9.0, as they are outdated and have security vulnerabilities.

Installation

To use Omise Python library in your application, install it using pip:

pip install omise

Or easy_install in case your system does not have pip installed:

easy_install omise

The Omise Python library officially supports the following Python versions:

  • Python 2.7
  • Python 3.7
  • Python 3.8
  • Python 3.9
  • Python 3.10
  • Python 3.11

Versions not listed here may work but they are not automatically tested.

Usage

Please refer to examples in our API documentation. For basic usage, you can use the package in your application by importing omise and setting the secret key:

import omise
omise.api_secret = 'skey_test_4xsjvwfnvb2g0l81sjz'

After the secret key is set, you can use all APIs that use secret key authentication.

To create a new card charge, use Omise.js to create a new token and run the following:

token_id = "tokn_test_no1t4tnemucod0e51mo" # see https://www.omise.co/tokens-api#create
charge = omise.Charge.create(
    amount=100000,
    currency="THB",
    card=token_id,
    return_uri="https://www.omise.co/example_return_uri",
)
# <Charge id='chrg_test_5ktrim62oiosnrc1r41' at 0x105d6bf28>
charge.status
# 'successful'

To create a new customer without any cards associated to the customer, run the following:

customer = omise.Customer.create(
   description='John Doe',
   email='john.doe@example.com'
)
# <Customer id='cust_test_4xtrb759599jsxlhkrb' at 0x7ffab7136910>

Then to retrieve, update, and destroy that customer, run the following:

customer = omise.Customer.retrieve('cust_test_4xtrb759599jsxlhkrb')
customer.description = 'John W. Doe'
customer.update()
# <Customer id='cust_test_4xtrb759599jsxlhkrb' at 0x7ffab7136910>
customer.destroy()
customer.destroyed
# True

In case of error (such as authentication failure, invalid card and others as listed in errors section in the documentation), the error of a subclass omise.errors.BaseError will be raised. Your application code should handle these errors appropriately.

API version

To enforce the API version that the application must use, set api_version. The version specified by this setting will override the version setting in your account. This is useful if you have multiple environments with different API versions (e.g. development on the latest but production on the older version).

import omise
omise.api_version = '2019-05-29'

It is highly recommended to set this version to the current version that you are using.

Contributing

The Omise Python library uses tox and Docker for testing. All changes must be tested against all supported Python versions. You can run tests using the following instructions:

  1. Install Docker
  2. Run docker run -it -v $(pwd):/app --rm $(docker build -q .)

This command builds a Docker image using the Dockerfile, mounts the current directory to the container's /app directory, and runs the default entrypoint for the image: /app/run-tox.sh.

After you've made your changes and run the tests, please open a Pull Request.

License

See LICENSE.txt

Metadata

Release files for omise 0.16.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for omise 0.16.0
File Size Uploaded Provenance
omise-0.16.0.tar.gz 37.5 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for omise 0.16.0
File Interpreter ABI Platform
omise-0.16.0-py3-none-any.whl Python 3 none any Details

Total release size: 88.4 kB

Release files / omise-0.16.0.tar.gz

Download URL omise-0.16.0.tar.gz
Size 37.5 kB
Tags Source
SHA-256 checksum
How to use checksums
c4d2c83f68922544b7208bc8372c5363193963c2f3a4fedccc7477418d0717fb
BLAKE2b-256 checksum
How to use checksums
5ff17460a5cf3eba3f661a3009d1ea45f17bab995b134a27764eeaa4df17a1e8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.25

Release files / omise-0.16.0-py3-none-any.whl

Download URL omise-0.16.0-py3-none-any.whl
Size 50.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7e7127d3dc0a40074fbbafab878c2f8b64a56a8f629ab55f3e6c915b52a5f53d
BLAKE2b-256 checksum
How to use checksums
49b54811d3cfdae78ddc751c6e23cab3feb14fd6248138e05d6d3b0cb9151ab7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.25

Security for omise 0.16.0

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page