diff --git a/source/pages/index.html b/source/pages/index.html
index b30951b..0103b72 100644
--- a/source/pages/index.html
+++ b/source/pages/index.html
@@ -128,10 +128,38 @@
-
Options:
+ Speed:
+
+
+ Services:
+
+
+
+ Extra Options:
+
+
+ By continuing, you acknowledge that you aren't sending anything except paper documents.
+
+
diff --git a/source/static/assets/js/shipment.js b/source/static/assets/js/shipment.js
index ebbe69a..ee5eacb 100644
--- a/source/static/assets/js/shipment.js
+++ b/source/static/assets/js/shipment.js
@@ -10,6 +10,7 @@ var printed = false;
function getRateAndValidateAddress() {
$("#getRateAndValidateAddressButton").html(' Working...');
disableGetRateButton = true;
+ $("#addresserror").text("");
$.post("makeshipment.php",
$("#addressform").serialize(),
function (resp) {
@@ -70,6 +71,7 @@ function getRateAndValidateAddress() {
$("#getRateAndValidateAddressButton").html(' Next');
$("#header-small-text").text("Confirm and Pay");
document.getElementById("label").scrollIntoView();
+ $("#addresserror").text("");
disablePayButton = false;
} else {
$("#addresserror").text(resp.message);
@@ -100,7 +102,8 @@ function submitPayment() {
"shipmentid": shipmentid,
"rateid": rateid,
"stripeid": result.paymentMethod.id,
- "price": price
+ "price": price,
+ "label_only": document.getElementById('label_only').checked ? "1" : ""
},
function (resp) {
if (resp.status == "OK") {
diff --git a/source/static/makeshipment.php b/source/static/makeshipment.php
index eb068bc..4d12429 100644
--- a/source/static/makeshipment.php
+++ b/source/static/makeshipment.php
@@ -61,27 +61,35 @@ try {
$weight = ($_REQUEST["page_count"] * 1 + 1) / 5;
}
- if ($weight > 3.5) {
- throw new Exception("Too many pages to send as a letter.");
+ if ($weight > 3.5 && $_REQUEST["postagetype"] == "first") {
+ throw new Exception("Too many pages to send as a First-Class letter. Use Priority Mail instead.");
+ }
+
+ if (!empty($_REQUEST["flat_rate"]) && $_REQUEST["flat_rate"] == "flat_rate") {
+ $shipmentinfo["parcel"] = \EasyPost\Parcel::create([
+ "predefined_package" => "FlatRateEnvelope",
+ "weight" => $weight
+ ]);
+ } else {
+ $shipmentinfo["parcel"] = \EasyPost\Parcel::create([
+ "predefined_package" => "Letter",
+ "weight" => $weight
+ ]);
}
- $shipmentinfo["parcel"] = \EasyPost\Parcel::create([
- "predefined_package" => "Letter",
- "weight" => $weight
- ]);
if (empty($_SETTINGS["test"]) || $_SETTINGS["test"] != true) {
$shipmentinfo["carrier_accounts"] = [$_SETTINGS["easypost_usps_account"]]; // USPS
}
- if ($_REQUEST["postagetype"] == "certified") {
+ if ($_REQUEST["postageservice"] == "certified") {
$shipmentinfo["options"]["certified_mail"] = true;
- } else if ($_REQUEST["postagetype"] == "certified_receipt") {
+ } else if ($_REQUEST["postageservice"] == "certified_receipt") {
$shipmentinfo["options"]["certified_mail"] = true;
$shipmentinfo["options"]["return_receipt"] = true;
}
- if ($_REQUEST["restricted_delivery"] == "restricted_delivery") {
+ if (!empty($_REQUEST["restricted_delivery"]) && $_REQUEST["restricted_delivery"] == "restricted_delivery") {
if (!empty($shipmentinfo["options"]["certified_mail"]) && $shipmentinfo["options"]["certified_mail"] == true) {
$shipmentinfo["options"]["delivery_confirmation"] = "SIGNATURE_RESTRICTED";
} else {
@@ -89,8 +97,19 @@ try {
}
}
- $shipmentinfo["options"]["label_format"] = "PNG";
- $shipmentinfo["options"]["label_size"] = "7x3";
+ if ($_REQUEST["postagetype"] == "priority") {
+ $shipmentinfo["options"]["label_format"] = "PNG";
+ $shipmentinfo["options"]["label_size"] = "4x6";
+ } else {
+ $shipmentinfo["options"]["label_format"] = "PNG";
+ $shipmentinfo["options"]["label_size"] = "7x3";
+ }
+
+
+ if ($_REQUEST["postagetype"] == "first" && ((!empty($_REQUEST["flat_rate"]) && $_REQUEST["flat_rate"] == "flat_rate") || (!empty($_REQUEST["label_only"]) && $_REQUEST["label_only"] == "label_only"))) {
+ throw new Exception("First-Class Mail can't be combined with the \"Print Postage Only\" or the \"Print Flat Rate Postage\" options.");
+ }
+
$mailing_date = date("c", strtotime("tomorrow"));
if (!empty($_REQUEST["mailing_date"])) {
@@ -115,13 +134,16 @@ try {
$rate = $shipment->rates[$i];
$retail_rate = $rate->retail_rate ?? ($rate->list_rate ?? $rate->rate);
- if ($rate->service != "First") {
+ if ($_REQUEST["postagetype"] == "priority" && $rate->service != "Priority") {
+ continue;
+ }
+ if ($_REQUEST["postagetype"] == "first" && $rate->service != "First") {
continue;
}
$selectedrate = [
"id" => $rate->id,
- "cost" => $retail_rate,
+ "cost" => $rate->rate,
"price" => $retail_rate + 1.00
];
}
diff --git a/source/static/papertemplate-labelonly-certified.png b/source/static/papertemplate-labelonly-certified.png
new file mode 100644
index 0000000..0f35c28
Binary files /dev/null and b/source/static/papertemplate-labelonly-certified.png differ
diff --git a/source/static/papertemplate-labelonly.png b/source/static/papertemplate-labelonly.png
new file mode 100644
index 0000000..2b35854
Binary files /dev/null and b/source/static/papertemplate-labelonly.png differ
diff --git a/source/static/papertemplate_labelonly.svg b/source/static/papertemplate_labelonly.svg
new file mode 100644
index 0000000..f731a37
--- /dev/null
+++ b/source/static/papertemplate_labelonly.svg
@@ -0,0 +1,112 @@
+
+
diff --git a/source/static/papertemplate_labelonly_certified.svg b/source/static/papertemplate_labelonly_certified.svg
new file mode 100644
index 0000000..a1b4484
--- /dev/null
+++ b/source/static/papertemplate_labelonly_certified.svg
@@ -0,0 +1,119 @@
+
+
diff --git a/source/static/payshipment.php b/source/static/payshipment.php
index 7cec9c6..e65bd87 100644
--- a/source/static/payshipment.php
+++ b/source/static/payshipment.php
@@ -57,7 +57,34 @@ try {
// load postage image
$labelimage = imagecreatefrompng($labelurl);
- if (!empty($shipment->options->certified_mail)) {
+ if ($shipment->postage_label->label_size == "4x6") {
+ if ((!empty($_REQUEST["label_only"]) && $_REQUEST["label_only"] == "1") || $shipment->parcel->predefined_package == "FlatRateEnvelope") {
+ if (!empty($shipment->options->certified_mail)) {
+ // label and banner only
+ $paperimage = imagecreatefrompng(__DIR__ . "/papertemplate-labelonly-certified.png");
+ } else {
+ // label only
+ $paperimage = imagecreatefrompng(__DIR__ . "/papertemplate-labelonly.png");
+ }
+ imagecopyresampled($paperimage, $labelimage, 675, 753, 0, 0, 1200, 1800, 1200, 1800);
+ } else {
+ if (!empty($shipment->options->certified_mail)) {
+ // envelope with banner
+ $paperimage = imagecreatefrompng(__DIR__ . "/papertemplate.png");
+ } else {
+ // plain envelope
+ $paperimage = imagecreatefrompng(__DIR__ . "/papertemplate_notracking.png");
+ }
+ $labelimage = imagerotate($labelimage, 270, 0);
+ imagecopyresampled($paperimage, $labelimage, 375, 750, 0, 0, 1800, 1200, 1800, 1200);
+ if ($shipment->options->delivery_confirmation == "SIGNATURE_RESTRICTED") {
+ $restrictedstamp = imagecreatefrompng(__DIR__ . "/restricted_delivery.png");
+ $restrictedstamp = imagerotate($restrictedstamp, 270, 0);
+ imagecopyresampled($paperimage, $restrictedstamp, 2200, 1050, 0, 0, 225, 600, 225, 600);
+ imagecopyresampled($paperimage, $restrictedstamp, 130, 1050, 0, 0, 225, 600, 225, 600);
+ }
+ }
+ } else if (!empty($shipment->options->certified_mail)) {
// load page template
$paperimage = imagecreatefrompng(__DIR__ . "/papertemplate.png");