Skip to main content

Official Python SDK for the Coinwaka Pay API.

Project description

coinwaka

Official Python SDK for the Coinwaka Pay API. Standard library only (no dependencies), Python 3.8+.

pip install coinwaka

Quickstart

Create an intent, redirect the customer to its hosted checkout, and fulfil the order on the signed payment_intent.paid webhook.

import os
from coinwaka import Coinwaka

coinwaka = Coinwaka(api_key=os.environ["COINWAKA_SECRET_KEY"])

intent = coinwaka.payment_intents.create(
    amount="2500",
    currency="KES",
    settlement_currency="USDT",
    payment_methods=["mpesa", "card", "coinwaka_balance"],
    merchant_reference="ORDER-1001",
)

# Redirect the customer to:
print(intent["checkout_url"])

A cwk_test_… key runs in sandbox (no real money); a cwk_live_… key is live. Every create call sends an Idempotency-Key automatically, so an automatic retry (on 429/5xx) never double-charges.

Resources

coinwaka.auth.verify()
coinwaka.rates.retrieve()
coinwaka.quotes.create(source_currency="KES", target_asset="USDT", amount="2500")

coinwaka.payment_intents.create(amount="2500", currency="KES", idempotency_key="order-1001")
coinwaka.payment_intents.retrieve("pi_...")
coinwaka.payment_intents.list(limit=20, status="paid")
coinwaka.payment_intents.cancel("pi_...")
coinwaka.payment_intents.refund_request("pi_...", reason="Customer returned item")

coinwaka.payment_links.create(title="Deposit", amount="15000", currency="KES")
coinwaka.payment_links.retrieve("pl_...")

Verify webhooks

Pass the raw request body (str or bytes).

event = coinwaka.webhooks.verify(
    payload=raw_body,
    signature=headers["Coinwaka-Signature"],
    timestamp=headers["Coinwaka-Timestamp"],
    secret=os.environ["COINWAKA_WEBHOOK_SECRET"],
)
if event["type"] == "payment_intent.paid":
    ...  # fulfil the order, dedupe on event["id"]

Errors

from coinwaka import CoinwakaError

try:
    coinwaka.payment_intents.create(amount="0", currency="KES")
except CoinwakaError as err:
    print(err.type, err.code, err, err.request_id)

The full contract is published as OpenAPI at https://www.coinwaka.com/openapi.yaml.

License

MIT

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

coinwaka-1.0.0.tar.gz (4.9 kB view details)

Uploaded Source

Built Distribution

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

coinwaka-1.0.0-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

Details for the file coinwaka-1.0.0.tar.gz.

File metadata

  • Download URL: coinwaka-1.0.0.tar.gz
  • Upload date:
  • Size: 4.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for coinwaka-1.0.0.tar.gz
Algorithm Hash digest
SHA256 652549ca1dc7245374ee9c385c2cf5ffe46aa24e91d2f4cb6b71d6909d52cbc3
MD5 446c37b979f7e7ae955fbff85a2462ca
BLAKE2b-256 c3c009b3382f40ca0fbd7b557c6cb7497f761ec1fa268f0a05ab3a31b15637fe

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for coinwaka-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4f19b00bd365acfb0f1e9b0eaaeee153f0a1d292afd334fbce2d5cc98b627c81
MD5 c62a3f4fd84a945af0cf7dd2662024f6
BLAKE2b-256 a262bd208ce7030e52a9055007d22132f359085fe2a9e79c53d8170bc7defa10

See more details on using hashes here.

Supported by

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