chiiya / laravel-passes Goto Github PK
View Code? Open in Web Editor NEWLaravel package for creating iOS and Android Wallet Passes.
License: MIT License
Laravel package for creating iOS and Android Wallet Passes.
License: MIT License
I have created a certificate file by exporting it with its private key from Apple Keychain, as directed in the requirements file, but I'm getting an error when the PassFactory tries to sign the pass:
Invalid certificate file: "certificates/certificates.p12"
I found that if I try to read it with openssl, I get this error:
openssl pkcs12 -info -in certificates/certificates.p12
Enter Import Password:
MAC: sha1, Iteration 1
MAC length: 20, salt length: 8
PKCS7 Encrypted data: pbeWithSHA1And40BitRC2-CBC, Iteration 2048
Error outputting keys and certificates
806075EE01000000:error:0308010C:digital envelope routines:inner_evp_generic_fetch:unsupported:crypto/evp/evp_fetch.c:341:Global default library context, Algorithm (RC2-40-CBC : 0), Properties ()
Searching on that reveals that this is apparently due to an old format for the p12 file, and to read it in the openssl binary I needed to add -legacy
to the command line, after which it seems to show the contents of the file correctly. So now I'm suspecting that PHP may have a similar problem reading it, but I don't know how to do the equivalent of setting the legacy flag in PHP. Any ideas?
I'am trying to make a generic pass with a logo:
$object = new GenericObject(
.........
logo: Image::make('https://s3.amazonaws.com/.........'),
.........
);
spatie/data-transfer-object
shouldn't be used since the package isn't maintained anymore. In the best case, no dependency should be used for this at all.
The comment for the MEDIA_DISK
config property is incorrect here - it's the comment for the certificate password. I'm not exactly sure what this property is used for (why I was reading the comment!), otherwise I would have made a PR for this.
$object = $objectRepository->get($objectId);
$object->state = State::INACTIVE;
$objectRepository->update($object); // Validation error: `Chiiya\Passes\Google\Passes\GenericObject->state`: The value is invalid. Should be one of .STATE_UNSPECIFIED, ACTIVE, COMPLETED, EXPIRED, INACTIVE
Apparently when a google pass' state is set to 'INACTIVE', the API returns the state legacy value 'inactive'. It seems that then the State method mapLegacyValues is applied. Due to the order of the values, the substring 'active' is replaced first, so 'inactive' becomes 'inACTIVE', which triggers the validation error.
In the mapLegacyValues State method I would use preg_replace:
preg_replace(['/^active$/', '/^completed$/', '/^expired$/', '/^inactive$/'], [self::ACTIVE, self::COMPLETED, self::EXPIRED, self::INACTIVE], $value);
instead of:
str_replace(['active', 'completed', 'expired', 'inactive'], [self::ACTIVE, self::COMPLETED, self::EXPIRED, self::INACTIVE], $value);
Or change the order of the replace values, such as:
str_replace(['inactive', 'active', 'completed', 'expired'], [self::INACTIVE, self::ACTIVE, self::COMPLETED, self::EXPIRED], $value);
I use the following code to create a validTimeInterval in an EventTicketObject
validTimeInterval: new TimeInterval(
start: new DateTime(date: Carbon::now()),
end: new DateTime(Carbon::now()->addMonth())
),
However the following error message appears
PHP Fatal error: Uncaught Spatie\DataTransferObject\Exceptions\ValidationException: Validation errors:
- `Chiiya\Passes\Google\Components\Common\DateTime->date`: The field is required. in /var/www/GoogleWalletDemo/vendor/spatie/data-transfer-object/src/Reflection/DataTransferObjectClass.php:63
Stack trace:
#0 /var/www/GoogleWalletDemo/vendor/spatie/data-transfer-object/src/DataTransferObject.php(38): Spatie\DataTransferObject\Reflection\DataTransferObjectClass->validate()
#1 /var/www/GoogleWalletDemo/src/google_event.php(91): Spatie\DataTransferObject\DataTransferObject->__construct()
#2 {main}
thrown in /var/www/GoogleWalletDemo/vendor/spatie/data-transfer-object/src/Reflection/DataTransferObjectClass.php on line 63
This package has a dependency on the spatie/data-transfer-object package, which is no longer maintained.
They recommend that you switch to their spatie/laravel-data package instead, though I've not spotted a migration advice (so I asked). Alternatively, they suggest using cuyz/valinor for handling strongly-typed DTOs.
The dependency is actually in your passes package, but when I created an issue in there, it created one in this repo instead because of the settings in here. Is that intentional?
I have the following test pass
use Chiiya\Passes\Apple\Components\Image;
use Chiiya\Passes\Apple\Enumerators\ImageType;
use Chiiya\Passes\Apple\PassFactory;
$pass = new \Chiiya\Passes\Apple\Passes\GenericPass(
description: '15% off purchases',
organizationName: 'organization',
passTypeIdentifier: 'pass.identifier,
serialNumber: '1',
teamIdentifier: 'organization id',
);
$pass
->addImage(new Image('logo.png', ImageType::ICON))
->addImage(new Image('logo.png', ImageType::ICON, 2))
;
$factory = new PassFactory();
$factory->setCertificate(__DIR__ . "/Certificates55.p12");
$factory->setPassword('password');
$factory->setWwdr(__DIR__ . "/aww.pem");
$factory->setOutput(__DIR__);
$file = $factory->create($pass, 'filename');
this creates the pass file successfully, but i am unable to use/import them in my app. If i use the example passes that Apple provides https://developer.apple.com/services-account/download?path=/iOS/Wallet_Support_Materials/WalletCompanionFiles.zip, my app loads it just fine.
Am I missing something?
Hi,
This could be a misguided question, so please feel free to correct anything daft.
If I currently search the LoyaltyObjectRepository and get the LoyaltyObject, it is 3800+ chars, after a create a JWT for the object.
Thanks in advance for any ideas...
This is a question (which would go into discussions, but the discussions tab is not enabled).
Looking at the code in passes, it seems that the pkpass files are always generated and saved on disk. The passes I generate are typically short-lived, and I don't need to cache them or generally keep them lying around, so I'm looking to generate passes dynamically and deliver them directly to the client without hitting disk.
Is there a built-in way to do this, or do I have to generate the pass on disk, send it to the client, then delete it?
I know that some PHP functions in zip or openssl might only work on disk files, which is fine, I just need to know if that's the case.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.