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
-
Checkout
process_payment()
-
Obtiene token →
get_token()
(/auth/token
). -
POST
/v2/api/checkout
con: -
Guarda respuesta (
uuid
,links.checkout_link
) en meta_uala
y enwp_options
(uuid → order_id
). -
Redirige al
checkout_link
.
-
-
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()
-
Lee
uuid
de_uala
. -
Token OAuth.
-
POST
…/v2/api/orders/{uuid}/refund
-
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
aorder_id
. -
Si
status=REFUNDED
y aún no existe unWC_Order_Refund
lo crea víawc_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 = Sí:
-
Pago →
UALA LOG | webhook: …
-
Refund →
UALA LOG | refund webhook: …
-
-
Archivo:
wp-content/debug.log
(requiereWP_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 |