tschoffelen / php-pkpass

💳 PHP class for creating passes for Wallet on iOS.
https://includable.com
MIT License
916 stars 186 forks source link

Pass Code Certificate Error #104

Closed Kamran95 closed 3 years ago

Kamran95 commented 4 years ago

Expected Behavior

Should accept certificate

Actual Behavior

Getting Error Error: Invalid certificate file. Make sure you have a P12 certificate that also contains a private key, and you have specified the correct password! Certificate was created as told. Exported both (certificate and its private key) but still getting the same error

Steps to Reproduce the Problem

Code in Laravel. <?php

namespace App\Http\Controllers; use PKPass\PKPass;

require('../vendor/autoload.php'); use Illuminate\Http\Request;

class ControllerApplePay extends Controller { public function ApplePay(){ // Replace the parameters below with the path to your .p12 certificate and the certificate password! $pass = new PKPass('../Certificates.p12', '*****'); dd($pass); // Pass content $data = [ 'description' => 'Demo pass', 'formatVersion' => 1, 'organizationName' => 'Flight Express', 'passTypeIdentifier' => 'pass.org.****.applepay', 'serialNumber' => '**', 'teamIdentifier' => '****', 'boardingPass' => [ 'primaryFields' => [ [ 'key' => 'origin', 'label' => 'San Francisco', 'value' => 'SFO', ], [ 'key' => 'destination', 'label' => 'London', 'value' => 'LHR', ], ], 'secondaryFields' => [ [ 'key' => 'gate', 'label' => 'Gate', 'value' => 'F12', ], [ 'key' => 'date', 'label' => 'Departure date', 'value' => '07/11/2012 10:22', ], ], 'backFields' => [ [ 'key' => 'passenger-name', 'label' => 'Passenger', 'value' => 'John Appleseed', ], ], 'transitType' => 'PKTransitTypeAir', ], 'barcode' => [ 'format' => 'PKBarcodeFormatQR', 'message' => 'Flight-GateF12-ID6643679AH7B', 'messageEncoding' => 'iso-8859-1', ], 'backgroundColor' => 'rgb(32,110,247)', 'logoText' => 'Flight info', 'relevantDate' => date('Y-m-d\TH:i:sP') ]; $pass->setData($data);

// Add files to the pass package
$pass->addFile('images/icon.png');
$pass->addFile('images/icon@2x.png');
$pass->addFile('images/logo.png');

// Create and output the pass
if(!$pass->create(true)) {
    echo 'Error: ' . $pass->getError();
}
dd("ok");

} }

lightgreenwings commented 1 year ago

getting the same error, any solutions?