I am trying to create dynamic coupons for my application. I have a PHP server that creates them. But I do not know why they do not work in a savings book.
If I create a passage from the terminal, it works fine. But in PHP with PHP-PKPass.
I left the PHP code below, it appears on my computer, but it is not added to the savings book (also if I send it by email)
Im 100% sure passTypeIdentifier, teamIdentifier, Certificate and WWDR are 100% correct
Note: all images exist
<?php
include ("conexion.php");
require('passpk/PKPass.php');
if (isset($_GET['cupon']) and $_GET['cupon'] != '' and $_GET['cupon'] > 0) {
$cuponID = $_GET['cupon'];
$pass = new PKPass\PKPass();
$pass->setCertificate('./Certificate.p12');
$pass->setCertificatePassword('*******');
$pass->setWWDRcertPath('./WWDR.pem');
$standardKeys = array(
'description' => 'Store',
'formatVersion' => 1,
'organizationName' => 'Store',
'passTypeIdentifier' => 'pass.store.store',
'serialNumber' => $cupon['id'],
'teamIdentifier' => '********'
);
$associatedAppKeys = array();
$relevanceKeys = array();
$styleKeys = array(
'coupon' => array(
'primaryFields' => array(
array(
'key' => 'key',
'label' => "Label"
)
),
'secondaryFields' => array(
array(
'key' => 'name',
'label' => 'Tienda',
'value' => "Name"
),
array(
'key' => 'date',
'label' => 'Válido hasta',
'value' => "Vigencia"
)
),
'backFields' => array(
array(
'key' => 'tienda',
'label' => 'Tienda',
'value' => "tienda"
),
array(
'key' => 'sucursales',
'label' => 'Sucursales',
'value' => 'Valido en las sucursales y sus horarios'
),
array(
'key' => 'description',
'label' => 'Descripción',
'value' => "descr"
),
array(
'key' => 'terms',
'label' => 'Términos y Condiciones',
'value' => "cupon"
)
)
)
);
$visualAppearanceKeys = array(
'barcode' => array(
'format' => 'PKBarcodeFormatPDF417',
'message' => "cupon",
'messageEncoding' => 'iso-8859-1'
),
'foregroundColor' => 'rgb(255, 255, 255)',
'backgroundColor' => 'rgb(4, 148, 203)',
'logoText' => 'cupon'
);
$webServiceKeys = array();
$passData = array_merge(
$standardKeys,
$associatedAppKeys,
$relevanceKeys,
$styleKeys,
$visualAppearanceKeys,
$webServiceKeys
);
$pass->setJSON(json_encode($passData));
$uniqID = uniqid('', true);
$dir = './tempDir/'.$uniqID;
mkdir($dir, 0777);
copy('../'.$img, './tempDir/'.$uniqID.'/strip.png');
$pass->addFile($dir.'/strip.png');
$pass->addFile('images/icon.png');
$pass->addFile('images/icon@2x.png');
$pass->addFile('images/logo.png');
$pass->addFile('images/logo@2x.png');
if(!$pass->create(true)) {
echo 'Error: '.$pass->getError();
}
unlink($dir.'/strip.png');
rmdir($dir);
}