feat: notify supplier and client after payment is done
This commit is contained in:
@@ -31,11 +31,13 @@ type MailService struct {
|
||||
}
|
||||
|
||||
type SendOK struct {
|
||||
Price float64
|
||||
Amount float64
|
||||
ExplorerUrl string
|
||||
TxID string
|
||||
BlockHash string
|
||||
DocHash string
|
||||
Tx string
|
||||
CustomerID string
|
||||
OrderID string
|
||||
Block string
|
||||
Timestamp time.Time
|
||||
To string
|
||||
}
|
||||
|
||||
@@ -115,10 +117,11 @@ func (m *MailService) SendProviderConfirm(data SendOK) error {
|
||||
return fmt.Errorf("os.ReadFile: %s", err)
|
||||
}
|
||||
template := strings.Replace(string(bts), "{{explorer_url}}", data.ExplorerUrl, -1)
|
||||
template = strings.Replace(template, "{{tx_id}}", data.TxID, -1)
|
||||
template = strings.Replace(template, "{{block_hash}}", data.BlockHash, -1)
|
||||
template = strings.Replace(template, "{{doc_hash}}", data.DocHash, -1)
|
||||
template = strings.Replace(template, "{{support_email}}", m.from, -1)
|
||||
template = strings.Replace(template, "{{customer_id}}", data.CustomerID, -1)
|
||||
template = strings.Replace(template, "{{order_id}}", data.OrderID, -1)
|
||||
template = strings.Replace(template, "{{tx}}", data.Tx, -1)
|
||||
template = strings.Replace(template, "{{block}}", data.Block, -1)
|
||||
template = strings.Replace(template, "{{timestamp}}", data.Timestamp.Format(time.RFC3339), -1)
|
||||
msg := []byte(m.messageWithHeaders(okSubject, data.To, template))
|
||||
return m.send(data.To, msg)
|
||||
}
|
||||
@@ -129,10 +132,11 @@ func (m *MailService) SendClientConfirm(data SendOK) error {
|
||||
return fmt.Errorf("os.ReadFile: %s", err)
|
||||
}
|
||||
template := strings.Replace(string(bts), "{{explorer_url}}", data.ExplorerUrl, -1)
|
||||
template = strings.Replace(template, "{{tx_id}}", data.TxID, -1)
|
||||
template = strings.Replace(template, "{{block_hash}}", data.BlockHash, -1)
|
||||
template = strings.Replace(template, "{{doc_hash}}", data.DocHash, -1)
|
||||
template = strings.Replace(template, "{{support_email}}", m.from, -1)
|
||||
template = strings.Replace(template, "{{customer_id}}", data.CustomerID, -1)
|
||||
template = strings.Replace(template, "{{order_id}}", data.OrderID, -1)
|
||||
template = strings.Replace(template, "{{tx}}", data.Tx, -1)
|
||||
template = strings.Replace(template, "{{block}}", data.Block, -1)
|
||||
template = strings.Replace(template, "{{timestamp}}", data.Timestamp.Format(time.RFC3339), -1)
|
||||
msg := []byte(m.messageWithHeaders(okSubject, data.To, template))
|
||||
return m.send(data.To, msg)
|
||||
}
|
||||
@@ -144,9 +148,8 @@ func (m *MailService) SendFail(data SendOK) error {
|
||||
return fmt.Errorf("os.ReadFile: %s", err)
|
||||
}
|
||||
template := strings.Replace(string(bts), "{{explorer_url}}", data.ExplorerUrl, -1)
|
||||
template = strings.Replace(template, "{{tx_id}}", data.TxID, -1)
|
||||
template = strings.Replace(template, "{{block_hash}}", data.BlockHash, -1)
|
||||
template = strings.Replace(template, "{{doc_hash}}", data.DocHash, -1)
|
||||
template = strings.Replace(template, "{{tx_id}}", data.Tx, -1)
|
||||
template = strings.Replace(template, "{{block_hash}}", data.Block, -1)
|
||||
template = strings.Replace(template, "{{support_email}}", m.from, -1)
|
||||
// TODO: Alert client too
|
||||
msg := []byte(m.messageWithHeaders(okSubject, data.To, template))
|
||||
|
||||
Reference in New Issue
Block a user