File: /home/xedaptot/ai.naniguide.com/app/Providers/CheckoutServiceProvider.php
<?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use App\Library\BillingManager;
use App\Library\Facades\Billing;
use App\Cashier\Services\StripePaymentGateway;
use App\Cashier\Services\OfflinePaymentGateway;
use App\Cashier\Services\StripeSubscriptionGateway;
use App\Cashier\Contracts\CheckoutHandlerInterface;
use App\Cashier\Contracts\PaymentGatewayResolverInterface;
use App\Library\Checkout\CheckoutHandler;
use App\Library\Checkout\PaymentGatewayResolver;
use App\Model\PaymentGateway;
class CheckoutServiceProvider extends ServiceProvider
{
public function boot()
{
Billing::register(
OfflinePaymentGateway::TYPE,
trans('cashier::messages.offline'),
trans('cashier::messages.offline.description'),
fn (PaymentGateway $gw) => new OfflinePaymentGateway(
$gw->getGatewayData('payment_instruction'),
),
icon: 'account_balance',
formView: 'refactor.pages.admin.payment-gateways.form.offline',
);
Billing::register(
StripePaymentGateway::TYPE,
trans('cashier::messages.stripe'),
trans('cashier::messages.stripe.description'),
fn (PaymentGateway $gw) => new StripePaymentGateway(
$gw->getGatewayData('publishable_key'),
$gw->getGatewayData('secret_key'),
),
icon: 'credit_card',
formView: 'refactor.pages.admin.payment-gateways.form.stripe',
);
Billing::register(
StripeSubscriptionGateway::TYPE,
'Stripe Subscription',
'Manage subscriptions directly through Stripe\'s subscription billing.',
fn (PaymentGateway $gw) => new StripeSubscriptionGateway(
$gw->getGatewayData('publishable_key'),
$gw->getGatewayData('secret_key'),
$gw->getGatewayData('webhook_secret'),
),
icon: 'sync',
isRemoteSubscription: true,
formView: 'refactor.pages.admin.payment-gateways.form.stripe-subscription',
);
}
public function register()
{
$this->app->singleton(BillingManager::class, function ($app) {
return new BillingManager();
});
$this->app->bind(CheckoutHandlerInterface::class, CheckoutHandler::class);
$this->app->bind(PaymentGatewayResolverInterface::class, PaymentGatewayResolver::class);
}
}