Just like craft.entries
, you can access the recorded charges with a twig tag. It's exactly the same:
craft.charge.charges
accepts the following parameters :
customerName
customerEmail
hash
userId
timestamp
sourceUrl
planCurrency
planType
For example :
{% set charges = craft.charge.charges.customerEmail('example@customer.com').find() %}
Will set charges to be all the charges recorded with the customerEmail of 'example@customer.com'.
More likely you'll want to just show a single charge, relating to a specific purchase. For example, if on the payment form, we set the following value as our redirect :
<input type="hidden" name="redirect" value="payment/thanks/{hash}"/>
The user would be directed to a url like : http://site.url/payment/thanks/xxxxxx-xxxxx-xxxxx
on success. On that page, we'll already have the relevant charge object defined, but if they revisit that page later, you can get the charge object back like so :
{% set hash = craft.request.getSegment(3) %} {% if charge is not defined %} {% set charge = craft.charge.hash(hash).first() %} {% endif %} {% if charge is defined %} Thanks for your payment of {{ charge.formatPlanAmount() }} {% endif %}
You could also use this method build retrievable receipts.