mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-07 11:14:40 -04:00
Move google play listener in place
This commit is contained in:
parent
93a9e207ee
commit
d4943703c8
@ -59,8 +59,5 @@ class AppStoreRenewSubscription implements ShouldQueue
|
||||
|
||||
$account->save();
|
||||
|
||||
// $server_notification = $event->getServerNotification();
|
||||
// $subscription = $event->getSubscription();
|
||||
// $subscription_identifier = $event->getSubscriptionIdentifier();
|
||||
}
|
||||
}
|
||||
|
49
app/Listeners/Subscription/PlayStoreRenewSubscription.php
Normal file
49
app/Listeners/Subscription/PlayStoreRenewSubscription.php
Normal file
@ -0,0 +1,49 @@
|
||||
<?php
|
||||
/**
|
||||
* Invoice Ninja (https://invoiceninja.com).
|
||||
*
|
||||
* @link https://github.com/invoiceninja/invoiceninja source repository
|
||||
*
|
||||
* @copyright Copyright (c) 2023. Invoice Ninja LLC (https://invoiceninja.com)
|
||||
*
|
||||
* @license https://www.elastic.co/licensing/elastic-license
|
||||
*/
|
||||
|
||||
namespace App\Listeners\Subscription;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use App\Models\Account;
|
||||
use App\Models\Company;
|
||||
use App\Libraries\MultiDB;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use App\Notifications\Ninja\RenewalFailureNotification;
|
||||
use Imdhemy\Purchases\Events\GooglePlay\SubscriptionRenewed;
|
||||
|
||||
class PlayStoreRenewSubscription implements ShouldQueue
|
||||
{
|
||||
public function handle(SubscriptionRenewed $event)
|
||||
{
|
||||
$notification = $event->getServerNotification();
|
||||
nlog("google");
|
||||
nlog($notification);
|
||||
$in_app_identifier = $event->getSubscriptionIdentifier();
|
||||
|
||||
MultiDB::findAndSetDbByInappTransactionId($in_app_identifier);
|
||||
|
||||
$expirationTime = $event->getSubscription()->getExpiryTime();
|
||||
|
||||
$account = Account::where('inapp_transaction_id', $in_app_identifier)->first();
|
||||
|
||||
if ($account) {
|
||||
$account->update(['plan_expires' => Carbon::parse($expirationTime)]);
|
||||
}
|
||||
|
||||
if (!$account) {
|
||||
$ninja_company = Company::on('db-ninja-01')->find(config('ninja.ninja_default_company_id'));
|
||||
$ninja_company->notification(new RenewalFailureNotification("{$in_app_identifier}"))->ninja();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -23,7 +23,7 @@ class RenewalFailureNotification extends Notification
|
||||
* @return void
|
||||
*/
|
||||
|
||||
public function __construct(protected string $notification_message)
|
||||
public function __construct(protected ?string $notification_message)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -1,30 +1,31 @@
|
||||
<?php
|
||||
|
||||
use App\Listeners\Subscription\AppStoreRenewSubscription;
|
||||
use Imdhemy\Purchases\Events\AppStore\Cancel;
|
||||
use Imdhemy\Purchases\Events\AppStore\DidChangeRenewalPref;
|
||||
use Imdhemy\Purchases\Events\AppStore\DidChangeRenewalStatus;
|
||||
use Imdhemy\Purchases\Events\AppStore\DidFailToRenew;
|
||||
use Imdhemy\Purchases\Events\AppStore\DidRecover;
|
||||
use Imdhemy\Purchases\Events\AppStore\DidRenew;
|
||||
use Imdhemy\Purchases\Events\AppStore\InitialBuy;
|
||||
use Imdhemy\Purchases\Events\AppStore\InteractiveRenewal;
|
||||
use Imdhemy\Purchases\Events\AppStore\PriceIncreaseConsent;
|
||||
use Imdhemy\Purchases\Events\AppStore\Refund;
|
||||
use Imdhemy\Purchases\Events\AppStore\Revoke;
|
||||
use Imdhemy\Purchases\Events\GooglePlay\SubscriptionCanceled;
|
||||
use Imdhemy\Purchases\Events\GooglePlay\SubscriptionDeferred;
|
||||
use Imdhemy\Purchases\Events\GooglePlay\SubscriptionExpired;
|
||||
use Imdhemy\Purchases\Events\GooglePlay\SubscriptionInGracePeriod;
|
||||
use Imdhemy\Purchases\Events\AppStore\DidRenew;
|
||||
use Imdhemy\Purchases\Events\AppStore\DidRecover;
|
||||
use Imdhemy\Purchases\Events\AppStore\InitialBuy;
|
||||
use Imdhemy\Purchases\Events\AppStore\DidFailToRenew;
|
||||
use App\Listeners\Subscription\AppStoreRenewSubscription;
|
||||
use Imdhemy\Purchases\Events\AppStore\InteractiveRenewal;
|
||||
use App\Listeners\Subscription\PlayStoreRenewSubscription;
|
||||
use Imdhemy\Purchases\Events\AppStore\DidChangeRenewalPref;
|
||||
use Imdhemy\Purchases\Events\AppStore\PriceIncreaseConsent;
|
||||
use Imdhemy\Purchases\Events\GooglePlay\SubscriptionOnHold;
|
||||
use Imdhemy\Purchases\Events\GooglePlay\SubscriptionPaused;
|
||||
use Imdhemy\Purchases\Events\GooglePlay\SubscriptionPauseScheduleChanged;
|
||||
use Imdhemy\Purchases\Events\GooglePlay\SubscriptionPriceChangeConfirmed;
|
||||
use Imdhemy\Purchases\Events\GooglePlay\SubscriptionExpired;
|
||||
use Imdhemy\Purchases\Events\GooglePlay\SubscriptionRenewed;
|
||||
use Imdhemy\Purchases\Events\GooglePlay\SubscriptionRevoked;
|
||||
use Imdhemy\Purchases\Events\AppStore\DidChangeRenewalStatus;
|
||||
use Imdhemy\Purchases\Events\GooglePlay\SubscriptionCanceled;
|
||||
use Imdhemy\Purchases\Events\GooglePlay\SubscriptionDeferred;
|
||||
use Imdhemy\Purchases\Events\GooglePlay\SubscriptionPurchased;
|
||||
use Imdhemy\Purchases\Events\GooglePlay\SubscriptionRecovered;
|
||||
use Imdhemy\Purchases\Events\GooglePlay\SubscriptionRenewed;
|
||||
use Imdhemy\Purchases\Events\GooglePlay\SubscriptionRestarted;
|
||||
use Imdhemy\Purchases\Events\GooglePlay\SubscriptionRevoked;
|
||||
use Imdhemy\Purchases\Events\GooglePlay\SubscriptionInGracePeriod;
|
||||
use Imdhemy\Purchases\Events\GooglePlay\SubscriptionPauseScheduleChanged;
|
||||
use Imdhemy\Purchases\Events\GooglePlay\SubscriptionPriceChangeConfirmed;
|
||||
|
||||
return [
|
||||
'routing' => [],
|
||||
@ -40,7 +41,7 @@ return [
|
||||
* --------------------------------------------------------
|
||||
*/
|
||||
SubscriptionPurchased::class => [],
|
||||
SubscriptionRenewed::class => [],
|
||||
SubscriptionRenewed::class => [PlayStoreRenewSubscription::class],
|
||||
SubscriptionInGracePeriod::class => [],
|
||||
SubscriptionExpired::class => [],
|
||||
SubscriptionCanceled::class => [],
|
||||
|
Loading…
x
Reference in New Issue
Block a user