Links

Classic Links

Classic Links are PayMongo's original Links API, reached through the package's links() service. A link is a shareable page for one fixed amount; its status tracks payment (unpaid, then paid) and it can be archived so it no longer accepts payments. Requests use the standard data.attributes envelope. Payment Links, beside it under Links, is the newer API for the same job; both are supported by the package.

Read the Classic Links docs

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

Create link

Create a link for a fixed amount. Open its checkout URL in the summary to see the page PayMongo hosts, and note its reference number for the lookup Step.

PHP
use Luigel\Paymongo\Facades\Paymongo;

$link = Paymongo::links()->create(
    attributes: [
        'amount' => 10000,
        'description' => 'Laravel PayMongo Playground demo link',
        'remarks' => 'Created from the Laravel PayMongo Playground',
    ],
);

Retrieve link

Fetch a link to see whether it has been paid, and any payments made through it.

PHP
use Luigel\Paymongo\Facades\Paymongo;

$link = Paymongo::links()->retrieve(
    id: '{link id}',
);

Retrieve link by reference number

Find a link by the short reference number in its checkout URL. The package returns null when none matches.

Test mode: Only links created in the Playground are shown. A reference number belonging to any other link on the account reads as no match.

PHP
use Luigel\Paymongo\Facades\Paymongo;

$link = Paymongo::links()->retrieveByReference(
    referenceNumber: '',
);

List links

Fetch one cursor page of links.

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

PHP
use Luigel\Paymongo\Facades\Paymongo;

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

Archive link

Stop a link from accepting payments without deleting it.

PHP
use Luigel\Paymongo\Facades\Paymongo;

$link = Paymongo::links()->archive(
    id: '{link id}',
);

Unarchive link

Let an archived link accept payments again.

PHP
use Luigel\Paymongo\Facades\Paymongo;

$link = Paymongo::links()->unarchive(
    id: '{link id}',
);