Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding Documentation and example for Order Wallet Types #146

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
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
Loading