Browse Source

Style fixes

proxy_request
Daan Geurts 5 years ago
parent
commit
f7b4123dde
  1. 8
      README.md
  2. 2
      composer.json
  3. 1
      config/appstore-server-notifications.php
  4. 1
      src/NotificationsServiceProvider.php
  5. 7
      src/WebhooksController.php
  6. 2
      src/model/AppleNotification.php
  7. 37
      src/model/NotificationPayload.php
  8. 59
      src/model/Receipt.php
  9. 23
      src/model/RenewalInfo.php
  10. 9
      tests/DummyJob.php
  11. 14
      tests/IntegrationTest.php

8
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/laravel-appstore-notifications.svg?style=flat-square)](https://packagist.org/packages/app-vise/laravel-appstore-notifications)
[![Build Status](https://img.shields.io/travis/app-vise/laravel-appstore-notifications/master.svg?style=flat-square)](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/105920179/shield?branch=master)](https://styleci.io/repos/105920179) [![StyleCI](https://styleci.io/repos/215539443/shield?branch=master)](https://styleci.io/repos/215539443)
[![Quality Score](https://img.shields.io/scrutinizer/g/app-vise/laravel-appstore-notifications.svg?style=flat-square)](https://scrutinizer-ci.com/g/app-vise/laravel-appstore-notifications) [![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/spatie/laravel-appstore-notifications) [![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)
## Installation ## Installation
You can install this package via composer You can install this package via composer

2
composer.json

@ -38,7 +38,7 @@
} }
}, },
"scripts": { "scripts": {
"test": "vendor/bin/phpunit --verbose" "test": "vendor/bin/phpunit"
}, },
"config": { "config": {
"sort-packages": true "sort-packages": true

1
config/appstore-server-notifications.php

@ -1,4 +1,5 @@
<?php <?php
return [ return [
/* /*
* Apple will send the shared secret with the request that should match * Apple will send the shared secret with the request that should match

1
src/NotificationsServiceProvider.php

@ -1,4 +1,5 @@
<?php <?php
namespace Appvise\AppStoreNotifications; namespace Appvise\AppStoreNotifications;
use Illuminate\Support\ServiceProvider; use Illuminate\Support\ServiceProvider;

7
src/WebhooksController.php

@ -2,11 +2,11 @@
namespace Appvise\AppStoreNotifications; namespace Appvise\AppStoreNotifications;
use Appvise\AppStoreNotifications\Exceptions\WebhookFailed; use Illuminate\Http\Request;
use Appvise\AppStoreNotifications\Model\NotificationType;
use Appvise\AppStoreNotifications\Model\AppleNotification; use Appvise\AppStoreNotifications\Model\AppleNotification;
use Appvise\AppStoreNotifications\Exceptions\WebhookFailed;
use Appvise\AppStoreNotifications\Model\NotificationPayload; use Appvise\AppStoreNotifications\Model\NotificationPayload;
use Appvise\AppStoreNotifications\Model\NotificationType;
use Illuminate\Http\Request;
class WebhooksController class WebhooksController
{ {
@ -25,7 +25,6 @@ class WebhooksController
throw WebhookFailed::jobClassDoesNotExist($jobConfigKey); throw WebhookFailed::jobClassDoesNotExist($jobConfigKey);
} }
$job = new $jobClass($payload); $job = new $jobClass($payload);
dispatch($job); dispatch($job);

2
src/model/AppleNotification.php

@ -8,7 +8,7 @@ class AppleNotification extends Model
{ {
public $guarded = []; public $guarded = [];
public static function storeNotification(String $notificationType, NotificationPayload $notificationPayload): AppleNotification public static function storeNotification(String $notificationType, NotificationPayload $notificationPayload)
{ {
return self::create([ return self::create([
'type' => $notificationType, 'type' => $notificationType,

37
src/model/NotificationPayload.php

@ -26,10 +26,9 @@ class NotificationPayload
public function __construct() public function __construct()
{ {
} }
static function createFromRequest(Request $request) public static function createFromRequest(Request $request)
{ {
$instance = new self(); $instance = new self();
$instance->environment = $request->input('environment'); $instance->environment = $request->input('environment');
@ -56,7 +55,7 @@ class NotificationPayload
} }
/** /**
* Get the value of environment * Get the value of environment.
*/ */
public function getEnvironment() public function getEnvironment()
{ {
@ -64,7 +63,7 @@ class NotificationPayload
} }
/** /**
* Get the value of notificationType * Get the value of notificationType.
*/ */
public function getNotificationType() public function getNotificationType()
{ {
@ -72,7 +71,7 @@ class NotificationPayload
} }
/** /**
* Get the value of pendingRenewalInfo * Get the value of pendingRenewalInfo.
*/ */
public function getPendingRenewalInfo() public function getPendingRenewalInfo()
{ {
@ -80,7 +79,7 @@ class NotificationPayload
} }
/** /**
* Get the value of autoRenewStatusChangeDateMs * Get the value of autoRenewStatusChangeDateMs.
*/ */
public function getAutoRenewStatusChangeDateMs() public function getAutoRenewStatusChangeDateMs()
{ {
@ -88,7 +87,7 @@ class NotificationPayload
} }
/** /**
* Get the value of autoRenewStatusChangeDatePst * Get the value of autoRenewStatusChangeDatePst.
*/ */
public function getAutoRenewStatusChangeDatePst() public function getAutoRenewStatusChangeDatePst()
{ {
@ -96,7 +95,7 @@ class NotificationPayload
} }
/** /**
* Get the value of autoRenewStatusChangeDate * Get the value of autoRenewStatusChangeDate.
*/ */
public function getAutoRenewStatusChangeDate() public function getAutoRenewStatusChangeDate()
{ {
@ -104,7 +103,7 @@ class NotificationPayload
} }
/** /**
* Get the value of autoRenewProductId * Get the value of autoRenewProductId.
*/ */
public function getAutoRenewProductId() public function getAutoRenewProductId()
{ {
@ -112,7 +111,7 @@ class NotificationPayload
} }
/** /**
* Get the value of autoRenewStatus * Get the value of autoRenewStatus.
*/ */
public function getAutoRenewStatus() public function getAutoRenewStatus()
{ {
@ -120,7 +119,7 @@ class NotificationPayload
} }
/** /**
* Get the value of latestExpiredReceiptInfo * Get the value of latestExpiredReceiptInfo.
*/ */
public function getLatestExpiredReceiptInfo() public function getLatestExpiredReceiptInfo()
{ {
@ -128,7 +127,7 @@ class NotificationPayload
} }
/** /**
* Get the value of latestExpiredReceipt * Get the value of latestExpiredReceipt.
*/ */
public function getLatestExpiredReceipt() public function getLatestExpiredReceipt()
{ {
@ -136,7 +135,7 @@ class NotificationPayload
} }
/** /**
* Get the value of latestReceiptInfo * Get the value of latestReceiptInfo.
*/ */
public function getLatestReceiptInfo() public function getLatestReceiptInfo()
{ {
@ -144,7 +143,7 @@ class NotificationPayload
} }
/** /**
* Get the value of latestReceipt * Get the value of latestReceipt.
*/ */
public function getLatestReceipt() public function getLatestReceipt()
{ {
@ -152,7 +151,7 @@ class NotificationPayload
} }
/** /**
* Get the value of webOrderLineItemId * Get the value of webOrderLineItemId.
*/ */
public function getWebOrderLineItemId() public function getWebOrderLineItemId()
{ {
@ -160,7 +159,7 @@ class NotificationPayload
} }
/** /**
* Get the value of cancellationDateMs * Get the value of cancellationDateMs.
*/ */
public function getCancellationDateMs() public function getCancellationDateMs()
{ {
@ -168,7 +167,7 @@ class NotificationPayload
} }
/** /**
* Get the value of cancellationDatePst * Get the value of cancellationDatePst.
*/ */
public function getCancellationDatePst() public function getCancellationDatePst()
{ {
@ -176,7 +175,7 @@ class NotificationPayload
} }
/** /**
* Get the value of cancellationDate * Get the value of cancellationDate.
*/ */
public function getCancellationDate() public function getCancellationDate()
{ {
@ -184,7 +183,7 @@ class NotificationPayload
} }
/** /**
* Get the value of password * Get the value of password.
*/ */
public function getPassword() public function getPassword()
{ {

59
src/model/Receipt.php

@ -40,7 +40,7 @@ class Receipt
} }
static function createFromArray(array $receiptInfo) public static function createFromArray(array $receiptInfo)
{ {
$instance = new self(); $instance = new self();
$instance->originalTransactionId = $receiptInfo['original_transaction_id'] ?? null; $instance->originalTransactionId = $receiptInfo['original_transaction_id'] ?? null;
@ -71,12 +71,13 @@ class Receipt
$instance->transactionId = $receiptInfo['transaction_id'] ?? null; $instance->transactionId = $receiptInfo['transaction_id'] ?? null;
$instance->bvrs = $receiptInfo['bvrs'] ?? null; $instance->bvrs = $receiptInfo['bvrs'] ?? null;
$instance->bid = $receiptInfo['bid'] ?? null; $instance->bid = $receiptInfo['bid'] ?? null;
return $instance; return $instance;
} }
/** /**
* Get the value of bid * Get the value of bid.
*/ */
public function getBid() public function getBid()
{ {
@ -84,7 +85,7 @@ class Receipt
} }
/** /**
* Get the value of bvrs * Get the value of bvrs.
*/ */
public function getBvrs() public function getBvrs()
{ {
@ -92,7 +93,7 @@ class Receipt
} }
/** /**
* Get the value of transactionId * Get the value of transactionId.
*/ */
public function getTransactionId() public function getTransactionId()
{ {
@ -100,7 +101,7 @@ class Receipt
} }
/** /**
* Get the value of versionExternalIdentifier * Get the value of versionExternalIdentifier.
*/ */
public function getVersionExternalIdentifier() public function getVersionExternalIdentifier()
{ {
@ -108,7 +109,7 @@ class Receipt
} }
/** /**
* Get the value of appItemId * Get the value of appItemId.
*/ */
public function getAppItemId() public function getAppItemId()
{ {
@ -116,7 +117,7 @@ class Receipt
} }
/** /**
* Get the value of itemId * Get the value of itemId.
*/ */
public function getItemId() public function getItemId()
{ {
@ -124,7 +125,7 @@ class Receipt
} }
/** /**
* Get the value of isTrialPeriod * Get the value of isTrialPeriod.
*/ */
public function getIsTrialPeriod() public function getIsTrialPeriod()
{ {
@ -132,7 +133,7 @@ class Receipt
} }
/** /**
* Get the value of isInIntroOfferPeriod * Get the value of isInIntroOfferPeriod.
*/ */
public function getIsInIntroOfferPeriod() public function getIsInIntroOfferPeriod()
{ {
@ -140,7 +141,7 @@ class Receipt
} }
/** /**
* Get the value of uniqueVendorIdentifier * Get the value of uniqueVendorIdentifier.
*/ */
public function getUniqueVendorIdentifier() public function getUniqueVendorIdentifier()
{ {
@ -148,7 +149,7 @@ class Receipt
} }
/** /**
* Get the value of uniqueIdentifier * Get the value of uniqueIdentifier.
*/ */
public function getUniqueIdentifier() public function getUniqueIdentifier()
{ {
@ -156,7 +157,7 @@ class Receipt
} }
/** /**
* Get the value of quantity * Get the value of quantity.
*/ */
public function getQuantity() public function getQuantity()
{ {
@ -164,7 +165,7 @@ class Receipt
} }
/** /**
* Get the value of expiresDateFormattedPst * Get the value of expiresDateFormattedPst.
*/ */
public function getExpiresDateFormattedPst() public function getExpiresDateFormattedPst()
{ {
@ -172,7 +173,7 @@ class Receipt
} }
/** /**
* Get the value of expiresDateFormatted * Get the value of expiresDateFormatted.
*/ */
public function getExpiresDateFormatted() public function getExpiresDateFormatted()
{ {
@ -180,7 +181,7 @@ class Receipt
} }
/** /**
* Get the value of expiresDateMs * Get the value of expiresDateMs.
*/ */
public function getExpiresDateMs() public function getExpiresDateMs()
{ {
@ -188,7 +189,7 @@ class Receipt
} }
/** /**
* Get the value of expiresDate * Get the value of expiresDate.
*/ */
public function getExpiresDate() public function getExpiresDate()
{ {
@ -196,7 +197,7 @@ class Receipt
} }
/** /**
* Get the value of cancellationDatePst * Get the value of cancellationDatePst.
*/ */
public function getCancellationDatePst() public function getCancellationDatePst()
{ {
@ -204,7 +205,7 @@ class Receipt
} }
/** /**
* Get the value of cancellationDateMs * Get the value of cancellationDateMs.
*/ */
public function getCancellationDateMs() public function getCancellationDateMs()
{ {
@ -212,7 +213,7 @@ class Receipt
} }
/** /**
* Get the value of cancellationDate * Get the value of cancellationDate.
*/ */
public function getCancellationDate() public function getCancellationDate()
{ {
@ -220,7 +221,7 @@ class Receipt
} }
/** /**
* Get the value of cancellationReason * Get the value of cancellationReason.
*/ */
public function getCancellationReason() public function getCancellationReason()
{ {
@ -228,7 +229,7 @@ class Receipt
} }
/** /**
* Get the value of originalPurchaseDatePst * Get the value of originalPurchaseDatePst.
*/ */
public function getOriginalPurchaseDatePst() public function getOriginalPurchaseDatePst()
{ {
@ -236,7 +237,7 @@ class Receipt
} }
/** /**
* Get the value of originalPurchaseDateMs * Get the value of originalPurchaseDateMs.
*/ */
public function getOriginalPurchaseDateMs() public function getOriginalPurchaseDateMs()
{ {
@ -244,7 +245,7 @@ class Receipt
} }
/** /**
* Get the value of originalPurchaseDate * Get the value of originalPurchaseDate.
*/ */
public function getOriginalPurchaseDate() public function getOriginalPurchaseDate()
{ {
@ -252,7 +253,7 @@ class Receipt
} }
/** /**
* Get the value of purchaseDatePst * Get the value of purchaseDatePst.
*/ */
public function getPurchaseDatePst() public function getPurchaseDatePst()
{ {
@ -260,7 +261,7 @@ class Receipt
} }
/** /**
* Get the value of purchaseDate * Get the value of purchaseDate.
*/ */
public function getPurchaseDate() public function getPurchaseDate()
{ {
@ -268,7 +269,7 @@ class Receipt
} }
/** /**
* Get the value of purchaseDateMs * Get the value of purchaseDateMs.
*/ */
public function getPurchaseDateMs() public function getPurchaseDateMs()
{ {
@ -276,7 +277,7 @@ class Receipt
} }
/** /**
* Get the value of productId * Get the value of productId.
*/ */
public function getProductId() public function getProductId()
{ {
@ -284,7 +285,7 @@ class Receipt
} }
/** /**
* Get the value of webOrderLineItemId * Get the value of webOrderLineItemId.
*/ */
public function getWebOrderLineItemId() public function getWebOrderLineItemId()
{ {
@ -292,7 +293,7 @@ class Receipt
} }
/** /**
* Get the value of originalTransactionId * Get the value of originalTransactionId.
*/ */
public function getOriginalTransactionId() public function getOriginalTransactionId()
{ {

23
src/model/RenewalInfo.php

@ -21,7 +21,8 @@ class RenewalInfo
{ {
} }
public static function createFromRequest(array $pendingRenewalInfo) { public static function createFromRequest(array $pendingRenewalInfo)
{
$instance = new self(); $instance = new self();
$instance->autoRenewProductId = $pendingRenewalInfo['auto_renew_product_id'] ?? null; $instance->autoRenewProductId = $pendingRenewalInfo['auto_renew_product_id'] ?? null;
$instance->autoRenewStatus = $pendingRenewalInfo['auto_renew_status'] ?? null; $instance->autoRenewStatus = $pendingRenewalInfo['auto_renew_status'] ?? null;
@ -35,7 +36,7 @@ class RenewalInfo
return $instance; return $instance;
} }
/** /**
* Get the value of autoRenewProductId * Get the value of autoRenewProductId.
*/ */
public function getAutoRenewProductId() public function getAutoRenewProductId()
{ {
@ -43,7 +44,7 @@ class RenewalInfo
} }
/** /**
* Get the value of autoRenewStatus * Get the value of autoRenewStatus.
*/ */
public function getAutoRenewStatus() public function getAutoRenewStatus()
{ {
@ -51,7 +52,7 @@ class RenewalInfo
} }
/** /**
* Get the value of expirationIntent * Get the value of expirationIntent.
*/ */
public function getExpirationIntent() public function getExpirationIntent()
{ {
@ -59,7 +60,7 @@ class RenewalInfo
} }
/** /**
* Get the value of originalTransactionId * Get the value of originalTransactionId.
*/ */
public function getOriginalTransactionId() public function getOriginalTransactionId()
{ {
@ -67,7 +68,7 @@ class RenewalInfo
} }
/** /**
* Get the value of isInBillingRetryPeriod * Get the value of isInBillingRetryPeriod.
*/ */
public function getIsInBillingRetryPeriod() public function getIsInBillingRetryPeriod()
{ {
@ -75,7 +76,7 @@ class RenewalInfo
} }
/** /**
* Get the value of productId * Get the value of productId.
*/ */
public function getProductId() public function getProductId()
{ {
@ -83,7 +84,7 @@ class RenewalInfo
} }
/** /**
* Get the value of priceConsentStatus * Get the value of priceConsentStatus.
*/ */
public function getPriceConsentStatus() public function getPriceConsentStatus()
{ {
@ -91,7 +92,7 @@ class RenewalInfo
} }
/** /**
* Get the value of gracePeriodExpiresDate * Get the value of gracePeriodExpiresDate.
*/ */
public function getGracePeriodExpiresDate() public function getGracePeriodExpiresDate()
{ {
@ -99,7 +100,7 @@ class RenewalInfo
} }
/** /**
* Get the value of gracePeriodExpiresDateMs * Get the value of gracePeriodExpiresDateMs.
*/ */
public function getGracePeriodExpiresDateMs() public function getGracePeriodExpiresDateMs()
{ {
@ -107,7 +108,7 @@ class RenewalInfo
} }
/** /**
* Get the value of gracePeriodExpiresDatePst * Get the value of gracePeriodExpiresDatePst.
*/ */
public function getGracePeriodExpiresDatePst() public function getGracePeriodExpiresDatePst()
{ {

9
tests/DummyJob.php

@ -2,13 +2,12 @@
namespace Appvise\AppStoreNotifications\Tests; namespace Appvise\AppStoreNotifications\Tests;
use Appvise\AppStoreNotifications\Model\NotificationPayload;
use Illuminate\Bus\Queueable; use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable; use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue; use Appvise\AppStoreNotifications\Model\NotificationPayload;
use Illuminate\Queue\SerializesModels;
class DummyJob implements ShouldQueue class DummyJob implements ShouldQueue
{ {
@ -21,7 +20,7 @@ class DummyJob implements ShouldQueue
$this->payload = $payload; $this->payload = $payload;
} }
function handle() public function handle()
{ {
} }
} }

14
tests/IntegrationTest.php

@ -2,9 +2,9 @@
namespace Appvise\AppStoreNotifications\Tests; namespace Appvise\AppStoreNotifications\Tests;
use Appvise\AppStoreNotifications\Model\AppleNotification;
use Illuminate\Support\Facades\Queue; use Illuminate\Support\Facades\Queue;
use Illuminate\Support\Facades\Route; use Illuminate\Support\Facades\Route;
use Appvise\AppStoreNotifications\Model\AppleNotification;
class IntegrationTest extends TestCase class IntegrationTest extends TestCase
{ {
@ -19,20 +19,18 @@ class IntegrationTest extends TestCase
config( config(
[ [
'appstore-server-notifications.jobs' => [ 'appstore-server-notifications.jobs' => [
'initial_buy' => DummyJob::class 'initial_buy' => DummyJob::class,
], ],
'appstore-server-notifications.shared_secret' => 'VALID_APPLE_PASSWORD', 'appstore-server-notifications.shared_secret' => 'VALID_APPLE_PASSWORD',
] ]
); );
} }
/** @test */ /** @test */
public function it_can_handle_a_valid_request() public function it_can_handle_a_valid_request()
{ {
$payload = include_once __DIR__ . '/__fixtures__/request.php'; $payload = include_once __DIR__.'/__fixtures__/request.php';
$payload['password'] = 'VALID_APPLE_PASSWORD';
$payload['password'] = "VALID_APPLE_PASSWORD";
$this $this
->postJson('/apple/server/notifications', $payload) ->postJson('/apple/server/notifications', $payload)
@ -51,8 +49,8 @@ class IntegrationTest extends TestCase
/** @test */ /** @test */
public function a_request_with_an_invalid_password_wont_be_logged() public function a_request_with_an_invalid_password_wont_be_logged()
{ {
$payload = include_once __DIR__ . '/__fixtures__/request.php'; $payload = include_once __DIR__.'/__fixtures__/request.php';
$payload['password'] = "NON_VALID_APPLE_PASSWORD"; $payload['password'] = 'NON_VALID_APPLE_PASSWORD';
$this $this
->postJson('/apple/server/notifications', $payload) ->postJson('/apple/server/notifications', $payload)

Loading…
Cancel
Save