Email message when Bitcoin payment is received
When a payment is received on your Bitcoin wallet, you usually want to be informed quickly by email.
This notification is usually done automatically by the online store software such as: WooCommerce.
However, with Bitcoin you can receive payments without operating an online store.
You can receive Bitcoin payments via pay button, by donation, to pay for a newspaper article or via any other of the applications presented here and you can be notified about these Bitcoin payment receipts via email as well.
In this article we will explain how you can use the BTCPay Server and BTC Transmuter to be automatically informed by email about every incoming payment on your Bitcoin wallet.
Email notification with BTCPay Transmuter
As soon as a payment is received on our Bitcoin Wallet, we would like to be notified about it via email. This can be implemented with the help of BTCPay Transmuter. BTCPay Transmuter is a part of BTCPay Server. In the article “BTCPay Transmuter” we introduce this service in more detail and there you will also find an explanation how to set up BTCPay Transmuter on your BTC Pay server. If you have set up a store at https://btcpay.coincharge.io, you can also use BTCPay Transmuter and be informed by e-mail about incoming payments.
In BTCPay Transmuter there are some prepared functions, which can be adjusted to your own requirements.
Under BTCPay Email Receipts there is a template based on the sale of an event ticket. We will modify and adapt this template.
As first setting, you have to define for which BTCPay store on your BTCPay server this application should be used. Likewise, an email must be stored, which will be used to send the email notification.
These are External Services, which can be set up and administered under this separate menu item.
If these corresponding External Services do not exist yet, they have to be created and it looks like this:
We would like to be notified by email for our supporter store at https://store.coincharge.io when a payment is received.
Pairing to the BTCPay store
The first step is to connect to your BTCPay store. For this purpose, an External Service must be created.
You give this service a name (here Supporter Shop) and select BTCPayServer External Service as type.
Then you need to connect this External Service to the BTCPay Store on the BTCPay Server.
This process is called pairing and requires the paring code of the store.
Then click Save and leave the field empty. You will be shown a link, you have to click on it.
You will be redirected to the backend system of your BTCPay server and have to select your BTCPay store.
Then click on Approve. This way you allow Transmuter to access the information of your BTCPay store.
After you click Appove, go back to Transmuter in the External Services section. There to the settings of the store and click on Save.
Then the Last Checked field should be displayed with a date.
Email Sending Service
Then the Email Sending Service must be set up. This service is required because notifications are sent via these email settings.
We also give this service a name and select SmtpExternalService as the type.
Then we have to deposit the data from our used email address.
And save. After that we will test if the email settings have been successfully deposited and send us a text message.
I had some problems with the mail server settings. Sometimes the displayed error messages are wrong or misleading.
After some trial and error, deactivating SSL and using a different browser, it finally worked.
After the two External Services have been set up, the External Services section will display the new services we have set up:
Email notification
We have defined for which store and via which email address the email notification should be sent.
In the next step, we determine which message should be sent when which event occurs.
We would like to receive an email notification when a payment in our store reaches a certain status. In the store settings, the various statuses are recorded in the Invoices section.
If the status changes to Complete, then we would like to be notified by email.
Then you can specify who should be notified by email.
If the customer should also be sent an email, then we check the box “Send email to the address registered on the BTCPay invoice”.
Since we want to be informed by email ourselves, we enter our own email address.
Then you can specify which email address should be displayed as the sender email address and the email subject.
The email body can be implemented using HTML. In the email text, data can be taken from the order or invoice.
This can be, for example:
- Customer Email: {{TriggerData.Invoice.Buyer.email}}
- Invoice Id: {{TriggerData.Invoice.Id}}
- Invoice Status: {{TriggerData.Invoice.Status}}
- Amount Paid in BTC: {{TriggerData.Invoice.BtcPaid}}
- Amount Due: {{TriggerData.Invoice.Price}}
- Invoice Currency: {{TriggerData.Invoice.Currency}}
- Item Description: {{TriggerData.Invoice.ItemDesc}}
- Invoice Url: {{TriggerData.Invoice.Url}}
Something is already stored in the template, but this can be edited and changed accordingly.
After we have saved, the following overview appears.
The division is divided into Trigger and Action. Under the Trigger item we have defined what event must occur for something to happen. We had set as a trigger that something should happen when the Payment “Complete” event occurs.
What is supposed to happen then is called action. In our case, an email with a certain content is to be sent to the customer and additionally to ourselves.
With these settings, we will now always be notified by email when a payment has been successfully received in our Supporter Shop.
With the help of the trigger and action functions in BTCPay Transmuter, you can create a wide variety of actions yourself in order to adapt the functionality of the BTCPay server to your individual requirements.
Other application examples we present here are: