|
|
|
@ -45,6 +45,13 @@ try {
|
|
|
|
|
$shipment->buy(['rate' => ['id' => $_REQUEST["rateid"]]]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
$stripe = new \Stripe\StripeClient($_SETTINGS["stripe_sk"]);
|
|
|
|
|
$stripe->paymentIntents->update($intent->id, ["metadata" => ["tracking_number" => "$shipment->tracking_code", "rate" => $price - 1.00]]);
|
|
|
|
|
} catch (Exception $exx) {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$labelurl = $shipment->postage_label->label_url;
|
|
|
|
|
|
|
|
|
|
// load postage image
|
|
|
|
@ -82,22 +89,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";
|
|
|
|
|
if (!empty($shipment->from_address->email)) {
|
|
|
|
|
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) {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
$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");
|
|
|
|
|