1. Arquitectura general

Capa Qué hace Dónde se define
Bootstrap – Declara compatibilidad con “Custom Order Tables”.
– Registra el gateway y callbacks globales.
líneas 25-54
Gateway WC_Wanderlust_Uala_Gateway Implementa pagos, reembolsos, webhooks y panel de ajustes. función uala_init_gateway_class()
OAuth callback Recibe state + code, consulta /apps/authorize, guarda credenciales en los ajustes. uala_autorization_callback()
Alerta de pago fallido Muestra banner rojo cuando un pedido quedó con error usando este gateway. uala_error_pago_complete()

2. Flujo de pago

  1. Checkout
    process_payment()

    • Obtiene tokenget_token() (/auth/token).

    • POST /v2/api/checkout con:

      { "origin":"woocommerce_uala",
      "amount": <total>,
      "description": "<nombres productos>",
      "notification_url": "<site>/?wc-api=uala",
      "callback_fail": "<url falló>",
      "callback_success": "<url gracias>",
      "external_reference": "<id pedido>" }
    • Guarda respuesta (uuid, links.checkout_link) en meta _uala y en wp_options (uuid → order_id).

    • Redirige al checkout_link.

  2. Webhook de pago /wc-api=uala

    • Confirma con 200 OK.

    • Si status ∈ {APPROVED, PROCESSED}payment_complete() y nota.

    • Guarda json recibido en _uala_response.

3. Reembolsos nativos

  • El gateway declara soporte 'refunds'.

  • process_refund()

    1. Lee uuid de _uala.

    2. Token OAuth.

    3. POST
      …/v2/api/orders/{uuid}/refund

      { "amount":"<monto>",
      "notification_url":"<site>/?wc-api=uala-refund" }
    4. Evalúa respuestas:

      • HTTP 200 + "status":"REFUNDED" → crea nota y guarda _uala_refund.

      • Otros estados → devuelve WP_Error → WooCommerce informa fallo.

  • Webhook de refund /wc-api=uala-refund

    • Confirma con 200 OK.

    • Mapea uuid a order_id.

    • Si status=REFUNDED y aún no existe un WC_Order_Refund lo crea vía wc_create_refund().

    • Registra nota y guarda payload completo en _uala_refund_webhook.

 

4. Tab “Ualá Bis” en WooCommerce → Ajustes → Pagos

Ajuste Descripción
Título / Descripción Texto visible en el checkout.
Credenciales username, client_id, client_secret_id (pueden autocompletarse vía enlace OAuth).
Habilitar gateway Activa/desactiva medio de pago.
Modo de prueba Rellena credenciales “stage” pre-definidas.
Vaciar carrito Vacía cart inmediatamente (ON) o en página de gracias (OFF).
Guardar log Registra payloads de webhooks en debug.log usando WC_Logger.

5. Gestión de logs

  • Si Guardar log = :

    • Pago → UALA LOG | webhook: …

    • Refund → UALA LOG | refund webhook: …

  • Archivo: wp-content/debug.log (requiere WP_DEBUG_LOG=true).

 

6. Endpoints externos usados

Entorno Token Checkout Refund
Prod https://auth.developers.ar.ua.la/v2/api/auth/token https://checkout.developers.ar.ua.la/v2/api/checkout https://checkout.developers.ar.ua.la/v2/api/orders/{uuid}/refund
Stage https://auth.stage.developers.ar.ua.la/v2/api/auth/token https://checkout.stage.developers.ar.ua.la/v2/api/checkout https://checkout.stage.developers.ar.ua.la/v2/api/orders/{uuid}/refund

Shopping cart

No products in the cart.

ATENCIÓN: DEL 11 AL 19 DE JUNIO ESTAREMOS DE VACACIONES. NO BRINDAREMOS SOPORTE. LOS MENSAJES RECIBIDOS SE RESPONDERÁN A PARTIR DEL 23 DE JUNIO.