Skip to main content

Omise Python client

Project description

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

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

omise-0.14.0.tar.gz (37.0 kB view details)

Uploaded Source

Built Distribution

omise-0.14.0-py3-none-any.whl (50.2 kB view details)

Uploaded Python 3

File details

Details for the file omise-0.14.0.tar.gz.

File metadata

  • Download URL: omise-0.14.0.tar.gz
  • Upload date:
  • Size: 37.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.19

File hashes

Hashes for omise-0.14.0.tar.gz
Algorithm Hash digest
SHA256 ab7189f99d9d82976a88150a06d88dbc00bd556816da8186ecbc682c014489dd
MD5 f3dc1ca3a28c5e010a94d2a4db395de9
BLAKE2b-256 7ff391bea472b1e45839c9169315e9c159e81f5422f45e71aeac14c891097964

See more details on using hashes here.

File details

Details for the file omise-0.14.0-py3-none-any.whl.

File metadata

  • Download URL: omise-0.14.0-py3-none-any.whl
  • Upload date:
  • Size: 50.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.19

File hashes

Hashes for omise-0.14.0-py3-none-any.whl
Algorithm Hash digest
SHA256 044f2d0dc4e214147d29f2c7eff4289ded7b95f42c084ab894f8d2a86e6c7fc9
MD5 ba945ade9f80ff586017b3aa04ab3d80
BLAKE2b-256 290e35cd475bf65626051cb2249f3c38a32806894c5d0ab2b16a7622259ebcd4

See more details on using hashes here.

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