Giter VIP home page Giter VIP logo

redsys-laravel's Introduction

Redys Laravel

Latest Version on Packagist Software License Total Downloads

Introducción

Tras finalizar la actualización de la clases Redsys para trabajar con sha256, he aprovechado en crear este package para laravel, de esta forma hacemos más ameno el trabajar con este framework.

Instalación

Via Composer

Laravel 5.1

$ composer require "ssheduardo/redsys-laravel=1.0.*"

Laravel 5.2 o 5.3

$ composer require "ssheduardo/redsys-laravel=~1.1"

O si lo prefieres, puedes agregarlo en la sección require de tu composer.json

Laravel 5.1

  "ssheduardo/redsys": "1.0.*"

Laravel 5.2 o 5.3

  "ssheduardo/redsys": "~1.1"

Ahora debemos cargar nuestro Services Provider dentro del array 'providers' (config/app.php)

Ssheduardo\Redsys\RedsysServiceProvider::class

Creamos un alias dentro del array 'aliases' (config/app.php)

'Redsys'    => Ssheduardo\Redsys\Facades\Redsys::class,

Y finalmente publicamos nuestro archivo de configuración

php artisan vendor:publish --provider="Ssheduardo\Redsys\RedsysServiceProvider"

Uso

Imaginemos que tenemos esta ruta http://ubublog.com/redsys que enlaza con RedsysController@index

Route::get('/redsys', ['as' => 'redsys', 'uses' => 'RedsysController@index']);

Y el contenido del controlador RedsysController sería este:

<?php
namespace App\Http\Controllers;

use Illuminate\Http\Request;

use App\Http\Requests;
use App\Http\Controllers\Controller;
use Ssheduardo\Redsys\Facades\Redsys;

class RedsysController extends Controller
{
    //
    public function index()
    {
        try{
            $key = config('redsys.key');
              
            Redsys::setAmount(rand(10,600));
            Redsys::setOrder(time());
            Redsys::setMerchantcode('999008881'); //Reemplazar por el código que proporciona el banco
            Redsys::setCurrency('978');
            Redsys::setTransactiontype('0');
            Redsys::setTerminal('1');
            Redsys::setMethod('T'); //Solo pago con tarjeta, no mostramos iupay
            Redsys::setNotification(config('redsys.url_notification')); //Url de notificacion
            Redsys::setUrlOk(config('redsys.url_ok')); //Url OK
            Redsys::setUrlKo(config('redsys.url_ko')); //Url KO             
            Redsys::setVersion('HMAC_SHA256_V1');
            Redsys::setTradeName('Tienda S.L');
            Redsys::setTitular('Pedro Risco');
            Redsys::setProductDescription('Compras varias');
            Redsys::setEnviroment('test'); //Entorno test
    
            $signature = Redsys::generateMerchantSignature($key);
            Redsys::setMerchantSignature($signature);
    
            $form = Redsys::createForm();
        }
        catch(Exception $e){
            echo $e->getMessage();
        }
        return $form;
    }
}

Change log

Please see CHANGELOG for more information what has changed recently.

Security

If you discover any security related issues, please email :author_email instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

redsys-laravel's People

Contributors

d3ce1t avatar ssheduardo avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.