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.1.tar.gz (4.8 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.1-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: falconext_logistica-0.1.1.tar.gz
  • Upload date:
  • Size: 4.8 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.1.tar.gz
Algorithm Hash digest
SHA256 8f9d802247d86b8ccaa5207b2c21a45a4087943f89207de7e2903d7c1a386788
MD5 1d3470f4d63e66badd9f42f93323b0bc
BLAKE2b-256 c4bcdd5f2ee35a8f80bc51f7ed55dcb3496da40b92d789ece2c2e5c522a5437c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for falconext_logistica-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6b8bd6a3e8a74dbfcc7b700c08fa29e46874b650f34024d1c4a33ca176701fc6
MD5 a739f8072978bf73db2eaf43eaefaa87
BLAKE2b-256 9ac0d7bd2c420119a80d41ff2df006beffc5b21d50deece81f5f7bc8f8b12a0f

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