Skip to main content

Payment Intents

Create Payment Intent#

A payment intent is designed to handle a complex payment process. To compare payment intents with tokens, tokens have a straight forward credit card payment process where it does not check if 3DS is required to fulfill a payment while payment intent is designed to handle such process.

Payload#

Refer to Paymongo documentation for payload guidelines.

Sample#

use Luigel\Paymongo\Facades\Paymongo;
$paymentIntent = Paymongo::paymentIntent()->create([    'amount' => 100,    'payment_method_allowed' => [        'card'    ],    'payment_method_options' => [        'card' => [            'request_three_d_secure' => 'automatic'        ]    ],    'description' => 'This is a test payment intent',    'statement_descriptor' => 'LUIGEL STORE',    'currency' => "PHP",]);

Cancel Payment Intent#

Cancels the payment intent.

Sample#

use Luigel\Paymongo\Facades\Paymongo;
$paymentIntent = Paymongo::paymentIntent()->find('pi_hsJNpsRFU1LxgVbxW4YJHRs6');$cancelledPaymentIntent = $paymentIntent->cancel();

Attach Payment Intent#

Attach the payment intent.

Sample#

use Luigel\Paymongo\Facades\Paymongo;
$paymentIntent = Paymongo::paymentIntent()->find('pi_hsJNpsRFU1LxgVbxW4YJHRs6');// Attached the payment method to the payment intent$successfulPayment = $paymentIntent->attach('pm_wr98R2gwWroVxfkcNVZBuXg2');

Get Payment Intent#

You can retrieve a Payment Intent by providing a payment intent ID. The prefix for the id is pi_ followed by a unique hash representing the payment. Just pass the payment id to find($paymentIntentId) method.

Sample#

use Luigel\Paymongo\Facades\Paymongo;
$paymentIntent = Paymongo::paymentIntent()->find('pi_hsJNpsRFU1LxgVbxW4YJHRs6');