### Environment Setup for Configuration Source: https://github.com/chiiya/laravel-passes/blob/master/_autodocs/DOCUMENTATION_SUMMARY.txt Example of setting environment variables for package configuration. ```dotenv APPLE_CERTIFICATE_PATH=/path/to/your/certificate.pem APPLE_WWDR_PATH=/path/to/your/wwdr.pem APPLE_PASSWORD=your_certificate_password GOOGLE_CREDENTIALS_PATH=/path/to/your/google_credentials.json ``` -------------------------------- ### Apple Configuration Example Source: https://github.com/chiiya/laravel-passes/blob/master/_autodocs/DOCUMENTATION_SUMMARY.txt Example configuration options for Apple passes. ```php 'apple' => [ 'certificate_path' => env('APPLE_CERTIFICATE_PATH'), 'wwdr_path' => env('APPLE_WWDR_PATH'), 'password' => env('APPLE_PASSWORD'), 'storage_disk' => env('APPLE_STORAGE_DISK', 'local'), 'temp_directory' => env('APPLE_TEMP_DIRECTORY'), ], ``` -------------------------------- ### Google Configuration Example Source: https://github.com/chiiya/laravel-passes/blob/master/_autodocs/DOCUMENTATION_SUMMARY.txt Example configuration options for Google passes. ```php 'google' => [ 'credentials_path' => env('GOOGLE_CREDENTIALS_PATH'), 'valid_origins' => [ 'https://your-app.com', ], ], ``` -------------------------------- ### Testing Environment Configuration (.env) Source: https://github.com/chiiya/laravel-passes/blob/master/_autodocs/usage-patterns.md Example of environment variables for testing setup. Use test fixtures for certificates and credentials to ensure tests are isolated and reproducible. ```bash PASSES_APPLE_CERT=/tests/fixtures/test.p12 PASSES_APPLE_WWDR=/tests/fixtures/test_wwdr.pem PASSES_APPLE_PASSWORD=test PASSES_GOOGLE_CREDENTIALS=/tests/fixtures/test_creds.json MEDIA_DISK=testing ``` -------------------------------- ### Production Environment Configuration (.env) Source: https://github.com/chiiya/laravel-passes/blob/master/_autodocs/usage-patterns.md Example of environment variables for production setup. Ensure sensitive information like certificates and passwords are kept secure and referenced appropriately. ```bash PASSES_APPLE_CERT=/secure/certs/apple.p12 PASSES_APPLE_WWDR=/secure/certs/apple_wwdr.pem PASSES_APPLE_PASSWORD=${SECURE_PASSWORD} PASSES_GOOGLE_CREDENTIALS=/secure/certs/google.json PASSES_GOOGLE_ORIGINS=https://example.com,https://www.example.com MEDIA_DISK=s3 ``` -------------------------------- ### Configuration Access Example Source: https://github.com/chiiya/laravel-passes/blob/master/_autodocs/DOCUMENTATION_SUMMARY.txt Demonstrates how to access package configuration values. ```php use Illuminate\Support\Facades\Config; $appleCertPath = Config::get('laravel-passes.apple.certificate_path'); $googleCredentialsPath = Config::get('laravel-passes.google.credentials_path'); ``` -------------------------------- ### Apple Configuration Example Source: https://github.com/chiiya/laravel-passes/blob/master/_autodocs/configuration.md Example configuration for Apple Wallet pass creation. Ensure certificate, WWDR, and password paths are correctly set. The disk and temp_dir can be customized for storage and temporary file handling. ```php 'apple' => [ 'certificate' => storage_path('app/credentials/pass_certificate.p12'), 'wwdr' => storage_path('app/credentials/AppleWWDRCA.pem'), 'password' => env('PASSES_APPLE_PASSWORD'), 'disk' => env('MEDIA_DISK', 'public'), 'temp_dir' => storage_path('app/temp'), ] ``` -------------------------------- ### Fetch Offer Class using GET Source: https://github.com/chiiya/laravel-passes/blob/master/_autodocs/api-reference/GoogleClient.md Use the get() method to retrieve a resource from the Google Wallet API. This example demonstrates fetching an offer class by its ID. Ensure to handle potential RequestExceptions. ```php use Chiiya\LaravelPasses\Google\GoogleClient; public function fetchOfferClass(GoogleClient $client) { try { $response = $client->get('https://walletobjects.googleapis.com/walletobjects/v1/offerClass/CLASS_ID'); echo $response['id']; // Access decoded JSON } catch (\Illuminate\Http\Client\RequestException $e) { echo 'Failed to fetch offer class: ' . $e->getMessage(); } } ``` -------------------------------- ### Google Configuration Example Source: https://github.com/chiiya/laravel-passes/blob/master/_autodocs/configuration.md Example configuration for Google Wallet pass creation and API authentication. The credentials path must point to a valid service account JSON file. Origins can be specified for the Save to Wallet button. ```php 'google' => [ 'credentials' => env('PASSES_GOOGLE_CREDENTIALS'), 'origins' => [ env('PASSES_GOOGLE_ORIGINS', env('APP_URL')) ], ] ``` -------------------------------- ### Create Event Ticket Class Example Source: https://github.com/chiiya/laravel-passes/blob/master/_autodocs/api-reference/GoogleDomain.md Example of how to use the eventTicketClasses repository to create a new event pass definition. Requires an instance of PassBuilder. ```php use Chiiya\LaravelPasses\PassBuilder; public function createEventClass(PassBuilder $builder) { $repo = $builder->google()->eventTicketClasses(); $repo->create($eventTicketClass); } ``` -------------------------------- ### Dependency Injection Example Source: https://github.com/chiiya/laravel-passes/blob/master/_autodocs/README.md Demonstrates how to type-hint core components of the laravel-passes package in your class constructors for dependency injection. ```php public function __construct( PassBuilder $builder, AppleDomain $apple, GoogleDomain $google, GoogleClient $client, PassFactory $factory, ) {} ``` -------------------------------- ### Serving Apple Passes Source: https://github.com/chiiya/laravel-passes/blob/master/_autodocs/DOCUMENTATION_SUMMARY.txt Example of a controller method to serve Apple Wallet passes. ```php namespace App\Http\Controllers; use Chiiya\Passes\PassBuilder; use Illuminate\Http\Request; use Illuminate\Support\Facades\Storage; class PassController extends Controller { public function showApplePass(Request $request, string $filename) { $passBuilder = new PassBuilder(); $appleDomain = $passBuilder->apple(); $path = $appleDomain->location($filename); if (!$path) { abort(404); } return response()->file($path, [ 'Content-Type' => 'application/vnd.apple.pkpass', ]); } } ``` -------------------------------- ### Import Pass Types Source: https://github.com/chiiya/laravel-passes/blob/master/_autodocs/DOCUMENTATION_SUMMARY.txt Example of importing necessary types for working with passes. ```php use Chiiya\Passes\Apple\PassFactory; use Chiiya\Passes\Google\Client as GoogleClient; use Chiiya\Passes\Types\ServiceCredentials; use Chiiya\Passes\Types\JWT; use Illuminate\Contracts\HTTP\Client as HttpClientInterface; ``` -------------------------------- ### Testing: Mocking Storage Source: https://github.com/chiiya/laravel-passes/blob/master/_autodocs/DOCUMENTATION_SUMMARY.txt Example of mocking the storage mechanism for testing pass creation and retrieval. ```php use Mockery\MockInterface; use Chiiya\Passes\PassBuilder; $mockStorage = Mockery::mock( Illuminate\Contracts\Filesystem\Filesystem::class ); $mockStorage->shouldReceive('put')->andReturn(true); $mockStorage->shouldReceive('exists')->andReturn(false); $mockStorage->shouldReceive('path')->andReturn('/tmp/mocked/path.pkpass'); $passBuilder = new PassBuilder($mockStorage); $appleDomain = $passBuilder->apple(); // ... test pass creation and retrieval using the mocked storage ``` -------------------------------- ### Install Laravel Passes via Composer Source: https://github.com/chiiya/laravel-passes/blob/master/README.md Install the package using Composer. This command adds the package to your project's dependencies. ```bash composer require chiiya/laravel-passes ``` -------------------------------- ### Testing: Mocking API Client Source: https://github.com/chiiya/laravel-passes/blob/master/_autodocs/DOCUMENTATION_SUMMARY.txt Example of mocking the HTTP client for testing interactions with external APIs. ```php use Mockery\MockInterface; use Chiiya\Passes\Google\Client as GoogleClient; $mockHttpClient = Mockery::mock( Illuminate\Contracts\HTTP\Client::class ); $mockHttpClient->shouldReceive('post')->andReturn(['success' => true]); $googleClient = new GoogleClient( config('services.google'), // Assuming config is available $mockHttpClient ); // ... test methods that use $googleClient->post() ``` -------------------------------- ### Google Client GET Request Source: https://github.com/chiiya/laravel-passes/blob/master/_autodocs/DOCUMENTATION_SUMMARY.txt Perform a GET request using the `GoogleClient`. Useful for retrieving data from Google APIs. ```php use Chiiya\Passes\Google\GoogleClient; $client = new GoogleClient(...); $response = $client->get('some/api/endpoint'); // $response contains the result of the GET request ``` -------------------------------- ### Get Offer Class Repository Source: https://github.com/chiiya/laravel-passes/blob/master/_autodocs/api-reference/GoogleDomain.md Retrieves the repository for managing Offer pass definitions. This repository is lazily instantiated. ```php public function offerClasses(): OfferClassRepository ``` -------------------------------- ### Create Offer Class using POST Source: https://github.com/chiiya/laravel-passes/blob/master/_autodocs/api-reference/GoogleClient.md Use the post() method to create a resource in the Google Wallet API. This example shows how to create an offer class by sending an OfferClass object. The data must implement JsonSerializable. ```php use Chiiya\ LaravelPasses\Google\GoogleClient; public function createOffer(GoogleClient $client, OfferClass $offer) { try { $response = $client->post( 'https://walletobjects.googleapis.com/walletobjects/v1/offerClass', $offer ); echo 'Created with ID: ' . $response['id']; } catch (\Illuminate\Http\Client\RequestException $e) { echo 'Failed to create offer: ' . $e->getMessage(); } } ``` -------------------------------- ### Pass Metadata Tracking Source: https://github.com/chiiya/laravel-passes/blob/master/_autodocs/DOCUMENTATION_SUMMARY.txt Example of tracking pass metadata in a database. ```php namespace App\Models; use Illuminate\Database\Eloquent\Model; class PassMetadata extends Model { protected $fillable = [ 'pass_id', // Foreign key to your pass model 'key', 'value', ]; // ... } ``` -------------------------------- ### Download Apple Pass File Source: https://github.com/chiiya/laravel-passes/blob/master/_autodocs/quick-reference.md Download an Apple Wallet pass file from storage. This example uses the `Storage` facade to retrieve the file and return it as a download response. ```php use Illuminate\Support\Facades\Storage; $path = $builder->apple()->location('passes/ticket-001'); return Storage::disk('public')->download($path, 'pass.pkpass'); ``` -------------------------------- ### Get Offer Object Repository Source: https://github.com/chiiya/laravel-passes/blob/master/_autodocs/api-reference/GoogleDomain.md Retrieves the repository for managing Offer pass instances. This repository is lazily instantiated. ```php public function offerObjects(): OfferObjectRepository ``` -------------------------------- ### Get Configured HTTP Client Source: https://github.com/chiiya/laravel-passes/blob/master/_autodocs/api-reference/GoogleClient.md Retrieves the base HTTP client instance configured with authentication middleware. This client is ready for chaining additional configurations. ```php protected function getClient(): PendingRequest ``` -------------------------------- ### Error Handling: Try-Catch Example Source: https://github.com/chiiya/laravel-passes/blob/master/_autodocs/DOCUMENTATION_SUMMARY.txt Basic try-catch block for handling potential exceptions during pass operations. ```php use Chiiya\Passes\PassBuilder; try { $passBuilder = new PassBuilder(); $appleDomain = $passBuilder->apple(); $appleDomain->create(new Chiiya\Passes\Apple\Pass(...)); } catch ( Exception $e ) { // Handle the exception report($e); } ``` -------------------------------- ### Checking HTTP Client Faking State Source: https://github.com/chiiya/laravel-passes/blob/master/_autodocs/api-reference/LaravelPassesServiceProvider.md This example demonstrates how to use the `isFaking()` macro to check if the HTTP client is in fake mode, typically used in testing scenarios. ```php use Illuminate\Support\Facades\Http; if (Http::isFaking()) { // Running in test mode } ``` -------------------------------- ### get() Source: https://github.com/chiiya/laravel-passes/blob/master/_autodocs/api-reference/GoogleClient.md Retrieves a resource from the Google Wallet API. It automatically adds standard headers, applies Google authentication in production, throws on HTTP errors, and returns decoded JSON. ```APIDOC ## get() ### Description Retrieve a resource from the Google Wallet API. ### Method GET ### Endpoint [Absolute or relative API endpoint URL] ### Parameters #### Path Parameters - **url** (string) - Required - Absolute or relative API endpoint URL ### Request Example ```php use Chiiya\LaravelPasses\Google\GoogleClient; public function fetchOfferClass(GoogleClient $client) { try { $response = $client->get('https://walletobjects.googleapis.com/walletobjects/v1/offerClass/CLASS_ID'); echo $response['id']; // Access decoded JSON } catch (\Illuminate\Http\Client\RequestException $e) { echo 'Failed to fetch offer class: ' . $e->getMessage(); } } ``` ### Response #### Success Response (200) - **array** - JSON-decoded response data. #### Response Example ```json { "example": "response body" } ``` ### Throws `Illuminate\Http\Client\RequestException` — If the HTTP response indicates an error (4xx or 5xx status). ``` -------------------------------- ### Laravel Passes Service Provider Configuration Source: https://github.com/chiiya/laravel-passes/blob/master/_autodocs/DOCUMENTATION_SUMMARY.txt Example of how the `LaravelPassesServiceProvider` might be configured within a Laravel application. ```php namespace App\Providers; use Chiiya\Passes\PassesServiceProvider; class AppServiceProvider extends PassesServiceProvider { public function configurePackage(Package $package): void { /* * More info: https://github.com/spatie/laravel-package-tools */ $package ->name('laravel-passes') // ->hasConfigFile() // ->hasViews() // ->hasTranslations() // ->hasCommand(InstallCommand::class); } } ``` -------------------------------- ### Get Loyalty Class Repository Source: https://github.com/chiiya/laravel-passes/blob/master/_autodocs/api-reference/GoogleDomain.md Retrieves the repository for managing Loyalty program pass definitions. This repository is lazily instantiated. ```php public function loyaltyClasses(): LoyaltyClassRepository ``` -------------------------------- ### Get Loyalty Object Repository Source: https://github.com/chiiya/laravel-passes/blob/master/_autodocs/api-reference/GoogleDomain.md Retrieves the repository for managing Loyalty program pass instances. This repository is lazily instantiated. ```php public function loyaltyObjects(): LoyaltyObjectRepository ``` -------------------------------- ### Service Container Type-Hinting Example Source: https://github.com/chiiya/laravel-passes/blob/master/_autodocs/api-reference/LaravelPassesServiceProvider.md This PHP code illustrates how to use type-hinting in a controller's constructor to inject services registered by the LaravelPassesServiceProvider, such as PassBuilder, PassFactory, and OfferClassRepository. ```php use Chiiya\LaravelPasses\PassBuilder; use Chiiya\Passes\Apple\PassFactory; use Chiiya\Passes\Google\Repositories\OfferClassRepository; class MyController { public function __construct( private PassBuilder $builder, private PassFactory $factory, private OfferClassRepository $offers, ) {} } ``` -------------------------------- ### Reusable Google Pass Service Factory Source: https://github.com/chiiya/laravel-passes/blob/master/_autodocs/usage-patterns.md This example demonstrates a reusable service factory for creating Google Pass objects and JWTs. It encapsulates the logic for building pass classes and signing JWTs with custom payloads. ```php use Chiiya\LaravelPasses\PassBuilder; class GooglePassFactory { public function __construct(private PassBuilder $builder) {} public function createOfferPass($offer) { $repo = $this->builder->google()->offerClasses(); $class = $this->buildOfferClass($offer); return $repo->create($class); } public function createJWTForOffer($object) { $jwt = $this->builder->google()->createJWT([ 'sub' => auth()->id(), ]); $jwt->addOfferObject($object); return $jwt->sign(); } private function buildOfferClass($offer) { // Build offer class object from model } } ``` -------------------------------- ### Core API Reference Files Source: https://github.com/chiiya/laravel-passes/blob/master/_autodocs/DOCUMENTATION_SUMMARY.txt The core API reference is divided into five markdown files, each documenting specific classes and their public methods. These files provide detailed information on method signatures, parameters, return types, error conditions, and code examples. ```APIDOC ## Core API Reference This section details the primary classes and their public methods available in the Laravel Passes package. ### api-reference/PassBuilder.md - Documents the `PassBuilder` class. - Covers 2 public methods. ### api-reference/AppleDomain.md - Documents the `AppleDomain` class. - Covers 3 public methods. ### api-reference/GoogleDomain.md - Documents the `GoogleDomain` class. - Covers 10 public methods, including repository accessors and JWT creation. ### api-reference/GoogleClient.md - Documents the `GoogleClient` class. - Covers 3 public methods and 2 protected methods. ### api-reference/LaravelPassesServiceProvider.md - Documents the `LaravelPassesServiceProvider` class. - Covers 3 public methods. **Each file includes:** - Full method signatures with parameter types - Parameter description tables - Return type documentation - Throws/Error conditions - Code examples - Source file references ``` -------------------------------- ### Update Offer Class using PUT Source: https://github.com/chiiya/laravel-passes/blob/master/_autodocs/api-reference/GoogleClient.md Use the put() method to update a resource in the Google Wallet API. This example demonstrates updating an existing offer class with new data. The data must implement JsonSerializable. ```php use Chiiya\ LaravelPasses\Google\GoogleClient; public function updateOffer(GoogleClient $client, OfferClass $offer) { try { $response = $client->put( 'https://walletobjects.googleapis.com/walletobjects/v1/offerClass/' . $offer->id, $offer ); echo 'Updated successfully'; } catch (\Illuminate\Http\Client\RequestException $e) { echo 'Failed to update offer: ' . $e->getMessage(); } } ``` -------------------------------- ### bootingPackage() Source: https://github.com/chiiya/laravel-passes/blob/master/_autodocs/api-reference/LaravelPassesServiceProvider.md Registers HTTP client macros and bootstraps the package, including the `isFaking()` macro. ```APIDOC ## bootingPackage() ### Description Registers HTTP client macros and bootstrap the package. ### Method `public function bootingPackage(): void` ### Macros Added - **isFaking()**: Checks if HTTP client is in fake mode. Returns `bool`. ### Usage ```php use Illuminate\Support\Facades\Http; if (Http::isFaking()) { // Running in test mode } ``` ``` -------------------------------- ### LaravelPassesServiceProvider bootingPackage Method Source: https://github.com/chiiya/laravel-passes/blob/master/_autodocs/api-reference/LaravelPassesServiceProvider.md This method registers HTTP client macros and bootstraps the package. It adds the `isFaking()` macro to check the HTTP client's faking state. ```php public function bootingPackage(): void ``` -------------------------------- ### Create Offer Classes and Objects Source: https://github.com/chiiya/laravel-passes/blob/master/_autodocs/usage-patterns.md This two-step pattern is used to first create an offer class definition and then create object instances based on that class. Ensure you have the necessary data for both the class and object. ```php use Chiiya\LaravelPasses\PassBuilder; public function createOffer(PassBuilder $builder, $offerData) { // Step 1: Create the class definition $classResponse = $builder->google()->offerClasses()->create( $this->buildOfferClass($offerData) ); $classId = $classResponse['id']; // Step 2: Create object instances $objectResponse = $builder->google()->offerObjects()->create( $this->buildOfferObject($classId, $offerData) ); $objectId = $objectResponse['id']; return [ 'class_id' => $classId, 'object_id' => $objectId, ]; } ``` -------------------------------- ### File Structure Overview Source: https://github.com/chiiya/laravel-passes/blob/master/_autodocs/modules.md Provides a breakdown of the package's file structure, including the 'src/' directory with core classes and the 'config/' directory for configuration files. ```text src/ ├── PassBuilder.php (24 lines) ├── LaravelPassesServiceProvider.php (37 lines) ├── Domains/ │ ├── AppleDomain.php (59 lines) │ └── GoogleDomain.php (188 lines) └── Google/ └── GoogleClient.php (79 lines) config/ └── passes.php (71 lines) **Total Package Code:** ~400 lines ``` -------------------------------- ### Basic Pass Creation with PassBuilder Source: https://github.com/chiiya/laravel-passes/blob/master/_autodocs/DOCUMENTATION_SUMMARY.txt Demonstrates the fundamental usage of the PassBuilder to create an Apple or Google pass instance. ```php use Chiiya\Passes\PassBuilder; $passBuilder = new PassBuilder(); $appleDomain = $passBuilder->apple(); $googleDomain = $passBuilder->google(); ``` -------------------------------- ### Optional Environment Variables for Configuration Source: https://github.com/chiiya/laravel-passes/blob/master/_autodocs/configuration.md Optional environment variables to customize storage disk and Google origins. These provide flexibility in deployment. ```bash # Storage disk (defaults to 'public') MEDIA_DISK=public # Google origins (defaults to APP_URL) PASSES_GOOGLE_ORIGINS=https://example.com APP_URL=https://example.com ``` -------------------------------- ### Lazy Loading and Caching of Repositories Source: https://github.com/chiiya/laravel-passes/blob/master/_autodocs/modules.md Demonstrates the lazy-loading and caching behavior of repositories. The first call instantiates the repository, while subsequent calls retrieve the cached instance. ```php $builder->google()->offerClasses() // First call: instantiated $builder->google()->offerClasses() // Second call: cached instance ``` -------------------------------- ### Get Apple Pass Location Source: https://github.com/chiiya/laravel-passes/blob/master/_autodocs/DOCUMENTATION_SUMMARY.txt Retrieve the file path of an existing Apple pass using the `location` method. ```php use Chiiya\Passes\PassBuilder; $passBuilder = new PassBuilder(); $appleDomain = $passBuilder->apple(); $location = $appleDomain->location('pass.pkpass'); if ($location) { // Pass found at $location } ``` -------------------------------- ### Create a Google Pass Source: https://github.com/chiiya/laravel-passes/blob/master/_autodocs/START_HERE.md Illustrates the process of creating a Google Wallet pass by first offering classes and then creating the pass itself. The response contains an 'id' for the class. ```php $repo = $this->builder->google()->offerClasses(); $response = $repo->create($offerClass); // Use response['id'] for the class ID ``` -------------------------------- ### Get Transit Object Repository Source: https://github.com/chiiya/laravel-passes/blob/master/_autodocs/api-reference/GoogleDomain.md Retrieves the repository for managing Transit pass instances. This repository is lazily instantiated. ```php public function transitObjects(): TransitObjectRepository ``` -------------------------------- ### Get Transit Class Repository Source: https://github.com/chiiya/laravel-passes/blob/master/_autodocs/api-reference/GoogleDomain.md Retrieves the repository for managing Transit pass definitions. This repository is lazily instantiated. ```php public function transitClasses(): TransitClassRepository ``` -------------------------------- ### Apple Pass Creation with Custom Path Source: https://github.com/chiiya/laravel-passes/blob/master/_autodocs/usage-patterns.md Shows how to specify a custom directory path when creating an Apple Wallet pass. ```php $path = $builder->apple()->create( $pass, 'events/summer-festival-2024' ); // Returns: 'events/summer-festival-2024.pkpass' ``` -------------------------------- ### Managing Apple Pass Files with Storage Source: https://github.com/chiiya/laravel-passes/blob/master/_autodocs/README.md Illustrates how to use Laravel's `Storage` facade to create, download, and delete Apple pass files after they have been generated by the PassBuilder. ```php use Illuminate\Support\Facades\Storage; $path = $builder->apple()->create($pass); Storage::disk('public')->download($path); Storage::disk('public')->delete($path); ``` -------------------------------- ### Accessing Configuration Values in Application Code Source: https://github.com/chiiya/laravel-passes/blob/master/_autodocs/configuration.md Demonstrates how to retrieve configuration values for both Apple and Google settings using Laravel's `config()` helper function. ```php use Illuminate\Support\Facades\Config; // Apple configuration $certificate = config('passes.apple.certificate'); $disk = config('passes.apple.disk'); // Google configuration $credentials = config('passes.google.credentials'); $origins = config('passes.google.origins'); ``` -------------------------------- ### Basic Apple Pass Creation Source: https://github.com/chiiya/laravel-passes/blob/master/_autodocs/usage-patterns.md Demonstrates the basic creation of an Apple Wallet pass object and its generation using the PassBuilder. ```php use Chiiya\LaravelPasses\PassBuilder; use Chiiya\Passes\Apple\Passes\Pass; public function createEventPass(PassBuilder $builder) { $pass = new Pass(serialNumber: 'EVENT-2024-001'); $pass->description = 'Summer Festival Ticket'; // Configure barcode, fields, style, etc. $path = $builder->apple()->create($pass); // Returns: 'EVENT-2024-001.pkpass' return $path; } ``` -------------------------------- ### Get Generic Object Repository Source: https://github.com/chiiya/laravel-passes/blob/master/_autodocs/api-reference/GoogleDomain.md Retrieves the repository for managing Generic pass instances. This repository is lazily instantiated. ```php public function genericObjects(): GenericObjectRepository ``` -------------------------------- ### Create a Google Offer Class Source: https://github.com/chiiya/laravel-passes/blob/master/_autodocs/quick-reference.md Create a new offer class for Google Wallet. This involves using the PassBuilder to access the Google domain and then the offerClasses repository to create the class. ```php public function createOffer(PassBuilder $builder) { $classes = $builder->google()->offerClasses(); $response = $classes->create($offerClass); // Returns API response with 'id' } ``` -------------------------------- ### Get Generic Class Repository Source: https://github.com/chiiya/laravel-passes/blob/master/_autodocs/api-reference/GoogleDomain.md Retrieves the repository for managing Generic pass definitions. This repository is lazily instantiated. ```php public function genericClasses(): GenericClassRepository ``` -------------------------------- ### Create an Apple Pass Source: https://github.com/chiiya/laravel-passes/blob/master/_autodocs/START_HERE.md Shows how to create a new Apple Wallet pass using the PassBuilder and the AppleDomain. It returns the file path of the generated .pkpass file. ```php use Chiiya\Passes\Apple\Passes\Pass; $pass = new Pass(serialNumber: 'TICKET-001'); $path = $this->builder->apple()->create($pass); // Returns: 'TICKET-001.pkpass' ``` -------------------------------- ### Get Flight Object Repository Source: https://github.com/chiiya/laravel-passes/blob/master/_autodocs/api-reference/GoogleDomain.md Retrieves the repository for managing Flight pass instances. This repository is lazily instantiated. ```php public function flightObjects(): FlightObjectRepository ``` -------------------------------- ### Get Flight Class Repository Source: https://github.com/chiiya/laravel-passes/blob/master/_autodocs/api-reference/GoogleDomain.md Retrieves the repository for managing Flight pass definitions. This repository is lazily instantiated. ```php public function flightClasses(): FlightClassRepository ``` -------------------------------- ### post() Source: https://github.com/chiiya/laravel-passes/blob/master/_autodocs/api-reference/GoogleClient.md Creates a resource in the Google Wallet API. It serializes the provided data, sends a POST request with a JSON body, applies Google authentication in production, throws on HTTP errors, and returns decoded JSON. ```APIDOC ## post() ### Description Create a resource in the Google Wallet API. ### Method POST ### Endpoint [Absolute or relative API endpoint URL] ### Parameters #### Path Parameters - **url** (string) - Required - Absolute or relative API endpoint URL - **data** (JsonSerializable) - Required - Object to create; must implement `JsonSerializable` ### Request Example ```php use Chiiya\LaravelPasses\Google\GoogleClient; public function createOffer(GoogleClient $client, OfferClass $offer) { try { $response = $client->post( 'https://walletobjects.googleapis.com/walletobjects/v1/offerClass', $offer ); echo 'Created with ID: ' . $response['id']; } catch (\Illuminate\Http\Client\RequestException $e) { echo 'Failed to create offer: ' . $e->getMessage(); } } ``` ### Response #### Success Response (200) - **array** - JSON-decoded response data from the API. #### Response Example ```json { "example": "response body" } ``` ### Throws `Illuminate\Http\Client\RequestException` — If the HTTP response indicates an error. ``` -------------------------------- ### Validate Configuration and Input Before Pass Creation Source: https://github.com/chiiya/laravel-passes/blob/master/_autodocs/usage-patterns.md This pattern emphasizes performing pre-flight checks, including validating necessary configurations (like Apple certificates and Google credentials) and input data, before attempting to create a pass. ```php public function createPass(PassBuilder $builder, $passData) { // Validate configuration if (!config('passes.apple.certificate')) { throw new Exception('Apple certificate not configured'); } if (!config('passes.google.credentials')) { throw new Exception('Google credentials not configured'); } // Validate input $validated = $this->validate($passData); // Create pass return $builder->apple()->create($validated['pass']); } ``` -------------------------------- ### configurePackage() Source: https://github.com/chiiya/laravel-passes/blob/master/_autodocs/api-reference/LaravelPassesServiceProvider.md Configures the package registration details, including setting the package name and enabling configuration file publication. ```APIDOC ## configurePackage() ### Description Configures the package registration details. ### Method `public function configurePackage(Package $package): void` ### Parameters #### Path Parameters - **package** (Spatie\LaravelPackageTools\Package) - Required - Package configuration object ### Behavior - Sets package name to `'laravel-passes'` - Enables configuration file publication with `hasConfigFile()` - Configuration file location: `config/passes.php` ``` -------------------------------- ### Get Gift Card Object Repository Source: https://github.com/chiiya/laravel-passes/blob/master/_autodocs/api-reference/GoogleDomain.md Retrieves the repository for managing Gift Card pass instances. This repository is lazily instantiated. ```php public function giftCardObjects(): GiftCardObjectRepository ``` -------------------------------- ### Get Gift Card Class Repository Source: https://github.com/chiiya/laravel-passes/blob/master/_autodocs/api-reference/GoogleDomain.md Retrieves the repository for managing Gift Card pass definitions. This repository is lazily instantiated. ```php public function giftCardClasses(): GiftCardClassRepository ``` -------------------------------- ### Complete Apple Pass Workflow Source: https://github.com/chiiya/laravel-passes/blob/master/_autodocs/quick-reference.md This workflow demonstrates the steps to create an Apple Pass object, configure its properties, generate the pass file, and retrieve its download URL. ```php use Chiiya\LaravelPasses\PassBuilder; use Chiiya\Passes\Apple\Passes\Pass; public function create(PassBuilder $builder) { // 1. Create pass object $pass = new Pass(serialNumber: 'TICKET-001'); // 2. Configure pass properties $pass->description = 'Event Ticket'; // 3. Create and store $path = $builder->apple()->create($pass, 'event-tickets/2024'); // 4. Return download URL return Storage::disk(config('passes.apple.disk')) ->url($path); } ``` -------------------------------- ### Get Event Ticket Object Repository Source: https://github.com/chiiya/laravel-passes/blob/master/_autodocs/api-reference/GoogleDomain.md Retrieves the repository for managing Event Ticket pass instances. This repository is lazily instantiated. ```php public function eventTicketObjects(): EventTicketObjectRepository ``` -------------------------------- ### Accessing Configuration Values Source: https://github.com/chiiya/laravel-passes/blob/master/_autodocs/README.md Shows how to retrieve configuration values related to Apple and Google Wallet settings using Laravel's `config` helper function. ```php config('passes.apple.certificate') config('passes.apple.disk') config('passes.google.credentials') config('passes.google.origins') ``` -------------------------------- ### Get Event Ticket Class Repository Source: https://github.com/chiiya/laravel-passes/blob/master/_autodocs/api-reference/GoogleDomain.md Retrieves the repository for managing Event Ticket pass definitions. This repository is lazily instantiated. ```php public function eventTicketClasses(): EventTicketClassRepository ``` -------------------------------- ### Get Apple Pass URL Source: https://github.com/chiiya/laravel-passes/blob/master/_autodocs/usage-patterns.md Retrieves the storage URL for an Apple Wallet pass based on its serial number. Returns null if the pass does not exist. ```php public function getPassUrl(PassBuilder $builder, string $serial) { $location = $builder->apple()->location($serial); if (!$location) { return null; // Pass doesn't exist } return Storage::disk(config('passes.apple.disk'))->url($location); } ``` -------------------------------- ### GoogleDomain Constructor Source: https://github.com/chiiya/laravel-passes/blob/master/_autodocs/api-reference/GoogleDomain.md Initializes the GoogleDomain with a GoogleClient for API interactions. The GoogleClient is automatically instantiated by the service provider. ```php public function __construct( protected GoogleClient $client, ) ``` -------------------------------- ### Get Apple Pass File Location Source: https://github.com/chiiya/laravel-passes/blob/master/_autodocs/quick-reference.md Retrieve the storage location of an Apple Wallet pass file. This is useful for generating URLs to access or download the pass. ```php $location = $builder->apple()->location('tickets/TICKET-001'); if ($location) { $url = Storage::disk('public')->url($location); } ``` -------------------------------- ### DI Pattern: GoogleClient Injection Source: https://github.com/chiiya/laravel-passes/blob/master/_autodocs/DOCUMENTATION_SUMMARY.txt Demonstrates injecting the GoogleClient into a class constructor. ```php use Chiiya\Passes\Google\Client as GoogleClient; class GooglePassUploader { protected GoogleClient $googleClient; public function __construct(GoogleClient $googleClient) { $this->googleClient = $googleClient; } public function uploadPass(array $data) { $this->googleClient->post('upload/pass', $data); } } ``` -------------------------------- ### DI Pattern: AppleDomain Injection Source: https://github.com/chiiya/laravel-passes/blob/master/_autodocs/DOCUMENTATION_SUMMARY.txt Demonstrates injecting the AppleDomain into a class constructor. ```php use Chiiya\Passes\Apple\Domain as AppleDomain; class ApplePassManager { protected AppleDomain $appleDomain; public function __construct(AppleDomain $appleDomain) { $this->appleDomain = $appleDomain; } public function checkPass(string $filename) { return $this->appleDomain->exists($filename); } } ``` -------------------------------- ### apple() Method Source: https://github.com/chiiya/laravel-passes/blob/master/_autodocs/DOCUMENTATION_SUMMARY.txt Returns an instance of AppleDomain, allowing for Apple pass operations. ```APIDOC ## apple() ### Description Returns an instance of AppleDomain, allowing for Apple pass operations. ### Method ``` public function apple(): AppleDomain ``` ### Returns An instance of `AppleDomain`. ``` -------------------------------- ### Get Apple Pass Storage Location Source: https://github.com/chiiya/laravel-passes/blob/master/_autodocs/api-reference/AppleDomain.md Retrieves the full storage path for a pass file. If the file does not exist, it returns null. The `.pkpass` extension is automatically appended if not provided. ```php use Chiiya\LaravelPasses\PassBuilder; public function getPassPath(PassBuilder $builder) { $fullPath = $builder->apple()->location('passes/boarding-pass-456'); if ($fullPath) { return Storage::disk('public')->url($fullPath); } return null; } ``` -------------------------------- ### Create JWT with Additional Payload Source: https://github.com/chiiya/laravel-passes/blob/master/_autodocs/usage-patterns.md This example demonstrates creating a JWT token with additional custom payload fields, such as 'sub' for subject and 'exp' for expiration time, alongside custom fields. ```php $jwt = $builder->google()->createJWT([ 'sub' => auth()->id(), 'exp' => now()->addHours(24)->timestamp, 'custom_field' => 'custom_value', ]); ``` -------------------------------- ### Serve Apple Pass Inline Source: https://github.com/chiiya/laravel-passes/blob/master/_autodocs/usage-patterns.md Returns an Apple Wallet pass file with the correct content type for inline display. Aborts with 404 if the pass is not found. ```php public function show(PassBuilder $builder, string $serial) { $location = $builder->apple()->location($serial); if (!$location) { abort(404); } return response()->file( Storage::disk(config('passes.apple.disk'))->path($location), ['Content-Type' => 'application/vnd.apple.pkpass'] ); } ``` -------------------------------- ### Get Google Domain Instance Source: https://github.com/chiiya/laravel-passes/blob/master/_autodocs/api-reference/PassBuilder.md Obtain the GoogleDomain instance from PassBuilder for Google Wallet pass creation and resource management. Use this when your operations are targeted towards the Google Wallet platform. ```php use Chiiya\LaravelPasses\PassBuilder; public function createGooglePass(PassBuilder $builder) { $googleDomain = $builder->google(); // Use $googleDomain for Google pass operations } ``` -------------------------------- ### Get Apple Domain Instance Source: https://github.com/chiiya/laravel-passes/blob/master/_autodocs/api-reference/PassBuilder.md Retrieve the AppleDomain instance from PassBuilder to perform Apple Wallet pass operations. This is useful when you need to specifically interact with Apple's pass creation functionalities. ```php use Chiiya\LaravelPasses\PassBuilder; public function createApplePass(PassBuilder $builder) { $appleDomain = $builder->apple(); // Use $appleDomain for Apple pass operations } ``` -------------------------------- ### Safe Apple Pass Creation with Try-Catch Source: https://github.com/chiiya/laravel-passes/blob/master/_autodocs/usage-patterns.md This pattern demonstrates how to safely create an Apple Pass using a try-catch block to handle potential exceptions during the creation process. It includes logging errors and returning a JSON error response. ```php use Chiiya\LaravelPasses\PassBuilder; public function createSafe(PassBuilder $builder) { try { $pass = new Pass(serialNumber: 'TICKET-001'); // Configure pass return $builder->apple()->create($pass); } catch (Exception $e) { // Log error Log::error('Apple pass creation failed: ' . $e->getMessage()); // Return error response return response()->json([ 'error' => 'Failed to create pass', 'details' => $e->getMessage(), ], 500); } } ``` -------------------------------- ### offerObjects() Source: https://github.com/chiiya/laravel-passes/blob/master/_autodocs/api-reference/GoogleDomain.md Retrieves the repository for managing Offer pass instances. This repository is lazily instantiated. ```APIDOC ## offerObjects() ### Description Get the Offer object repository for managing offer pass instances. ### Method GET ### Endpoint `/google/offerObjects` (Conceptual - actual access is via method call) ### Returns `Chiiya\Passes\Google\Repositories\OfferObjectRepository` - Repository instance (lazily instantiated). ``` -------------------------------- ### Get Google Pass Save URL from Model Source: https://github.com/chiiya/laravel-passes/blob/master/_autodocs/usage-patterns.md Implement a method to generate the Google Pay save URL for a pass. This involves creating a JWT with an offer object and signing it. Requires PassBuilder injection. ```php public function getGoogleSaveUrl(PassBuilder $builder) { if (!$this->google_object_id) { return null; } $jwt = $builder->google()->createJWT(); $jwt->addOfferObject($this->createGoogleObject()); return "https://pay.google.com/gp/v/save/{$jwt->sign()}"; } ``` -------------------------------- ### Mock Storage for Testing Source: https://github.com/chiiya/laravel-passes/blob/master/_autodocs/quick-reference.md Use `Storage::fake` to mock the filesystem during testing. This allows you to assert that storage operations, like creating or deleting files, are performed correctly without touching the actual disk. ```php Storage::fake(config('passes.apple.disk')); $path = $builder->apple()->create($pass); Storage::disk(config('passes.apple.disk'))->assertExists($path); ``` -------------------------------- ### Get Apple Pass URL from Model Source: https://github.com/chiiya/laravel-passes/blob/master/_autodocs/usage-patterns.md Add a method to your model to retrieve the URL for the Apple pass. This method checks if the pass path exists before generating the URL using the configured storage disk. ```php public function getApplePassUrl() { if (!$this->apple_pass_path) { return null; } return Storage::disk(config('passes.apple.disk')) ->url($this->apple_pass_path); } ``` -------------------------------- ### Dependency Injection of PassBuilder Source: https://github.com/chiiya/laravel-passes/blob/master/_autodocs/usage-patterns.md The recommended pattern for most use cases, providing a single consistent entry point to access both Apple and Google platforms. ```php use Chiiya\LaravelPasses\PassBuilder; class TicketController { public function __construct(private PassBuilder $builder) {} public function store() { $apple = $this->builder->apple(); $google = $this->builder->google(); // Use both platforms } } ``` -------------------------------- ### LaravelPassesServiceProvider configurePackage Method Source: https://github.com/chiiya/laravel-passes/blob/master/_autodocs/api-reference/LaravelPassesServiceProvider.md This method configures the package registration details, including the package name and enabling configuration file publication. ```php public function configurePackage(Package $package): void ``` -------------------------------- ### Environment Variables for Configuration Source: https://github.com/chiiya/laravel-passes/blob/master/_autodocs/quick-reference.md These environment variables are required for configuring the package to interact with Apple and Google services. Optional variables can also be set for media disk and application URL. ```bash # Required PASSES_APPLE_CERT=/path/to/cert.p12 PASSES_APPLE_WWDR=/path/to/wwdr.pem PASSES_APPLE_PASSWORD=password PASSES_GOOGLE_CREDENTIALS=/path/to/credentials.json # Optional MEDIA_DISK=public PASSES_GOOGLE_ORIGINS=https://example.com APP_URL=https://example.com ``` -------------------------------- ### Publish Configuration Files Source: https://github.com/chiiya/laravel-passes/blob/master/README.md Publish the package's configuration files to your Laravel application. This makes the configuration accessible for customization. ```bash php artisan vendor:publish --tag="passes-config" ``` -------------------------------- ### Inject and Use PassBuilder Source: https://github.com/chiiya/laravel-passes/blob/master/_autodocs/START_HERE.md Demonstrates how to inject and access the PassBuilder service in a Laravel controller to obtain instances for creating Apple and Google passes. ```php use Chiiya\LaravelPasses\PassBuilder; class MyController { public function __construct(private PassBuilder $builder) {} public function store() { // Apple $appleDomain = $this->builder->apple(); // Google $googleDomain = $this->builder->google(); } } ``` -------------------------------- ### Using Repositories and PassFactory in Laravel Source: https://github.com/chiiya/laravel-passes/blob/master/README.md Inject OfferClassRepository and PassFactory into your service or controller to create and manage Wallet Passes. This demonstrates direct usage of the underlying repositories. ```php public function __construct( private OfferClassRepository $offers, private PassFactory $apple, ) public function handle(): void { $this->apple->create(...); $this->offers->get(...); } ``` -------------------------------- ### Handle Apple Pass Creation Errors Source: https://github.com/chiiya/laravel-passes/blob/master/_autodocs/quick-reference.md Catch potential exceptions during Apple Pass creation. Common issues include invalid certificates, missing WWDR certificates, or insufficient write permissions for temporary directories. ```php try { $path = $builder->apple()->create($pass); } catch (\Exception $e) { // Could be: invalid cert, missing WWDR, temp dir not writable echo 'Pass creation failed: ' . $e->getMessage(); } ``` -------------------------------- ### offerClasses() Source: https://github.com/chiiya/laravel-passes/blob/master/_autodocs/api-reference/GoogleDomain.md Retrieves the repository for managing Offer pass definitions. This repository is lazily instantiated. ```APIDOC ## offerClasses() ### Description Get the Offer class repository for managing offer pass definitions. ### Method GET ### Endpoint `/google/offerClasses` (Conceptual - actual access is via method call) ### Returns `Chiiya\Passes\Google\Repositories\OfferClassRepository` - Repository instance (lazily instantiated). ``` -------------------------------- ### Apple Pass Configuration Source: https://github.com/chiiya/laravel-passes/blob/master/_autodocs/modules.md Shows how configuration values from 'config("passes.php")' are mapped to PassFactory properties for Apple passes. ```php config('passes.apple.temp_dir') → temp_dir config('passes.apple.temp_dir') → output config('passes.apple.certificate') → certificate config('passes.apple.password') → password config('passes.apple.wwdr') → wwdr ``` -------------------------------- ### PassBuilder::apple() Source: https://github.com/chiiya/laravel-passes/blob/master/_autodocs/api-reference/PassBuilder.md Retrieves the domain instance for creating Apple Wallet passes. ```APIDOC ## PassBuilder::apple() ### Description Returns the Apple domain instance for creating Apple Wallet passes. ### Method GET ### Endpoint PassBuilder::apple() ### Parameters None ### Response #### Success Response (200) - **appleDomain** (AppleDomain) - Instance for Apple Wallet pass operations. ### Response Example { "example": "AppleDomain instance" } ``` -------------------------------- ### PassBuilder::google() Source: https://github.com/chiiya/laravel-passes/blob/master/_autodocs/api-reference/PassBuilder.md Retrieves the domain instance for creating Google Wallet passes and managing resources. ```APIDOC ## PassBuilder::google() ### Description Returns the Google domain instance for creating Google Wallet passes and managing resources. ### Method GET ### Endpoint PassBuilder::google() ### Parameters None ### Response #### Success Response (200) - **googleDomain** (GoogleDomain) - Instance for Google Wallet pass operations. ### Response Example { "example": "GoogleDomain instance" } ``` -------------------------------- ### google() Method Source: https://github.com/chiiya/laravel-passes/blob/master/_autodocs/DOCUMENTATION_SUMMARY.txt Returns an instance of GoogleDomain, enabling Google pass operations. ```APIDOC ## google() ### Description Returns an instance of GoogleDomain, enabling Google pass operations. ### Method ``` public function google(): GoogleDomain ``` ### Returns An instance of `GoogleDomain`. ``` -------------------------------- ### Test Apple Pass Creation with Fake Storage Source: https://github.com/chiiya/laravel-passes/blob/master/_autodocs/usage-patterns.md Use `Storage::fake()` to mock the storage disk when testing Apple pass creation. This allows you to assert that the pass file was created without actually writing to disk. ```php use Illuminate\Support\Facades\Storage; public function testApplePassCreation() { Storage::fake(config('passes.apple.disk')); $this->app->make(PassBuilder::class) ->apple() ->create($pass, 'tickets/test'); Storage::disk(config('passes.apple.disk')) ->assertExists('tickets/test.pkpass'); } ``` -------------------------------- ### Create Google Offer Pass Source: https://github.com/chiiya/laravel-passes/blob/master/_autodocs/types.md Use the PassBuilder to interact with repositories for creating and updating Google Offer classes and objects for promotions. ```php public function createOffer(PassBuilder $builder) { $classes = $builder->google()->offerClasses(); $objects = $builder->google()->offerObjects(); } ``` -------------------------------- ### Required Environment Variables for Configuration Source: https://github.com/chiiya/laravel-passes/blob/master/_autodocs/configuration.md Essential environment variables for configuring Apple and Google passes. Ensure these are set in your .env file for proper operation. ```bash # Apple configuration PASSES_APPLE_CERT=/path/to/certificate.p12 PASSES_APPLE_WWDR=/path/to/wwdr.pem PASSES_APPLE_PASSWORD=certificate_password # Google configuration PASSES_GOOGLE_CREDENTIALS=/path/to/service-account.json ``` -------------------------------- ### Access Google Wallet Repositories Source: https://github.com/chiiya/laravel-passes/blob/master/_autodocs/quick-reference.md Provides a list of available repositories for Google Wallet objects and classes. Use these to interact with specific types of Google Wallet items. ```php // Any of these repository patterns $builder->google()->eventTicketClasses() $builder->google()->eventTicketObjects() $builder->google()->flightClasses() $builder->google()->flightObjects() $builder->google()->genericClasses() $builder->google()->genericObjects() $builder->google()->giftCardClasses() $builder->google()->giftCardObjects() $builder->google()->loyaltyClasses() $builder->google()->loyaltyObjects() $builder->google()->offerClasses() $builder->google()->offerObjects() $builder->google()->transitClasses() $builder->google()->transitObjects() ``` -------------------------------- ### Create and Sign JWT with Payload Source: https://github.com/chiiya/laravel-passes/blob/master/_autodocs/api-reference/GoogleDomain.md Demonstrates how to create a JWT with additional payload data, add an offer object, and sign the token using the PassBuilder. This is useful for authenticating with Google APIs or signing passes. ```php use Chiiya\LaravelPasses\PassBuilder; public function createSignedJWT(PassBuilder $builder) { $jwt = $builder->google()->createJWT(['sub' => 'user@example.com']); $jwt->addOfferObject($offerObject); $signedToken = $jwt->sign(); } ``` -------------------------------- ### getClient() Source: https://github.com/chiiya/laravel-passes/blob/master/_autodocs/api-reference/GoogleClient.md Retrieves the configured base HTTP client with authentication middleware applied. This client is ready for making authenticated requests to Google services. ```APIDOC ## getClient() ### Description Get the configured base HTTP client with authentication middleware. ### Method `protected` ### Signature ```php protected function getClient(): PendingRequest ``` ### Returns `Illuminate\Http\Client\PendingRequest` — Configured client ready for requests. ### Behavior - Sets standard JSON headers - If not faking HTTP calls: applies Google authentication middleware from service credentials - Returns a pending request ready to chain additional configuration ### Testing When `Http::fake()` is active, authentication middleware is skipped automatically. ``` -------------------------------- ### Inject PassBuilder (Recommended) Source: https://github.com/chiiya/laravel-passes/blob/master/_autodocs/quick-reference.md Inject the PassBuilder service into your controller for easy access to Apple and Google Wallet functionalities. This is the recommended approach for most use cases. ```php use Chiiya\LaravelPasses\PassBuilder; class MyController { public function __construct(private PassBuilder $builder) {} public function store() { $this->builder->apple()->create($pass); $this->builder->google()->offerClasses()->create($offerClass); } } ``` -------------------------------- ### Complete Google Pass Workflow Source: https://github.com/chiiya/laravel-passes/blob/master/_autodocs/quick-reference.md This workflow outlines the process for creating Google Offer Classes and Objects, generating a JWT for the 'Save to Wallet' button, and returning the necessary identifiers. ```php use Chiiya\LaravelPasses\PassBuilder; public function create(PassBuilder $builder) { // 1. Create offer class $response = $builder->google()->offerClasses()->create($offerClass); $classId = $response['id']; // 2. Create offer object $objectResponse = $builder->google()->offerObjects()->create($offerObject); // 3. Create JWT for Save to Wallet button $jwt = $builder->google()->createJWT(); $jwt->addOfferObject($offerObject); $token = $jwt->sign(); return ['class_id' => $classId, 'jwt' => $token]; } ```