Skip to content

Commit

Permalink
Response and confirmation
Browse files Browse the repository at this point in the history
  • Loading branch information
joselfonseca committed Aug 25, 2015
1 parent 9755387 commit 9d0984b
Show file tree
Hide file tree
Showing 8 changed files with 148 additions and 61 deletions.
41 changes: 41 additions & 0 deletions migrations/2015_08_25_093443_PayUlatamConfirmationData.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class PayUlatamConfirmationData extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('payu_confirmations', function($table)
{
$table->increments('id');
$table->integer('reference_sale')->unsigned();
$table->integer('state_pol');
$table->string('response_code_pol');
$table->string('reference_pol');
$table->string('sign');
$table->string('payment_method');
$table->decimal('value');
$table->decimal('tax');
$table->datetime('transaction_date');
$table->timestamps();
$table->softdeletes();
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('payu_confirmations');
}
}
23 changes: 23 additions & 0 deletions src/Confirmation/PayUConfirmation.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

namespace AnvarCO\PayuLatam\Confirmation;

use Illuminate\Database\Eloquent\Model;

class PayUConfirmation extends Model{

protected $table = "payu_confirmations";

protected $fillable = [
'reference_sale',
'state_pol',
'response_code_pol',
'reference_pol',
'sign',
'payment_method',
'value',
'tax',
'transaction_date'
];

}
28 changes: 28 additions & 0 deletions src/Events/ConfirmationArrived.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

namespace AnvarCO\PayuLatam\Events;

use Illuminate\Http\Request;


/**
* Class ConfirmationArrived
* @package AnvarCO\PayuLatam\Events
*/
class ConfirmationArrived {

/**
* @var Request
*/
public $confirmationRequest;

/**
* @param Request $confirmationRequest
*/
function __construct(Request $confirmationRequest)
{
$this->confirmationRequest = $confirmationRequest;
}


}
27 changes: 27 additions & 0 deletions src/Events/ConfirmationSaved.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

namespace AnvarCO\PayuLatam\Events;


use AnvarCO\PayuLatam\Confirmation\PayUConfirmation;

/**
* Class ConfirmationSaved
* @package AnvarCO\PayuLatam\Events
*/
class ConfirmationSaved {

/**
* @var
*/
public $confirmation;

/**
* @param PayUConfirmation $model
*/
public function __construct(PayUConfirmation $model)
{
$this->confirmation = $model;
}

}
35 changes: 25 additions & 10 deletions src/Http/Controllers/PayuLatamController.php
Original file line number Diff line number Diff line change
@@ -1,19 +1,34 @@
<?php namespace AnvarCO\Payulatam\Http\Controllers;

use AnvarCO\PayuLatam\Confirmation\PayUConfirmation;
use AnvarCO\PayuLatam\Events\ConfirmationArrived;
use AnvarCO\PayuLatam\Events\ConfirmationSaved;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Config;


/**
* Class PayuLatamController
* @package AnvarCO\Payulatam\Http\Controllers
*/
class PayuLatamController extends Controller
{
/**
* Show the application welcome screen to the user.
*
* @return Response
*/
public function index()
{
//dd(Config::get("payulatam.message"));
return view('payulatam::payulatam');
}

public function response()
{
return view('payulatam::response');
}

/**
* @param Request $request
* @return \Illuminate\Http\JsonResponse
*/
public function confirmation(Request $request)
{
event(new ConfirmationArrived($request));
$confirmation = PayUConfirmation::create($request->all());
event(new ConfirmationSaved($confirmation));
return response()->json(['ok' => true]);
}
}
4 changes: 3 additions & 1 deletion src/Http/routes.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<?php

Route::get('payulatam', 'PayuLatamController@index');
// Confirmation
Route::post('payu/confirmation', 'PayuLatamController@confirmation');
Route::get('payu/response', 'PayuLatamController@response');
50 changes: 0 additions & 50 deletions src/views/payulatam.blade.php

This file was deleted.

1 change: 1 addition & 0 deletions src/views/response.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<h1>Thanks!</h1>

0 comments on commit 9d0984b

Please sign in to comment.