PHP code example of julienmru / laravel-paybox-gateway

1. Go to this page and download the library: Download julienmru/laravel-paybox-gateway 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/ */

    

julienmru / laravel-paybox-gateway example snippets

   
   composer 

   JulienMru\PayboxGateway\Providers\PayboxServiceProvider::class,
   

    php artisan vendor:publish --provider="JulienMru\PayboxGateway\Providers\PayboxServiceProvider"
    

$authorizationRequest = \App::make(\JulienMru\PayboxGateway\Requests\AuthorizationWithCapture::class);

return $authorizationRequest->setAmount(100)->setCustomer([
                            'firstname' => 'John',
                            'lastname' => 'Doe',
                            'email' => '[email protected]',
                            'address' => 'Test Street',
                            'postcode' => '75015',
                            'city' => 'PARIS',
                            'countrycode' => 250 // ISO Numeric Code
                        ])
            ->setShoppingCart(['total' => ['totalQuantity' => 10]])
            ->setPaymentNumber(1)->send('paybox.send');

$subscriptionRequest = \App::make(\JulienMru\PayboxGateway\Requests\Subscription::class);

return $subscriptionRequest->setInitialAmount(100)->setRecurringAmount(100)->setCustomer([
                            'firstname' => 'John',
                            'lastname' => 'Doe',
                            'email' => '[email protected]',
                            'address' => 'Test Street',
                            'postcode' => '75015',
                            'city' => 'PARIS',
                            'countrycode' => 250 // ISO Numeric Code
                        ])
            ->setShoppingCart(['total' => ['totalQuantity' => 10]])
            ->setPaymentDay(0)->setPaymentFrequency(1)->setPaymentCount(12)->setPaymentShift(5)->send('paybox.send');

$severalTimesRequest = \App::make(\JulienMru\PayboxGateway\Requests\SeveralTimes::class);

return $severalTimesRequest->setCustomer([
                            'firstname' => 'John',
                            'lastname' => 'Doe',
                            'email' => '[email protected]',
                            'address' => 'Test Street',
                            'postcode' => '75015',
                            'city' => 'PARIS',
                            'countrycode' => 250 // ISO Numeric Code
                        ])
            ->setShoppingCart(['total' => ['totalQuantity' => 10]])
            ->setPayment1(20)
            ->setPayment2(Carbon\Carbon::now()->addDays(15), 25)
            ->setPayment3(Carbon\Carbon::now()->addDays(45), 30)
            ->setPayment4(Carbon\Carbon::now()->addDays(60), 40)
            ->send();

$payment = Payment::where('number', $request->input('order_number'))->firstOrFail();
$payboxVerify = \App::make(\JulienMru\PayboxGateway\Responses\Verify::class);
try {
    $success = $payboxVerify->isSuccess($payment->amount);
    if ($success) {
       // process order here after making sure it was real payment
    }
    echo "OK";
}
catch (InvalidSignature $e) {
    Log::alert('Invalid payment signature detected');
}

$payment = PaymentModel::find($idOfAuthorizedPayment);
$captureRequest = \App::make(\JulienMru\PayboxGateway\Requests\Capture::class);
$response = $captureRequest->setAmount($payment->amount)
                           ->setPayboxCallNumber($payment->call_number)
                           ->setPayboxTransactionNumber($payment->transaction_number)
                           ->setDayRequestNumber(2)
                           ->send();
                           
if ($response->isSuccess()) {
     // process order here                
}