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.
Emails have the following attributes :
name
handle
subject
Thanks for your payment {{ charge.customerEmail }}
recipient
{{ charge.customerEmail }}
bcc recipient
template path
_emails/customer/thanks
enabled
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.
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.
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.