-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
14571a3
commit 0b766e0
Showing
13 changed files
with
192 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package monero.ecwid.server.config; | ||
|
||
import java.util.Properties; | ||
|
||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.mail.javamail.JavaMailSender; | ||
import org.springframework.mail.javamail.JavaMailSenderImpl; | ||
|
||
@Configuration | ||
public class MailConfig { | ||
|
||
public MailConfig() { | ||
|
||
} | ||
|
||
@Bean | ||
public JavaMailSender javaMailSender() { | ||
JavaMailSenderImpl mailSender = new JavaMailSenderImpl(); | ||
ServerConfig serverConfig = ServerConfig.getServerConfig(); | ||
|
||
mailSender.setHost(serverConfig.mailHost); | ||
mailSender.setPort(serverConfig.mailPort); | ||
mailSender.setUsername(serverConfig.mailUsername); | ||
mailSender.setPassword(serverConfig.mailPassword); | ||
|
||
Properties props = mailSender.getJavaMailProperties(); | ||
props.put("mail.transport.protocol", "smtp"); | ||
props.put("mail.smtp.auth", true); | ||
props.put("mail.smtp.starttls.enable", true); | ||
props.put("mail.smtp.starttls.required", true); | ||
|
||
return mailSender; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
src/main/java/monero/ecwid/server/service/MailService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package monero.ecwid.server.service; | ||
|
||
import org.springframework.mail.SimpleMailMessage; | ||
import org.springframework.mail.javamail.JavaMailSender; | ||
import org.springframework.stereotype.Service; | ||
|
||
import monero.ecwid.server.config.ServerConfig; | ||
import monero.ecwid.server.repository.PaymentRequestEntity; | ||
|
||
@Service | ||
public class MailService { | ||
|
||
public static class ReceiptMessage extends SimpleMailMessage { | ||
private PaymentRequestEntity request; | ||
|
||
public ReceiptMessage(PaymentRequestEntity request) { | ||
this.request = request; | ||
init(); | ||
} | ||
|
||
private void init() { | ||
setSubject(); | ||
setText(); | ||
setTo(request.getCustomerMail()); | ||
setFrom(ServerConfig.getServerConfig().mailUsername); | ||
} | ||
|
||
private void setSubject() { | ||
setSubject("Monero Payment Receipt " + getTxId()); | ||
} | ||
|
||
private void setText() { | ||
|
||
} | ||
|
||
public String getTxId() { | ||
return request.getTxId(); | ||
} | ||
} | ||
|
||
private final JavaMailSender sender; | ||
|
||
public MailService(JavaMailSender sender) { | ||
this.sender = sender; | ||
} | ||
|
||
public boolean isEnabled() { | ||
return ServerConfig.getServerConfig().validMailConfig(); | ||
} | ||
|
||
public void sendReceipt(PaymentRequestEntity request) { | ||
if (!isEnabled()) { | ||
throw new Error("Cannot send receipt, mail is not configured"); | ||
} | ||
|
||
ReceiptMessage msg = new ReceiptMessage(request); | ||
|
||
sender.send(msg); | ||
} | ||
|
||
} |
17 changes: 0 additions & 17 deletions
17
src/main/java/monero/ecwid/server/service/MoneroTransactionService.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.