HEX
Server: LiteSpeed
System: Linux s1049.use1.mysecurecloudhost.com 4.18.0-477.27.2.lve.el8.x86_64 #1 SMP Wed Oct 11 12:32:56 UTC 2023 x86_64
User: xedaptot (3356)
PHP: 8.3.31
Disabled: NONE
Upload Files
File: /home/xedaptot/be.naniguide.com/app/Model/InvoiceEmailVerificationCredits.php
<?php

namespace Acelle\Model;

use Acelle\Model\Invoice;
use Acelle\Model\Customer;

class InvoiceEmailVerificationCredits extends Invoice
{
    protected $table = 'invoices';

    public const TYPE_EMAIL_VERIFICATION_CREDITS = 'email_verification_credits';

    /**
     * Process invoice.
     *
     * @return void
     */
    public function process()
    {
        // @important BIG dependencies and assumption here
        // - Need explicit subscription_id
        $tracker = $this->customer->getCurrentActiveGeneralSubscription()->getVerifyEmailCreditTracker();

        if ($tracker->isUnlimited()) {
            // Right now, just do nothing
            // throw new \Exception('Cannot add more sending credits, already UNLIMITED');
        } else {
            $tracker->topup($this->email_verification_credits);
        }
    }

    /**
     * Get billing info.
     *
     * @return void
     */
    public function getBillingInfo()
    {
        $chargeInfo = trans('messages.bill.charge_now');

        return $this->getBillingInfoBase($chargeInfo);
    }

    public function refreshPrice()
    {
        if ($this->isPaid()) {
            throw new \Exception("Can not change paid invoice price!");
        }

        // do nothing
    }

    public function beforeCancel()
    {
    }

    public function checkoutAfterPayFailed($error)
    {
    }
}