1. Go to this page and download the library: Download laragear/transbank 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/ */
laragear / transbank example snippets
use Laragear\Transbank\Facades\Webpay;
use Laragear\Transbank\Http\Requests\WebpayRequest;
public function pay(Request $request)
{
return Webpay::create('pink teddy bear', 1990, url('confirm'));
}
public function confirm(WebpayRequest $payment)
{
if ($payment->isSuccessful()) {
return 'Your pink teddy bear is on the way!';
};
}
use Laragear\Transbank\Facades\Webpay;
public function pay(Request $request)
{
return Webpay::create('pink teddy bear', 1990, route('confirm'));
}
use Laragear\Transbank\Http\Requests\WebpayRequest;
public function confirm(WebpayRequest $request)
{
$transaction = $request->transaction();
if ($transaction->isSuccessful()) {
return 'Your pink teddy bear is on the way!';
};
}
use Illuminate\Support\Facades\Route;
Route::get('confirm', function (WebpayRequest $request) {
// ...
})->middleware('transbank.handle')
use Illuminate\Support\Facades\Route;
use Laragear\Transbank\Http\Requests\WebpayRequest;
use Laragear\Transbank\Facades\RouteRedirect;
Route::get('confirm', function (WebpayRequest $request) {
// ...
})->middleware('transbank.protect');
RouteRedirect::as('confirm');
use Illuminate\Support\Facades\Route;
use Laragear\Transbank\Http\Requests\WebpayRequest;
use Laragear\Transbank\Facades\RouteRedirect;
Route::get('confirm', function (WebpayRequest $request) {
// ... Handle the successful transaction.
})->middleware('transbank.protect');
Route::get('failed-transaction', function () {
// ... Handle the failed transaction.
})->middleware('transbank.protect');
RouteRedirect::as('confirm', 'failed-transaction');