A Python client SDK for integrating with the ALATPay API.
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
Requires Python version >=3.11
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 account
# 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
Release history Release notifications | RSS feed
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.1.tar.gz
(12.4 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file alatpay_sdk-0.0.1.tar.gz.
File metadata
- Download URL: alatpay_sdk-0.0.1.tar.gz
- Upload date:
- Size: 12.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2f242b3f951f890badde13ac035a9ad20e25d9ffe13ca24b4a4ef76e913b8fe4
|
|
| MD5 |
25da525e9cf38534a7e2161114927ccf
|
|
| BLAKE2b-256 |
2cca9aa8bc2beca48f0c25b04db4d477f9f7710258894d8052c8af8790263bd8
|
File details
Details for the file alatpay_sdk-0.0.1-py3-none-any.whl.
File metadata
- Download URL: alatpay_sdk-0.0.1-py3-none-any.whl
- Upload date:
- Size: 17.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f745c20b597b0ad788a02c4940dead3ce029c71db6d24967382d054b9246d2f4
|
|
| MD5 |
7b1f3eca310a6c665875419c0bb6e597
|
|
| BLAKE2b-256 |
050f99c93fd7f3bb1f13eafa857942db1c10a39115340d6c2df03bb7ed7f160f
|