Links
Payment Links
Payment Links is PayMongo's newer Links API, reached through the package's paymentLinks() service. Requests and responses are flat, with no data.attributes envelope, and its status is a management state, active or archived, rather than a payment state: the payments collected are listed separately. Classic Links, beside it under Links, is the original API for the same job; both are supported by the package.
Every demonstration here makes a real PayMongo API call in test mode. Nothing is simulated, and no real money moves.
Create payment link
Create a payment link for a fixed amount. Open its URL in the summary to see the page PayMongo hosts.
Test mode: PayMongo requires an amount of at least 100 centavos, and an uppercase currency code.
use Luigel\Paymongo\Facades\Paymongo;
$paymentLink = Paymongo::paymentLinks()->create(
attributes: [
'amount' => 10000,
'currency' => 'PHP',
'description' => 'Laravel PayMongo Playground demo payment link',
'remarks' => 'Created from the Laravel PayMongo Playground',
],
);
Retrieve payment link
Fetch a payment link to see its status, URL, and completed-session restriction.
use Luigel\Paymongo\Facades\Paymongo;
$paymentLink = Paymongo::paymentLinks()->retrieve(
id: '{payment_link id}',
);
Update payment link
Change a payment link's description or remarks. Only the fields sent are changed.
use Luigel\Paymongo\Facades\Paymongo;
$paymentLink = Paymongo::paymentLinks()->update(
id: '{payment_link id}',
attributes: [
'description' => 'Updated from the Laravel PayMongo Playground',
'remarks' => 'Updated from the Laravel PayMongo Playground',
],
);
Archive payment link
Stop a payment link from accepting payments. The package sends an update that sets its status to archived.
Test mode: PayMongo's Update Payment Link reference documents an archive boolean rather than a status field. If PayMongo rejects the package's request, its error shows here.
use Luigel\Paymongo\Facades\Paymongo;
$paymentLink = Paymongo::paymentLinks()->archive(
id: '{payment_link id}',
);
Unarchive payment link
Let an archived payment link accept payments again. The package sets its status back to active.
use Luigel\Paymongo\Facades\Paymongo;
$paymentLink = Paymongo::paymentLinks()->unarchive(
id: '{payment_link id}',
);
List payment links
Fetch one cursor page of payment links.
Test mode: PayMongo lists every payment link on the account. The Playground shows only the ones created through it.
use Luigel\Paymongo\Facades\Paymongo;
$paymentLink = Paymongo::paymentLinks()->list(
params: [
'limit' => 20,
],
);
List the payments of a payment link
Fetch one cursor page of the payments collected through a payment link. They join the Playground's payments, so the Refunds scenario can refund them.
Test mode: A new payment link has no payments. Pay it on its URL with a test card first.
use Luigel\Paymongo\Facades\Paymongo;
$paymentLink = Paymongo::paymentLinks()->payments(
id: '{payment_link id}',
params: [
'limit' => 20,
],
);
Refund a payment link payment
Refund a payment collected through a payment link with PayMongo's payment link refund endpoint. The package returns a typed Refund, like the Refunds scenario.
Test mode: PayMongo documents this endpoint's amount in pesos, unlike every other amount, so the default 100 is PHP 100.00; the refund it returns is in centavos. Choose a payment of the chosen link.
use Luigel\Paymongo\Facades\Paymongo;
$paymentLink = Paymongo::paymentLinks()->refund(
id: '{payment_link id}',
attributes: [
'amount' => 100,
'reason' => 'requested_by_customer',
'payment_id' => '{payment id}',
],
);