`public function createApplePass(Request $request) {
// phpinfo();
$uniqueId = uniqid();
$pass = new GenericPass([
'serialNumber' => $uniqueId,
'description' => 'Card',
'organizationName' => '****',
'passTypeIdentifier' => '****',
'teamIdentifier' => '****',
]);
$barcode = new Barcode([
'format' => 'PKBarcodeFormatQR',
'message' => 'https://my-app.app/sample-url',
'messageEncoding' => 'iso-8859-1',
]);
$pass->barcodes = [$barcode];
$pass->backgroundColor = 'rgb(0, 100, 255)';
$pass->labelColor = 'rgb(255, 255, 255)';
$logoPath = storage_path('app/public/img/layout/logo.png');
if (file_exists($logoPath) && mime_content_type($logoPath) === 'image/png') {
$pass->addImage(new Image($logoPath, ImageType::ICON, 1));
$pass->addImage(new Image($logoPath, ImageType::LOGO, 1));
} else {
throw new \Exception('Icon and logo images must exist at ' . $logoPath . ' and be valid PNG files.');
}
// $this->builder->apple()->create($pass);
// $signedPass = $this->builder->apple()->create($pass);
$factory = new PassFactory();
$factory->setCertificate(config('passes.apple.certificate'));
$factory->setPassword(config('passes.apple.password'));
$factory->setWwdr(config('passes.apple.wwdr'));
$factory->setOutput(config('passes.apple.disk'));
// dd(config('passes.apple.disk'));
$factory->create($pass, $uniqueId);
// dd($factory);
// return redirect()->back();
return response()->make($pass, 200, [
'Content-Type' => 'application/vnd.apple.pkpass',
'Content-Disposition' => 'attachment; filename="'.$uniqueId.'.pkpass"',
]);
}
Topic:
App & System Services
SubTopic:
Apple Pay
Tags: