Integra Battlepay con SumUp (órdenes battlepay_orders)

- pagos_sumup.py: crear_checkout_battlepay(reference,...) y obtener_checkout()
- battlepay_view: lista las órdenes PENDING de la cuenta de juego
- battlepay_pay_view: crea checkout SumUp para una orden concreta (checkout_reference=reference)
- sumup_webhook: marca la orden PAID (valida estado contra la API de SumUp si falta)
- plantillas account/battlepay.html y partials/pago_sumup.html
- sql/battlepay_sumup.sql (tablas battlepay_orders/battlepay_price) y docs actualizados

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-07-12 16:48:16 +00:00
parent 215061776b
commit 0fef9ac35b
7 changed files with 317 additions and 60 deletions
+60
View File
@@ -0,0 +1,60 @@
<!DOCTYPE html>
{% include 'partials/head.html' %}
{% include 'partials/header.html' %}
{% include 'partials/video.html' %}
<div class="main-page">
<div class="middle-content">
<div class="body-content">
<div class="title-content">
<h1>Tienda del cliente (Battlepay)</h1>
</div>
<div class="box-content">
<div class="body-box-content centered">
<p>Compras pendientes de pago de la cuenta <strong>{{ username }}</strong>.</p>
<br>
{% if orders %}
<table class="middle-center-table">
<thead>
<tr>
<th>Producto</th>
<th>Precio</th>
<th></th>
</tr>
</thead>
<tbody>
{% for order in orders %}
<tr>
<td>{{ order.product_name }}</td>
<td>{{ order.price_eur }} €</td>
<td>
<form action="{% url 'battlepay_pay' %}" method="POST" accept-charset="utf-8">
{% csrf_token %}
<input type="hidden" name="reference" value="{{ order.reference }}">
<button type="submit" class="login-button">Pagar con SumUp</button>
</form>
</td>
</tr>
{% endfor %}
</tbody>
</table>
{% else %}
<p>No tienes compras pendientes.</p>
<br>
<p>Para comprar, pulsa <strong>Comprar</strong> en la tienda del cliente dentro del juego;
la compra aparecerá aquí para completar el pago.</p>
{% endif %}
<hr>
<p><a href="my-account">Volver a mi cuenta</a></p>
</div>
</div>
</div>
</div>
</div>
{% include 'partials/social.html' %}
{% include 'partials/footer.html' %}
{% include 'partials/final.html' %}
+8 -2
View File
@@ -10,7 +10,12 @@
{% if error %}
<p style="color: red;">Error: {{ error }}</p>
<p><a href="battlepay">Volver a mis compras</a></p>
{% else %}
{% if product_name %}
<p>Producto: <strong>{{ product_name }}</strong></p>
<p>Importe: <strong>{{ price_eur }} €</strong></p>
{% endif %}
<div id="sumup-card"></div>
<script>
@@ -18,8 +23,8 @@
checkoutId: "{{ checkout_id }}",
onResponse: function (type, body) {
if (type === 'success') {
alert("Pago exitoso. ID de transacción: " + body.transaction_code);
console.log("Pago exitoso:", body);
alert("Pago exitoso. El producto se entregará en el juego en breve.");
window.location = "battlepay";
} else if (type === 'error') {
alert("Error en el pago: " + body.message);
console.error("Error en el pago:", body);
@@ -27,6 +32,7 @@
}
});
</script>
<p><a href="battlepay">Cancelar y volver</a></p>
{% endif %}
</body>
</html>