Subscriptions

Plans

A plan is what a subscription bills: an amount in integer centavos, and how often, as an interval and a count of intervals. One plan can be reused by many subscriptions. The package has no way to delete or archive a plan, so every plan created here stays on the account.

Read the Plans & Subscriptions docs

Every demonstration here makes a real PayMongo API call in test mode. Nothing is simulated, and no real money moves.

Create plan

Create a plan billed every interval. 29900 is ₱299.00.

Test mode: The interval is weekly, monthly, or yearly, and the interval count is 1 to 10: a count of 3 on a monthly plan bills quarterly. The amount is at least 100 centavos.

PHP
use Luigel\Paymongo\Facades\Paymongo;

$plan = Paymongo::plans()->create(
    attributes: [
        'name' => 'Playground Monthly',
        'description' => 'Laravel PayMongo Playground demo plan',
        'amount' => 29900,
        'currency' => 'PHP',
        'interval' => 'monthly',
        'interval_count' => 1,
    ],
);

Retrieve plan

Fetch a plan created in the Playground.

PHP
use Luigel\Paymongo\Facades\Paymongo;

$plan = Paymongo::plans()->retrieve(
    id: '{plan id}',
);

Update plan

Rename a plan or change its description or amount. Only the fields sent are changed.

Test mode: PayMongo's reference documents this endpoint as PUT, while the package sends PATCH. If PayMongo rejects the method, the error it returns is shown here as it came.

PHP
use Luigel\Paymongo\Facades\Paymongo;

$plan = Paymongo::plans()->update(
    id: '{plan id}',
    attributes: [
        'name' => 'Playground Monthly (renamed)',
    ],
);

List plans

Fetch one cursor page of plans.

Test mode: PayMongo lists every plan on the account. The Playground shows only the ones created through it.

PHP
use Luigel\Paymongo\Facades\Paymongo;

$plan = Paymongo::plans()->list(
    params: [
        'limit' => 20,
    ],
);