-
-
Notifications
You must be signed in to change notification settings - Fork 187
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for Wallet Orders #137
Add support for Wallet Orders #137
Conversation
This looks amazing! It's a lot cleaner than I thought it would be to extend the class like this, great! Definitely mergeable if we add some docs. A test would be good indeed. I think the signing cert for the current test could be reused for the orders test. The test doesn't have to generate a signature that Apple is happy with/recognises, at least if you're happy using the same type of test setup used for the PKPass test. |
I have added a unit test (I'm a Magento developer so used an order in the sampledata as an example to base it on). I re-read the original comment on the issue and had another think about making some more changes to add an abstract class, but on reflection I think its probably ok as-is. If Apple add another feature that requires creating a "signed bundle/package" perhaps it'll be worth taking another look then. For the unit test I originally thought about creating a real Apple one but as you mentioned it only really needs to succeed in signing as there is no integration test validating it on a device. I have used the same data (apart from the order and merchant identifier) to create one I have validated on device so I am happy with that. Marking as ready for review.🙂 |
Great, I'm going to get this merged now. In the future we might want to add some docs to explain the usage of this, but hopefully for now the new test should guide people in the right direction if they stumble upon this. |
Released to Packagist as 2.3.0 - thanks again @cjnewbs! |
Thats amazing, glad you like it 🤩 ! I realised I forgot to add any docs to this earlier last week. Just sat down to write some simple ones and noticed this merged. I'll get a few put together and create a subsequent PR at some point. Hope that's ok 🙂 |
Of course, thank you! |
Im trying to get this to work and running into the error (I'm attempting to get docs updated) Converting the pkpass to a zip, shows the pass.json is available in the file. Looks the same as this issue in another repo
Im just wondering anyone ever got a functional order to show on apple wallet with the test file you made, or are we very much still attempting this? (I'm attempting with apples Minimum configuration json) $pass = new FinanceOrder(base_path('***.p12'), 'password');
$data = [
"merchant" => [
"displayName" => "***",
"merchantIdentifier" => "***",
"logo" => "logo.png",
"url" => "***"
],
"orderTypeIdentifier" => "***",
"orderIdentifier" => "U2ecItkLLbs8CdGP",
"status" => "open",
"createdAt" => Carbon::now()->toAtomString(),
"updatedAt" => Carbon::now()->toAtomString(),
"orderType" => "ecommerce",
"orderManagementURL" => "https://applepaydemo.apple.com/order-tracking",
"authenticationToken" => "qtGZX4m4ArxlkqA5cVR3wx8ykL65LK",
"schemaVersion" => 1
];
$pass->setData($data);
$pass->addFile(public_path('assets/images/example/logo.png'));
$pass->addFile(public_path('assets/images/example/icon@2x.png'));
$pass->create(true); Edit - |
Summary
Added support for Apple Wallet orders. Thought I'd open a draft PR to get some feedback before I go any further. I have tested that this works by creating a bare minimum test order, and AirDropping it to my iPhone.
PKOrder
as mentioned, then I went to find the equivalent for orders but was unable to find one. I then saw the mime type wasapplication/vnd.apple.finance.order
so thoughtFinanceOrder
might work? Happy for this to be renamed back toPKOrder
,$json
to string,createSignature
: Used the parent method as I don't think the path has any affect on the signature creation,createManifest
: I did start by replacing this method with one that uses thehash
method like in the FinanceOrder class but realised that the pass also needs anicon.png
file so copied it to the child method,getName
: Updated to use the const's from the class that was instantiated.Happy to revert all the changes I made to make the PKPass class a little bit more flexible and instead override the method in FinanceOrder.
Todo:
Will resolve #136