Skip to main content

Simple PayNexus Gateway Python SDK for M-Pesa payments

Project description

PayNexus Gateway Python SDK

Simple Python SDK for PayNexus M-Pesa payments.

Installation

pip install paynexus-gateway

Requires Python 3.9 or later.

Usage

from paynexus_gateway import PayNexusClient

client = PayNexusClient("sk_your_secret_key_here")

payment = client.initiate_payment(
    amount=100,
    phone="0746990866",
    description="Order #12345",
)

reference = payment["data"]["reference"]
status = client.get_payment_status(reference)

Methods

Initiate payment

payment = client.initiate_payment(
    amount=100,
    phone="0746990866",
    description="Order #12345",
)

The API auto-normalizes the phone number and uses your default M-Pesa payment account.

Validate phone

result = client.validate_phone("0746990866")

Get payment status by reference

status = client.get_payment_status("PNXABC123")

Get payment status by CheckoutRequestID

status = client.get_payment_status_by_checkout_id("ws_CO_123456")

Error handling

from paynexus_gateway import PayNexusClient, PayNexusError

client = PayNexusClient("sk_your_secret_key_here")

try:
    client.initiate_payment(100, "0746990866", "Order #12345")
except PayNexusError as exc:
    print(exc.status, exc.code, exc.errors)

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

paynexus_gateway-1.0.1.tar.gz (6.0 kB view details)

Uploaded Source

Built Distribution

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

paynexus_gateway-1.0.1-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

Details for the file paynexus_gateway-1.0.1.tar.gz.

File metadata

  • Download URL: paynexus_gateway-1.0.1.tar.gz
  • Upload date:
  • Size: 6.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for paynexus_gateway-1.0.1.tar.gz
Algorithm Hash digest
SHA256 92f5b7b511aa4e253724a35586b5b37cc5969cf9b3a322f5256d81bc0a9fbe77
MD5 1c9c34be62b498005bd0a66d0ff77e7d
BLAKE2b-256 34d9b8ad4c2f8074b665cc01d17e1fd3279ec6226e233062c4d663d38184140d

See more details on using hashes here.

File details

Details for the file paynexus_gateway-1.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for paynexus_gateway-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 52f5c354fe9ef96bc2b3c6fde815d65a8368db44e5d9e5bb27e42a7f07e5a42e
MD5 a019894b3faac41cb2a89943624d1516
BLAKE2b-256 f16365d58350aa678739c9b2fd6e321b95128de90724ec4176b4c7029a63d527

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