1. Go to this page and download the library: Download cynchro/modux-billing library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
cynchro / modux-billing example snippets
use Cynchro\Billing\{Schema, PlanRepository, SubscriptionRepository,
TenantEntitlementWriter, BillingManager};
use Cynchro\Billing\Models\PlanEntitlement;
Schema::up($pdo); // crea plans, plan_entitlements, subscriptions
$plans = new PlanRepository($pdo);
$pro = $plans->create('pro', 'Pro', 29.0, 'USD', 'month', 'stripe');
$plans->addEntitlement($pro->id, new PlanEntitlement('ia.rag', 'flag'));
$plans->addEntitlement($pro->id, new PlanEntitlement('api.calls', 'quota', 1000));
$billing = new BillingManager(
$plans,
new SubscriptionRepository($pdo),
new TenantEntitlementWriter($pdo) // escribe tenant_entitlements del base
);
// Tras un checkout exitoso:
$billing->subscribe($tenantId, 'pro', 'stripe', $externalSubscriptionId);
// Desde un webhook de la pasarela (ya verificado con el WebhookVerifier del base):
$billing->handleEvent($gateway->parseWebhook($payload));
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.