vendredi 5 août 2016

PHP generated pass is not being installed in wallet on an iPhone

I am using this passgenerator library to generate a .pkpass which is supposed to be installed on an apple wallet on iPhone. The .pkpass file is generated successfully but it could not be added to "wallet" on iPhone it even don't show any error when I try to open this file from an email attachment. When I open it with "Pass Viewer" on mac it shows some error on bar-code area. Here is screenshot;

enter image description here

I don't know where I am doing something wrong. I am using laravel 5.1 and I have required this package correctly and also as documentation asked to set environment variables to set certificates paths.

CERTIFICATE_PATH= './assets/certificates/PassCertificate.p12'
CERTIFICATE_PASS= "mypassword"
WWDR_CERTIFICATE='./assets/certificates/WWDRCA.pem'

Here is my controller code where I am setting its configurations in json format.

public function index(PassGenerator $pass)
    {
        $pass_identifier = 'testPkPass';  // This, if set, it would allow for retrieval later on of the created Pass
        $pkpass = $pass->getPass($pass_identifier);
        if (!$pkpass) {
            $pkpass = $this->createWalletPass($pass_identifier);
        }
        $path = storage_path().'/app/passgenerator/'.$pass_identifier.'.pkpass';
        return Response::download($path, $pass_identifier.'.pkpass', [
            'Content-Transfer-Encoding' => 'binary',
            'Content-Description' => 'File Transfer',
            'Content-Disposition' => 'attachment; filename="myTestingPass.pkpass"',
            'Content-length' => strlen($pkpass),
            'Content-Type' => PassGenerator::getPassMimeType(),
            'Pragma' => 'no-cache',
        ]);
    }

    private function createWalletPass($pass_identifier)
    {

        $pass = new PassGenerator($pass_identifier);

        $pass_definition = [
            "description"       => "description",
            "formatVersion"     => 1,
            "organizationName"  => "Black Book",
            "passTypeIdentifier"=> "pass.biz.myIdentifier.coupon",
            "serialNumber"      => "123456",
            "teamIdentifier"    => "xyz",
            "foregroundColor"   => "rgb(255, 255, 255)",
            "backgroundColor"   => "rgb(44, 49, 51)",
            "barcode" => [
                "message"   => "encodedmessageonQR",
                "format"    => "PKBarcodeFormatQR",
                "altText"   => "altextfortheQR",
                "messageEncoding"=> "utf-8",
            ],
            "coupon" => [
                "headerFields" => [
                    [
                        "key" => "header",
                        "label" => "Value",
                        "value" => "30%"
                    ]
                ],
                "secondaryFields" => [
                    [
                        "key" => "welcome",
                        "label" => "",
                        "value" => "Welcome valued customer!"
                    ],
                    [
                        "key" => "date",
                        "label" => "EXPIRES",
                        "value" => "2016/06/29"
                    ]
                ],
                "backFields" => [
                    [
                        "key" => "terms",
                        "label" => "Terms & Conditions",
                        "value" => "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
                    ], [
                        "key" => "contact",
                        "label" => "Contact Us",
                        "value" => "[Contact-us] Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco."
                    ], 
                ],
            ],
        ];

        $pass->setPassDefinition($pass_definition);

        // Add assets to the PKPass package
        $pass->addAsset(base_path('public/assets/wallet/background.png'));
        $pass->addAsset(base_path('public/assets/wallet/thumbnail.png'));
        $pass->addAsset(base_path('public/assets/wallet/icon.png'));
        $pass->addAsset(base_path('public/assets/wallet/logo.png'));

        $pkpass = $pass->create();
        return $pkpass;
    }

Any help would be really appreciated. Please let me know if I am doing anything wrong with configuration or somewhere else.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire