Skip to content
This repository has been archived by the owner on Dec 8, 2023. It is now read-only.

Latest commit

 

History

History
86 lines (60 loc) · 1.93 KB

README.md

File metadata and controls

86 lines (60 loc) · 1.93 KB

alma-python-client

Travis Build Status PyPI

Python API Client for the Alma API.

Support Python >= 3.8

Install

pip install alma-client

Demo

We support both a sync and async client.

Synchronous client

from alma_client import Client

alma_client = Client.with_api_key("sk_test..")
payments = alma_client.payments.fetch_all()

for p in payments:
    print(f"{p.id}: Paiement en {len(p.payment_plan)} fois")


payment_data = {
    "payment": {
        "purchase_amount": 10000,
        "return_url": "http://merchant.com/payment-success",
        "shipping_address": {
            "first_name": "Martin",
            "last_name": "Dupond",
            "line1": "1 rue de Rivoli",
            "postal_code": "75004",
            "city": "Paris"
        }
    }
}

eligibility = alma_client.payments.eligibility(payment_data)
if eligibility.eligible:
    payment = alma_client.payments.create(payment_data)

print(payment.raw_data)

Asynchronous client

from alma_client import AsyncClient

alma_client = AsyncClient.with_api_key("sk_test..")
payments = await alma_client.payments.fetch_all()

for p in payments:
    print(f"{p.id}: Paiement en {len(p.payment_plan)} fois")


payment_data = {
    "payment": {
        "purchase_amount": 10000,
        "return_url": "http://merchant.com/payment-success",
        "shipping_address": {
            "first_name": "Martin",
            "last_name": "Dupond",
            "line1": "1 rue de Rivoli",
            "postal_code": "75004",
            "city": "Paris"
        }
    }
}

eligibility = await alma_client.payments.eligibility(payment_data)
if eligibility.eligible:
    payment = await alma_client.payments.create(payment_data)

print(payment.raw_data)