<?php
namespace App\Billing\Gateways;
use Pixelworxio\Subscribd\Contracts\Billable;
use Pixelworxio\Subscribd\Contracts\Gateway;
use Pixelworxio\Subscribd\Models\Invoice;
use Pixelworxio\Subscribd\Models\Plan;
use Pixelworxio\Subscribd\Models\Subscription;
use Pixelworxio\Subscribd\Enums\CheckoutMode;
class MyGateway implements Gateway
{
public function createSubscription(Billable $billable, Plan $plan, array $options = []): Subscription
{
// Create the subscription at your payment provider
// Return the local Subscription model
}
public function cancelSubscription(Subscription $subscription, bool $immediately = false): Subscription
{
// Cancel at the provider
// Return the updated Subscription model
}
public function updateSubscription(Subscription $subscription, array $options = []): Subscription
{
// Update quantity, plan, or other attributes
}
public function createInvoice(Billable $billable, array $lineItems, array $options = []): Invoice
{
// Create a one-off invoice
}
public function retryInvoice(Invoice $invoice): Invoice
{
// Retry a failed invoice
}
public function createCustomer(Billable $billable, array $options = []): string
{
// Create a customer record at the provider
// Return the provider's customer ID string
}
public function checkoutMode(): CheckoutMode
{
// Return CheckoutMode::Hosted, CheckoutMode::Embedded, or CheckoutMode::Overlay
return CheckoutMode::Hosted;
}
public function createHostedCheckoutSession(Billable $billable, Plan $plan, array $options = []): string
{
// Return the URL the user should be redirected to for checkout
}
public function supportsNativeProration(): bool
{
return false;
}
public function supportsTrialExtension(): bool
{
return false;
}
public function supportsPause(): bool
{
return false;
}
}