PHP code example of luigel / laravel-paymongo

1. Go to this page and download the library: Download luigel/laravel-paymongo library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

luigel / laravel-paymongo example snippets


use Luigel\Paymongo\Enums\PaymentIntentStatus;
use Luigel\Paymongo\Facades\Paymongo;

// 1. Create the intent. Amounts are integer centavos: 150050 = PHP 1,500.50.
$intent = Paymongo::paymentIntents()->create([
    'amount' => 150050,
    'currency' => 'PHP',
    'payment_method_allowed' => ['card'],
    'description' => 'Order #1234',
]);

// 2. Create a payment method (normally done client-side with your public key).
$method = Paymongo::paymentMethods()->create([
    'type' => 'card',
    'details' => [
        'card_number' => '4343434343434345',
        'exp_month' => 12,
        'exp_year' => 34,
        'cvc' => '123',
    ],
]);

// 3. Attach it to the intent to trigger the payment.
$intent = Paymongo::paymentIntents()->attach($intent->id, $method->id);

if ($intent->status === PaymentIntentStatus::Succeeded) {
    // Paid. $intent->payments holds the resulting Payment resources.
}
bash
php artisan vendor:publish --tag=paymongo-config