From 81a5f125d3ffc7597adf606f8b3a9717ed501e69 Mon Sep 17 00:00:00 2001 From: Zac Grierson Date: Wed, 28 Aug 2024 18:56:37 +0000 Subject: [PATCH] Had to add support for the .order in zip since it was not being respected --- src/FinanceOrder.php | 52 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/src/FinanceOrder.php b/src/FinanceOrder.php index 33dc427..c3510fe 100644 --- a/src/FinanceOrder.php +++ b/src/FinanceOrder.php @@ -58,6 +58,58 @@ protected function createManifest() return json_encode((object)$sha); } + /** + * Create the actual .pkpass file. + * + * @param bool $output Whether to output it directly or return the pass contents as a string. + * + * @return string + * @throws PKPassException + */ + public function create($output = false) + { + // Prepare payload + $manifest = $this->createManifest(); + $signature = $this->createSignature($manifest); + + // Build ZIP file + $zip = $this->createZip($manifest, $signature); + + // Return pass + if (!$output) { + return $zip; + } + + // Output pass + header('Content-Description: File Transfer'); + header('Content-Type: ' . self::MIME_TYPE); + header('Content-Disposition: attachment; filename="' . $this->getName() . '"'); + header('Content-Transfer-Encoding: binary'); + header('Connection: Keep-Alive'); + header('Expires: 0'); + header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); + header('Last-Modified: ' . gmdate('D, d M Y H:i:s T')); + header('Pragma: public'); + echo $zip; + + return ''; + } + + /** + * Get filename. + * + * @return string + */ + public function getName() + { + $name = $this->name ?: self::FILE_TYPE; + if (!strstr($name, '.')) { + $name .= '.' . self::FILE_EXT; + } + + return $name; + } + /** * Creates .pkpass zip archive. *