Emails in Charge are simple to setup, and can be attached to different events.

To setup a new email in Charge, go the to Charge CP > Settings > Emails

Upgrade to Pro Emails are a Pro only feature. If you're running the free edition you'll be asked to upgrade to Charge Pro to unlock them.

Setup & Options #

Emails have the following attributes :

The name you'll see used for this email in the CP
How you'll refer to this email in your templates
The email subject. *This can be dynamic, i.e. Thanks for your payment {{ charge.customerEmail }}
Who'll get this email. *This can be dynamic, ie. {{ charge.customerEmail }}
bcc recipient
Any bcc recipients you want on the email
template path
The path to the template to be used for this email. ie. _emails/customer/thanks
If this email is active

All the values are dynamic Subject, recipient, bcc and body values are all parsed using all the variables from the charge event that's triggered them.

Using Emails #

Emails can be triggered from various different places in Charge.

The most common usage will be to trigger from a successful payment. To set that up, you simply need to supply the emails you want triggering as part of your setPaymentOptions() > 'onSuccess> 'email. Like so :

{% set options = {
    'planAmount' : 99.99,
    'actions' : {
        'onSuccess': {
            'email' : { 0: 'customer-thanks', 1: 'admin-notify' },
        'onFailure': {
            'email' : 'admin-notify-failure'
    }} %}

{{ craft.charge.setPaymentOptions(options) }}

How can I see what's sent out? If you've enabled logging for Charge you'll see all the emails and their contents logged in the CP. It's a great way to help debug any unexpected behaviour

With that setup, when the payment is successful it'll trigger emails with the handles customer-thanks, and admin-notify, if the payment fails, it'll trigger the email with the handle admin-notify-failure.

In addition - for certain features you can set the emails directly when setting them up - e.g. for Membership Subscriptions you can define what emails send out directly in the CP.

What variables can I use in my email body? #

Emails will always trigger with an associated charge object. You'll be able to access all the details of the charge object in the same way as you'd access them in your payment thanks page. We're recommend using the thanks page as a test bed when trying out new email contents first.