Pull the package in with Composer:
composer require spatie/laravel-mobile-pass
##Getting credentials from Apple and Google
Each platform wants its own credentials before you can issue passes. Follow the walkthrough for whichever platforms you plan to support:
Each guide walks you through what to register, which keys to download, and the environment variables to set.
##Publishing the config file
You can publish the laravel-mobile-pass config if you want to tweak it:
php artisan vendor:publish --tag="mobile-pass-config"
Here's what the published file looks like:
return [
'apple' => [
'organization_name' => env('MOBILE_PASS_APPLE_ORGANIZATION_NAME'),
'type_identifier' => env('MOBILE_PASS_APPLE_TYPE_IDENTIFIER'),
'team_identifier' => env('MOBILE_PASS_APPLE_TEAM_IDENTIFIER'),
'certificate' => env('MOBILE_PASS_APPLE_CERTIFICATE'),
'certificate_path' => env('MOBILE_PASS_APPLE_CERTIFICATE_PATH'),
'certificate_password' => env('MOBILE_PASS_APPLE_CERTIFICATE_PASSWORD'),
'apple_push_base_url' => 'https://api.push.apple.com/3/device',
'webservice' => [
'secret' => env('MOBILE_PASS_APPLE_WEBSERVICE_SECRET'),
'host' => env('MOBILE_PASS_APPLE_WEBSERVICE_HOST'),
],
],
'google' => [
'issuer_id' => env('MOBILE_PASS_GOOGLE_ISSUER_ID'),
'service_account_key' => env('MOBILE_PASS_GOOGLE_KEY'),
'service_account_key_path' => env('MOBILE_PASS_GOOGLE_KEY_PATH'),
'origins' => [env('APP_URL')],
'api_base_url' => env(
'MOBILE_PASS_GOOGLE_API_BASE_URL',
'https://walletobjects.googleapis.com/walletobjects/v1'
),
],
'actions' => [
'handle_google_callback' => Spatie\LaravelMobilePass\Actions\Google\HandleGoogleCallbackAction::class,
'notify_apple_of_pass_update' => Spatie\LaravelMobilePass\Actions\Apple\NotifyAppleOfPassUpdateAction::class,
'notify_google_of_pass_update' => Spatie\LaravelMobilePass\Actions\Google\NotifyGoogleOfPassUpdateAction::class,
'register_device' => Spatie\LaravelMobilePass\Actions\Apple\RegisterDeviceAction::class,
'unregister_device' => Spatie\LaravelMobilePass\Actions\Apple\UnregisterDeviceAction::class,
],
'models' => [
'mobile_pass' => Spatie\LaravelMobilePass\Models\MobilePass::class,
'apple_mobile_pass_registration' => Spatie\LaravelMobilePass\Models\Apple\AppleMobilePassRegistration::class,
'apple_mobile_pass_device' => Spatie\LaravelMobilePass\Models\Apple\AppleMobilePassDevice::class,
'google_mobile_pass_event' => Spatie\LaravelMobilePass\Models\Google\GoogleMobilePassEvent::class,
],
'builders' => [
'apple' => [
],
'google' => [
],
],
'queue' => [
'connection' => env('MOBILE_PASS_QUEUE_CONNECTION'),
'name' => env('MOBILE_PASS_QUEUE_NAME', 'default'),
],
];
##Migrating the database
The package keeps track of generated passes, Apple device registrations, and Google save/remove events in your database. Publish and run the included migration:
php artisan vendor:publish --tag="mobile-pass-migrations"
php artisan migrate
The published create_mobile_pass_tables migration creates four tables: mobile_passes, apple_mobile_pass_devices, apple_mobile_pass_registrations, and mobile_pass_google_events.
##Registering the routes
Apple needs to reach your app to register devices and log errors. To wire up the routes it calls into, drop the mobilePass macro into your routes file:
Route::mobilePass();