1. Go to this page and download the library: Download alexo/laravel-payu 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/ */
alexo / laravel-payu example snippets
namespace App\Http\Controllers;
use Alexo\LaravelPayU\LaravelPayU;
class PaymentsController extends Controller
{
LaravelPayU::doPing(function($response) {
$code = $response->code;
// ... revisar el codigo de respuesta
}, function($error) {
// ... Manejo de errores PayUException
});
namespace App\Http\Controllers;
use Alexo\LaravelPayU\LaravelPayU;
class PaymentsController extends Controller
{
LaravelPayU::getPSEBanks(function($banks) {
//... Usar datos de bancos
foreach($banks as $bank) {
$bankCode = $bank->pseCode;
}
}, function($error) {
// ... Manejo de errores PayUException, InvalidArgument
});
namespace App;
use Alexo\LaravelPayU\Payable;
use Illuminate\Database\Eloquent\Model;
class Order extends Model
{
use Payable;
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'reference', 'payu_order_id', 'transaction_id', 'state', 'value', 'user_id'
];
}
$order = Order::find($id);
$data = [
\PayUParameters::DESCRIPTION => 'Payment cc test',
\PayUParameters::IP_ADDRESS => '127.0.0.1',
\PayUParameters::CURRENCY => 'COP',
\PayUParameters::CREDIT_CARD_NUMBER => '378282246310005',
\PayUParameters::CREDIT_CARD_EXPIRATION_DATE => '2017/02',
\PayUParameters::CREDIT_CARD_SECURITY_CODE => '1234',
\PayUParameters::INSTALLMENTS_NUMBER => 1 ...
];
$order->payWith($data, function($response, $order) {
if ($response->code == 'SUCCESS') {
$order->update([
'payu_order_id' => $response->transactionResponse->orderId,
'transaction_id' => $response->transactionResponse->transactionId
]);
// ... El resto de acciones sobre la orden
} else {
//... El código de respuesta no fue exitoso
}
}, function($error) {
// ... Manejo de errores PayUException, InvalidArgument
});
namespace App;
use Alexo\LaravelPayU\Payable;
use Alexo\LaravelPayU\Searchable;
use Illuminate\Database\Eloquent\Model;
class Order extends Model
{
use Payable, Searchable;
}
$order = Order::find($id);
$order->searchById(function($response, $order) {
// ... Usar la información de respuesta
}, function($error) {
// ... Manejo de errores PayUException, InvalidArgument
});
$order->searchByReference(function($response, $order) {
// ... Usar la información de respuesta
}, function($error) {
// ... Manejo de errores PayUException, InvalidArgument
});
$order->searchByTransaction(function($response, $order) {
// ... Usar la información de respuesta
}, function($error) {
// ... Manejo de errores PayUException, InvalidArgument
});
bash
php artisan vendor:publish
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.