LegacyDeprecated
Sources
PayMongo no longer supports the Sources workflow, and the package marks it deprecated; it is here only to compare against what replaced it. A source took a GCash or GrabPay amount and returned a checkout URL where the customer authorised it. Once authorised the source became chargeable, announced by the source.chargeable webhook, and your application then had to create a payment from it itself, which the package does with payments()->create(). Payment intents replace this: attach an e-wallet payment method to an intent, and PayMongo creates the payment for you.
Deprecated by PayMongo. This API is shown only for comparison: do not build new integrations on it. Use Payment intents instead.
Every demonstration here makes a real PayMongo API call in test mode. Nothing is simulated, and no real money moves.
Create source
Create a GCash source for an amount. Open the checkout URL in the summary to see the authorisation page PayMongo hosts.
Test mode: Authorising the source on its checkout URL only makes it chargeable; the Charge source Step takes the money. PayMongo documents the workflow as no longer supported, so your account may reject a new source; its error shows here if so.
use Luigel\Paymongo\Facades\Paymongo;
$source = Paymongo::sources()->create(
attributes: [
'type' => 'gcash',
'amount' => 10000,
'currency' => 'PHP',
'redirect' => [
'success' => 'https://paymongo.rigelkentcarbonel.com/playground/scenarios/sources',
'failed' => 'https://paymongo.rigelkentcarbonel.com/playground/scenarios/sources',
],
],
);
Retrieve source
Fetch a source created in the Playground to see whether it is pending, chargeable, expired, or paid.
use Luigel\Paymongo\Facades\Paymongo;
$source = Paymongo::sources()->retrieve(
id: '{source id}',
);
Charge source
Create a payment from a chargeable source, the step your application had to take itself. The amount should match the source's.
Test mode: A source can be charged only once it is chargeable: authorise it on its checkout URL first. PayMongo rejects a pending, expired, or already-paid source, and its error shows here.
use Luigel\Paymongo\Facades\Paymongo;
$payment = Paymongo::payments()->create(
attributes: [
'amount' => 10000,
'currency' => 'PHP',
'source' => [
'type' => 'source',
'id' => '{source id}',
],
'description' => 'Laravel PayMongo Playground source charge',
],
);