Browse Source

Updated README

proxy_request
Daan Geurts 5 years ago
parent
commit
8996f5bd3b
  1. 2
      .travis.yml
  2. 80
      README.md

2
.travis.yml

@ -7,8 +7,6 @@ cache:
matrix: matrix:
fast_finish: true fast_finish: true
include: include:
- php: 7.1
env: LARAVEL='5.7.*' TESTBENCH='3.7.*' PHPENUM='1.*' PHPUNIT='7.*' COMPOSER_FLAGS='--prefer-stable'
- php: 7.2 - php: 7.2
env: LARAVEL='5.7.*' TESTBENCH='3.7.*' PHPENUM='1.*' PHPUNIT='7.*' COMPOSER_FLAGS='--prefer-stable' env: LARAVEL='5.7.*' TESTBENCH='3.7.*' PHPENUM='1.*' PHPUNIT='7.*' COMPOSER_FLAGS='--prefer-stable'
- php: 7.3 - php: 7.3

80
README.md

@ -1,10 +1,10 @@
# Handle Appstore server-to-server notifications for auto-renewable subscriptions # Handle Appstore server-to-server notifications for auto-renewable subscriptions
[![Latest Version on Packagist](https://img.shields.io/packagist/v/app-vise/laravel-appstore-notifications.svg?style=flat-square)](https://packagist.org/packages/app-vise/laravel-appstore-notifications) [![Latest Version on Packagist](https://img.shields.io/packagist/v/app-vise/app-vise/laravel-appstore-server-notifications.svg?style=flat-square)](https://packagist.org/packages/app-vise/laravel-appstore-server-notifications)
[![Build Status](https://travis-ci.org/app-vise/laravel-appstore-notifications.svg?branch=master)](https://travis-ci.org/app-vise/laravel-appstore-notifications) [![Build Status](https://travis-ci.org/app-vise/laravel-appstore-notifications.svg?branch=master)](https://travis-ci.org/app-vise/laravel-appstore-notifications)
[![StyleCI](https://styleci.io/repos/215539443/shield?branch=master)](https://styleci.io/repos/215539443) [![StyleCI](https://styleci.io/repos/215539443/shield?branch=master)](https://styleci.io/repos/215539443)
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/app-vise/laravel-appstore-notifications/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/app-vise/laravel-appstore-notifications/?branch=master) [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/app-vise/laravel-appstore-notifications/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/app-vise/laravel-appstore-notifications/?branch=master)
[![Total Downloads](https://img.shields.io/packagist/dt/app-vise/laravel-appstore-notifications.svg?style=flat-square)](https://packagist.org/packages/app-vise/laravel-appstore-notifications) [![Total Downloads](https://img.shields.io/packagist/dt/app-vise/laravel-appstore-server-notifications.svg?style=flat-square)](https://packagist.org/packages/app-vise/laravel-appstore-server-notifications)
## Installation ## Installation
You can install this package via composer You can install this package via composer
@ -19,8 +19,84 @@ You have to publish the config file with:
```bash ```bash
php artisan vendor:publish --provider="Appvise\AppStoreNotifications\NotificationsServiceProvider" --tag="config" php artisan vendor:publish --provider="Appvise\AppStoreNotifications\NotificationsServiceProvider" --tag="config"
``` ```
This is the config that will be published.
```php
return [
/*
* Apple will send the shared secret with the request that should match
* the one you use when validating receipts.
* https://developer.apple.com/documentation/storekit/in-app_purchase/enabling_server-to-server_notifications?language=objc#overview
*/
'shared_secret' => env('APPLE_SHARED_SECRET'),
/*
* All the events that should be handeled by your application.
* Typically you should uncomment all jobs
*
* You can find a list of all notification types here:
* https://developer.apple.com/documentation/storekit/in-app_purchase/enabling_server-to-server_notifications?language=objc#3162176
*/
'jobs' => [
// 'initial_buy' => \App\Jobs\AppstoreNotifications\HandleInitialBuy::class,
// 'cancel' => \App\Jobs\AppstoreNotifications\HandleCancellation::class,
// 'renewal' => \App\Jobs\AppstoreNotifications\HandleRenewal::class,
// 'interactive_renewal' => \App\Jobs\AppstoreNotifications\HandleInteractiveRenewal::class,
// 'did_change_renewal_pref' => \App\Jobs\AppstoreNotifications\HandleDidChangeRenewalPreferences::class,
// 'did_change_renewal_status' => \App\Jobs\AppstoreNotifications\HandleDidChangeRenewalStatus::class,
],
];
```
The shared secret should match the one you send to the store to validate receipts
This package logs all the incoming requests to the database so these steps are mandatory:
```bash
php artisan vendor:publish --provider="Appvise\AppStoreNotifications\NotificationsServiceProvider" --tag="migrations"
```
You should run migrate next to create the apple_notifications table:
```bash
php artisan migrate
```
This packages registers a POST route (/apple/server/notifications) to the Webhookscontroller of this package
## Usage ## Usage
When there is an change in one of the subscriptions Apple will send a POST request to a configured endpoint.
[Follow this guide to configure the endpoint:](https://help.apple.com/app-store-connect/#/dev0067a330b)
This package will send a 200 response if you configured the right Job for the right Notification Type otherwise it will send a 500 back to Apple.
Apple will retry a couple of times more. The incoming payload is stored in the apple_notifications table.
### Handling incoming notifications via Jobs
```php
<?php
namespace App\Jobs\AppstoreNotifications;
use App\Jobs\Job;
use Appvise\AppStoreNotifications\Model\NotificationPayload;
class HandleInitialBuy extends Job
{
public $payload;
public function __construct(NotificationPayload $payload)
{
$this->payload = $payload;
}
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
// Do something that matches your business logic with $this->payload
}
}
```
## Changelog ## Changelog

Loading…
Cancel
Save