Last updated: Jul 20, 2018

Order - Return Url

Let's get the Order in our templates once the payment is charged and the user back to the Return Url.

The first step is to set the Return URL field in our PayPal button. We can pass any property of the Order model in the URL, let's pass the "number" property so we can use that number to fetch the Order in our templates. For example: "/order?number={number}"

Set Return Url
screenshot

Let's get the Order in our template using the "number" parameter:

{% set number = craft.app.request.param('number') %}
{% set order = craft.paypalButton.getOrderByNumber(number) %}

<h1>Order #{{ order.number }}</h1>


<div class="row">
    <div class="four columns">
        <h4>Details</h4>

        <strong>{{ "Customer"|t }}:</strong> {{ order.email }}<br>
        <strong>{{ "Total"|t }}:</strong> {{ order.totalPrice|commerceCurrency(order.currency) }}<br>
        <strong>{{ "Date"|t }}:</strong> {{ order.dateOrdered|date('D jS M Y') }}<br>
        
    </div>
    <div class="four columns order-address">
        <h4>Shipping Address</h4>

        {{ order.getShippingAddress()|raw}}
    </div>
</div>