Verificar una compra exitosa de PayPal - 31
Siguiente paso crear una vista específica al momento de procesar la orden de PayPal así que por lo demás aquí no creo que no tengo mucho más que hacer:
def capture_payment(request, order_id):
paypal = PayPalPayment()
res = paypal.capture_order(order_id)
if res:
return render(request,'elements/capture_payment.html', {'res': res,
'id': res['id'],
'status': res['status'],
price': res['purchase_units'][0]['payments']['captures'][0]['amount']['value']})
return render(request,'elements/error.html')
We implement this in the view in Django, using the capture_order method. PayPal processes the order passed from the client:
Getting relevant data when processing the PayPal order Django - 30
For the rest, we pass the data to the template.
El template queda como:
mystore\elements\templates\elements\capture_payment.html
{% extends "base.html" %}
{% block content %}
<script src="https://www.paypal.com/sdk/js?client-id={{paypal_client_id}}"></script>
<div class="card">
<div class="card-header">
<h1>Payment Process</h1>
</div>
<div class="card-body">
<ul>
<li>id: {{id }}</li>
<li>status: {{ status }}</li>
<li>price: {{ price }}</li>
</ul>
</div>
<div class="card-header">
<h5>Traze</h5>
</div>
<div class="card-body">
{{res}}
</div>
</div>
{% endblock %}
Ya con esto, al momento de procesar la orden, deberías de ver en el template anterior la traza.