Skip to content

Commit

Permalink
Had to add support for the .order in zip since it was not being respe…
Browse files Browse the repository at this point in the history
…cted
  • Loading branch information
xitude committed Aug 28, 2024
1 parent 99ba67d commit 81a5f12
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions src/FinanceOrder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down

0 comments on commit 81a5f12

Please sign in to comment.