You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+7-43Lines changed: 7 additions & 43 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -18,20 +18,16 @@ Wallet Kit helps you build the **JSON payloads** wallet platforms expect. It foc
18
18
-**PHP** 8.5+
19
19
-**symfony/serializer** ^8.0
20
20
21
-
## Dual-platform builder
21
+
## 🛠️ Builder
22
22
23
-
The **`Jolicode\WalletKit\Builder`** namespace provides a **fluent API** that builds **both** an Apple [`Pass`](src/Pass/Apple/Model/Pass.php) and the matching Google Wallet **class + object** in one go. Entry point: [`WalletPass`](src/Builder/WalletPass.php) (`generic`, `offer`, `loyalty`, `eventTicket`, `flight`, `transit`, `giftCard`).
23
+
The **`Jolicode\WalletKit\Builder`** namespace exposes a fluent API around [`WalletPass`](src/Builder/WalletPass.php). For **Apple and Google together**, use [`WalletPlatformContext::both(...)`](src/Builder/WalletPlatformContext.php) then `build()` → [`BuiltWalletPass`](src/Builder/BuiltWalletPass.php) (`apple()`, `google()`). Normalize the models with Symfony Serializer and this package’s normalizers.
24
24
25
-
1. Create a [`WalletPlatformContext`](src/Builder/WalletPlatformContext.php) with your Apple identifiers (team, pass type, serial, organization, description) and Google IDs (`classId`, `objectId`).
26
-
2. Chain portable options (barcodes, colors, grouping, validity, web service URL, …) via [`CommonWalletBuilderTrait`](src/Builder/CommonWalletBuilderTrait.php).
27
-
3. Call **`build()`** → [`BuiltWalletPass`](src/Builder/BuiltWalletPass.php): `apple()` for `pass.json`, `google()` for the [`GoogleWalletPair`](src/Builder/GoogleWalletPair.php) (issuer class + holder object).
Apple’s model maps to a **single** tree: either use the **builder** above or build a `Pass` manually (see `src/Pass/Apple/`) and normalize it to the structure that becomes **`pass.json`** inside a pass package. Images, manifest, and cryptographic signing are still your responsibility.
Copy file name to clipboardExpand all lines: docs/builder-examples.md
+67-5Lines changed: 67 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,17 +1,17 @@
1
1
# Wallet Kit — Builder examples
2
2
3
-
This page shows one **end-to-end example** per vertical supported by [`WalletPass`](../src/Builder/WalletPass.php). Each example assumes you already configured a[`WalletPlatformContext`](../src/Builder/WalletPlatformContext.php)with your real Apple and Google identifiers.
3
+
This page shows one **end-to-end example** per vertical supported by [`WalletPass`](../src/Builder/WalletPass.php). Examples below use a **dual-platform** context; you can also use[`WalletPlatformContext::appleOnly`](../src/Builder/WalletPlatformContext.php)or [`::googleOnly`](../src/Builder/WalletPlatformContext.php) when you only target one store.
4
4
5
5
After `build()`, you get a [`BuiltWalletPass`](../src/Builder/BuiltWalletPass.php):
6
6
7
-
-`$built->apple()` → Apple [`Pass`](../src/Pass/Apple/Model/Pass.php) for `pass.json`
8
-
-`$built->google()->issuerClass` / `$built->google()->passObject` → Google class and object for the Wallet API
7
+
-`$built->apple()` → Apple [`Pass`](../src/Pass/Apple/Model/Pass.php) for `pass.json` (throws [`ApplePassNotAvailableException`](../src/Exception/ApplePassNotAvailableException.php) if the context had no Apple slice)
8
+
-`$built->google()->issuerClass` / `$built->google()->passObject` → Google class and object (throws [`GoogleWalletPairNotAvailableException`](../src/Exception/GoogleWalletPairNotAvailableException.php) if there was no Google slice)
9
9
10
10
Serialize with **Symfony Serializer** and the normalizers from this package (see [`tests/Builder/BuilderTestSerializerFactory.php`](../tests/Builder/BuilderTestSerializerFactory.php) for a full list).
11
11
12
12
---
13
13
14
-
## Shared context (all examples)
14
+
## Shared context (dual-platform examples)
15
15
16
16
```php
17
17
<?php
@@ -22,7 +22,7 @@ use Jolicode\WalletKit\Builder\WalletPlatformContext;
22
22
use Jolicode\WalletKit\Pass\Android\Model\Shared\ReviewStatusEnum;
23
23
use Jolicode\WalletKit\Pass\Android\Model\Shared\StateEnum;
24
24
25
-
$context = new WalletPlatformContext(
25
+
$context = WalletPlatformContext::both(
26
26
appleTeamIdentifier: 'YOUR_TEAM_ID',
27
27
applePassTypeIdentifier: 'pass.com.example.app',
28
28
appleSerialNumber: 'UNIQUE-SERIAL-001',
@@ -37,6 +37,67 @@ $context = new WalletPlatformContext(
37
37
38
38
---
39
39
40
+
## Apple-only and Google-only snippets
41
+
42
+
**Apple-only** (no Google IDs required). After `build()`, use only `$built->apple()`; `$built->google()` throws.
43
+
44
+
```php
45
+
use Jolicode\WalletKit\Builder\WalletPlatformContext;
46
+
use Jolicode\WalletKit\Builder\WalletPass;
47
+
use Jolicode\WalletKit\Pass\Apple\Model\Field;
48
+
use Jolicode\WalletKit\Pass\Apple\Model\PassStructure;
49
+
use Jolicode\WalletKit\Pass\Android\Model\Generic\GenericTypeEnum;
**Google-only** (requires `issuerName` on the context for class payloads). After `build()`, use `$built->google()`; `$built->apple()` throws. You can still call `addAppleBarcode()` to supply a barcode image for the Google object.
70
+
71
+
```php
72
+
use Jolicode\WalletKit\Builder\WalletPlatformContext;
73
+
use Jolicode\WalletKit\Builder\WalletPass;
74
+
use Jolicode\WalletKit\Pass\Android\Model\Offer\RedemptionChannelEnum;
75
+
use Jolicode\WalletKit\Pass\Apple\Model\Barcode;
76
+
use Jolicode\WalletKit\Pass\Apple\Model\BarcodeFormatEnum;
**Use case:** membership card, insurance card, or any pass that does not fit a specialized vertical.
@@ -273,3 +334,4 @@ These methods come from [`CommonWalletBuilderTrait`](../src/Builder/CommonWallet
273
334
274
335
- The library does **not** sign `.pkpass` bundles or call Google Wallet REST APIs.
275
336
- Apple and Google models differ: not every field exists on both sides. Use `mutateApple` or adjust the returned Google class/object after `build()` for platform-specific details.
337
+
- A [`WalletPlatformContext`](../src/Builder/WalletPlatformContext.php) with **no** Apple and **no** Google slice throws [`InvalidWalletPlatformContextException`](../src/Exception/InvalidWalletPlatformContextException.php). Google-only contexts must include a non-empty `issuerName` (or use `::googleOnly(...)`, which enforces it).
0 commit comments