Skip to main content

SDK oficial de Falconext Logística para Python.

Project description

falconext-logistica (Python)

SDK oficial de Falconext Logística para Python. Sin dependencias (solo stdlib), tipado, con verificación de firma de webhooks.

Instalación

pip install falconext-logistica

Requiere Python ≥ 3.8.

Uso

import os
from falconext_logistica import FalconextLogistica

fx = FalconextLogistica(api_key=os.environ["FALCONEXT_API_KEY"])  # sk_live_… / sk_test_…

# Crear una orden
order = fx.orders.create(
    external_order_id="ORD-10482",
    customer={"name": "María Fernández", "phone": "+51987654321",
              "document_type": "DNI", "document_number": "70123456"},
    delivery_address={"address": "Av. Javier Prado 123", "district": "San Isidro",
                      "city": "Lima", "lat": -12.09, "lng": -77.04},
    items=[{"description": "Caja de zapatos", "quantity": 1, "weight_kg": 0.8}],
    cash_on_delivery=150,
    requires_signature=True,
)
print(order["id"], order["tracking_code"], order["status"])

# Listar / obtener / rastrear / cancelar
page = fx.orders.list(limit=20, status="pending")   # {"object","data","has_more"}
one = fx.orders.get(order["id"])                     # por id o tracking_code
tracking = fx.orders.tracking(order["id"])
fx.orders.cancel(order["id"])

Webhooks

from falconext_logistica import verify_webhook_signature

wh = fx.webhooks.create(url="https://miapp.com/webhooks/falconext",
                        events=["order.delivered", "order.failed"])
# Guarda wh["secret"].

# En tu handler (Flask) — usa el cuerpo CRUDO:
@app.post("/webhooks/falconext")
def handler():
    raw = request.get_data(as_text=True)
    ok = verify_webhook_signature(raw, request.headers.get("Falconext-Signature"),
                                  os.environ["FALCONEXT_WEBHOOK_SECRET"])
    if not ok:
        return "firma inválida", 400
    event = request.get_json()  # {"id","type","created","data"}
    return "", 200

Errores

from falconext_logistica import FalconextError
try:
    fx.orders.get("ord_inexistente")
except FalconextError as e:
    print(e.status, e.message)  # 404 …

Notas

  • base_url por defecto: https://api.falconext.pe/api. La URL de marca api.falconext.com está reservada para el gateway público.
  • Nunca uses una API key live en el cliente: este SDK es para servidores.

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

falconext_logistica-0.1.0.tar.gz (4.0 kB view details)

Uploaded Source

Built Distribution

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

falconext_logistica-0.1.0-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

Details for the file falconext_logistica-0.1.0.tar.gz.

File metadata

  • Download URL: falconext_logistica-0.1.0.tar.gz
  • Upload date:
  • Size: 4.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.7

File hashes

Hashes for falconext_logistica-0.1.0.tar.gz
Algorithm Hash digest
SHA256 0770ac0ed3c07587ee8249ba4bba33f19195a3f5d1328e922f18591edc6ab59e
MD5 2d2d2a2fb46b3cddb06a8cb9a145757b
BLAKE2b-256 041e5e47bec4b902d4c0a40b2d1a1d64b7ca75d5a04d0f30dc356752b8b93a9b

See more details on using hashes here.

File details

Details for the file falconext_logistica-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for falconext_logistica-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e4d323ece55f7c13e7b909f88cdd95af63d734f942d014bd165bc6cb3470051c
MD5 c332f7c7cdf049c519c2cbe9f5d1116b
BLAKE2b-256 6a58e3279af121322aee16d430a0193ebc8ac0e7a50af8867f695e7cee3459ba

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