From b44b365c706345b85c8fdec2e53b42f20193a969 Mon Sep 17 00:00:00 2001 From: Skylar Ittner Date: Sun, 3 Oct 2021 22:49:40 -0600 Subject: [PATCH] Send email receipts --- settings.json | 2 +- source/pages/index.html | 1 + source/static/makeshipment.php | 3 +++ source/static/payshipment.php | 18 ++++++++++++++++++ source/static/settings.sample.php | 7 +++++++ 5 files changed, 30 insertions(+), 1 deletion(-) diff --git a/settings.json b/settings.json index 70e7a31..383f682 100644 --- a/settings.json +++ b/settings.json @@ -2,7 +2,7 @@ "context": { "site_title": "Certified from Home", "site_root": "https://certifiedfromhome.com/", - "stripe_pk": "pk_live_RgpadCo1LIIkfyUsY47VhUq6", + "stripe_pk": "pk_live_51J6qFXCa1Fboir5UXRYBZ0dQVL43LpQ8NpT2bjpyrzSpdZhbpmJ9FFtMO7cBrGXd0fC4SZxqg7ZXD70DNF7998Dm003g81nrxs", "navigation": [ { "title": "Home", diff --git a/source/pages/index.html b/source/pages/index.html index c89dca4..a3f306f 100644 --- a/source/pages/index.html +++ b/source/pages/index.html @@ -111,6 +111,7 @@ {{> statelist}} +

Options:

diff --git a/source/static/makeshipment.php b/source/static/makeshipment.php index 74a1e62..44dd8a2 100644 --- a/source/static/makeshipment.php +++ b/source/static/makeshipment.php @@ -34,6 +34,7 @@ try { "city" => $_REQUEST["from_city"], "state" => $_REQUEST["from_state"], "zip" => $_REQUEST["from_zip"], + "email" => $_REQUEST["from_email"], "country" => "US" ]); @@ -54,6 +55,8 @@ try { "weight" => 3.5 ]); + $shipmentinfo["carrier_accounts"] = ["ca_fe31a7e4fcf24438b8cdfb74541c7094"]; // USPS + if ($_REQUEST["postagetype"] == "certified") { $shipmentinfo["options"]["certified_mail"] = true; } else if ($_REQUEST["postagetype"] == "certified_receipt") { diff --git a/source/static/payshipment.php b/source/static/payshipment.php index 463f70a..60212f5 100644 --- a/source/static/payshipment.php +++ b/source/static/payshipment.php @@ -82,6 +82,24 @@ try { // get paid $intent->capture(); + try { + $mail = new Email(); + $emailsettings = $_SETTINGS["email"]; + $mail->setSMTP($emailsettings["server"], $emailsettings["port"], true, $emailsettings["user"], $emailsettings["password"], $emailsettings["security"]); + $mail->setFrom("certifiedfromhome@helena.express", "CertifiedFromHome.com"); + $mail->addTo($shipment->from_address->email); + $mail->setSubject("Your CertifiedFromHome Receipt"); + $body = "Thanks for using CertifiedFromHome.com!\r\nYour card has been charged a total of $" . number_format($price, 2) . ".\r\n"; + if (!empty($shipment->options->certified_mail)) { + $body .= "You can track your letter with this tracking code: " . $shipment->tracking_code . "\r\n"; + } + $body .= "If you need any help, just reply to this email. Thanks again!"; + $mail->setBody($body); + $mail->send(); + } catch (Exception $ex) { + + } + header("Content-Type: application/json"); exit(json_encode([ "status" => "OK", diff --git a/source/static/settings.sample.php b/source/static/settings.sample.php index 83a325d..be31bd2 100644 --- a/source/static/settings.sample.php +++ b/source/static/settings.sample.php @@ -4,4 +4,11 @@ $_SETTINGS = [ "debug" => false, "easypost_key" => "", "stripe_sk" => "", + "email" => [ + "server" => "mail.netsyms.net", + "port" => 587, + "user" => "noreply@netsyms.com", + "password" => "", + "security" => "tls" + ], ];