diff --git a/README.md b/README.md index c5d15e7..484b6a8 100644 --- a/README.md +++ b/README.md @@ -54,6 +54,18 @@ style it, take a look at the [docs at developers.apple.com](https://developer.ap choose `Export 2 items…`. 6. Choose a password and export the file to a folder. +### Requesting the Order Certificate + +1. Go to the [iOS Provisioning portal](https://developer.apple.com/account/ios/identifier/passTypeId). +2. Create a new Order Type ID Certificate, and write down the Order Type ID you choose, you'll need it later. +3. Click the edit button under your newly created Order Type ID and generate a certificate according to the instructions + shown on the page. Make sure *not* to choose a name for the Certificate but keep it empty instead. +4. Download the .cer file and drag it into Keychain Access. +5. Find the certificate you just imported and click the triangle on the left to reveal the private key. +6. Select both the certificate and the private key it, then right-click the certificate in Keychain Access and + choose `Export 2 items…`. +6. Choose a password and export the file to a folder. + #### OpenSSL error When you get the error 'Could not read certificate file. This might be related to using an OpenSSL version that has deprecated some older hashes. More info here: https://schof.link/2Et6z3m OpenSSL error: error:0308010C:digital envelope routines::unsupported' this is due to osx exporting the .p12 file using an old version of OpenSSL. To fix this issue, use the following commands: 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. *