Skip to main content

Add your description here

Project description

ALATPay SDK (Python)

A Python client SDK for integrating with the ALATPay API.

Features

  • Fully Typed.
  • Automatic payload, queries and response data case transformation.
  • Pydantic for payload and response data modeling.
  • Custom response data model injection.
  • Synchronous and Asynchronous clients

Installation

With uv

uv add alatpay-sdk

With pip

pip install alatpay-sdk

Usage

# You may provide your credentials through environment variables.
# The client automatically loads the following variables:
#
# ALATPAY_SECRET_KEY=""            # Required
# ALATPAY_BUSINESS_ID=""           # Optional. If omitted, methods that require
#                                  #   a business ID will require one explicitly.
# ALATPAY_WEBHOOK_SECRET_KEY=""    # Optional
# ALATPAY_PUBLIC_KEY=""            # Optional
#
# Credentials passed to the client on instantiation take precedence over
# environment variables.

from alatpay_sdk import ALATPayClient, AsyncALATPayClient, PayViaVirtualAccountPayload
from uuid import uuid4

# Instantiate the client
# Credentials may be passed directly if they are not available
# in the environment.
# May raise `MissingCredentialError` if no credentials was passed in 
# on instantiation or found in the environmental variables.
client = ALATPayClient()
# In a async context, you may use the async client
aclient = AsyncALATPayClient()

# Now we create a payload for a debit request via a virtual account.
payload = PayViaVirtualAccountPayload.model_validate(
            {
                "amount": 100,
                "order_id": str(uuid4()),
                "description": "test payin",
                "customer": {
                    "email": "johndoe@example.com",
                    "phone": "08012345678",
                    "first_name": "John",
                    "last_name": "Doe",
                },
            }
        )
# NOTE: Payloads are all pydantic models and you may choose to instantiate it 
#   however you please. They follow a naming convention of converting the method 
#   they are for into PascalCase and appending a `Payload` to it.

# Now we call our client method designated for requesting a debit via a virtual
# with our payload. (Calling a client method that makes a request, may raise 
# `ClientError` You need to handle this.)
response = client.pay_via_virtual_aaccount(payload)
# If you're using the async clients, the method names remain the same, they just need 
# to be awaited (This only works in a async context ).
response = await aclient.pay_via_virtual_aaccount(payload)

# Use the response data in your application
print(response)
# NOTE: response are pydantic models of type APIResponse[T] where T is the type of the 
# `data` field. The response also includes fields like `status`, `message` and `raw`
# which is the exact response data gotten from ALATPay without any transformation.
# It's also worth noting that you may pass a custom response model while calling
# the client method via the `response_model_class` parameter, for the most part,
# you'll only need to change the `T` of the `APIResponse` e.g if i have 
# `MyCustomResponseData`, then `response_model_class=APIResponse[MyCustomResponseData]`.
# When the client is unable to serialize the data returned by ALATPay, it sets the `data`
# field to `None`, the original data is still present in the `raw` field.

Issues and Contributions

If you discover bugs, missing endpoints, incorrect typings, or any other issues, please open an issue or submit a pull request. Contributions are welcome.

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

alatpay_sdk-0.0.0.tar.gz (12.2 kB view details)

Uploaded Source

Built Distribution

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

alatpay_sdk-0.0.0-py3-none-any.whl (17.5 kB view details)

Uploaded Python 3

File details

Details for the file alatpay_sdk-0.0.0.tar.gz.

File metadata

  • Download URL: alatpay_sdk-0.0.0.tar.gz
  • Upload date:
  • Size: 12.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.25 {"installer":{"name":"uv","version":"0.11.25","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Arch Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for alatpay_sdk-0.0.0.tar.gz
Algorithm Hash digest
SHA256 00f26258284b34f47305341bb8188717f3352d8f4f793e9ccc9b9f1e1225b04f
MD5 c1ec6e20303302ac55925305cdd656ab
BLAKE2b-256 211d00c1b02df9b9d72114c6e14fe6c9566be54950303d08c5c3a42611c90f30

See more details on using hashes here.

File details

Details for the file alatpay_sdk-0.0.0-py3-none-any.whl.

File metadata

  • Download URL: alatpay_sdk-0.0.0-py3-none-any.whl
  • Upload date:
  • Size: 17.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.25 {"installer":{"name":"uv","version":"0.11.25","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Arch Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for alatpay_sdk-0.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 43cba69e0756d41476a72363b68c47c72cd4981b2b281b786ce0487335bbb835
MD5 53961c01e87bd015cfacda026ac59009
BLAKE2b-256 cdf212d3e626df6ed3d12d744a2f5b00968f3d42f03ebf98f1dc84c6ab56c902

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