Skip to main content

kobil-payment

KOBIL Pay (mpay-merchant) client for Python, with automatic OAuth token management.

pip install kobil-payment

Credentials are shared across modules and read from KOBIL_* env vars if omitted. merchant_id defaults to client_id. Amounts are in the smallest currency unit (1300 = 13.00 TRY); timeouts in minutes.

from kobil.payment import PaymentClient, payment_group

payment = PaymentClient(
    payment_base_url="https://pay.cloud.kobil.com/mpay-merchant/create/transaction",
    merchant_name="ISPARK",
    # credentials optional if KOBIL_* env vars are set:
    client_id="...", client_secret="...", token_endpoint="https://idp/token",
)

res = payment.create_transaction(
    user_id=user_id,
    amount=1300,
    payment_content=payment_group(("Service Amount", "10.0 TL"), ("Tax Amount", "3.0 TL")),
)
# res["transactionId"], res["status"]

payment.create_pre_auth_transaction(user_id, 1300)
payment.post_auth(transaction_id, 40)
payment.get_status(transaction_id)
payment.cancel(transaction_id, user_id, cancellation_message="Iptal")
payment.refund(transaction_id, user_id, 5555, currency="USD")

Each operation returns the decoded response dict. Failures raise kobil.payment.KobilPaymentError (subclass of kobil.core.KobilError).

License

MIT

Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

kobil_payment-1.0.0-py3-none-any.whl (3.6 kB view details)

Uploaded Python 3

File details

Details for the file kobil_payment-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: kobil_payment-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 3.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for kobil_payment-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 36f9c2a8ddcd74fcfc747fdc03be784d73b4ea1b6217e8b600fb40420e82146a
MD5 869bab57aaf361058802c7153ccd22aa
BLAKE2b-256 218818b03435075d76cf2d8c87a10231bccce56398c69e404210d86e55483a2c

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

1.0.0 This release

1 file

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page