forked from anvargear/LaravelPayuLatam
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request anvargear#2 from joselfonseca/master
Web Checkout Facilities
- Loading branch information
Showing
24 changed files
with
650 additions
and
141 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
/vendor | ||
composer.phar | ||
composer.lock | ||
/nbproject | ||
/site |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,41 @@ | ||
{ | ||
"name": "anvarco/payulatam", | ||
"description": "Payulatam form laravel provides an expressive, fluent interface to PayuLatam subscription billing services.", | ||
"version": "0.0.3-dev", | ||
"type": "project", | ||
"require": { | ||
"php": ">=5.5.9", | ||
"anvarco/sdkpayu": "1.0.*", | ||
"laravel/framework": "5.*" | ||
}, | ||
"license": "MIT", | ||
"authors": [ | ||
{ | ||
"name": "AnvarStudios.CO Labs", | ||
"email": "[email protected]", | ||
"homepage": "http://www.anvarstudios.co", | ||
"role": "Developer" | ||
} | ||
], | ||
"support": { | ||
"name": "anvarco/payulatam", | ||
"description": "Payulatam form laravel provides an expressive, fluent interface to PayuLatam subscription billing services.", | ||
"type": "project", | ||
"require": { | ||
"php": ">=5.5.9" | ||
}, | ||
"require-dev": { | ||
"phpunit/phpunit": "4.8.*", | ||
"orchestra/testbench": "~3.1" | ||
}, | ||
"license": "MIT", | ||
"authors": [ | ||
{ | ||
"name": "AnvarStudios.CO Labs", | ||
"email": "[email protected]", | ||
"wiki": "https://github.com/anvarstudios/LaravelPayuLatam/wiki" | ||
"homepage": "http://www.anvarstudios.co", | ||
"role": "Developer" | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"AnvarCO\\PayuLatam\\": "src/" | ||
} | ||
{ | ||
"name": "Jose Luis Fonseca", | ||
"email": "[email protected]", | ||
"homepage": "https://www.josefonseca.me", | ||
"role": "Developer" | ||
} | ||
], | ||
"support": { | ||
"email": "[email protected]", | ||
"wiki": "https://github.com/anvarstudios/LaravelPayuLatam/wiki" | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"AnvarCO\\PayuLatam\\": "src/" | ||
} | ||
}, | ||
"autoload-dev": { | ||
"psr-4": { | ||
"AnvarCO\\PayuLatam\\Tests\\": "tests/" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
# Migration | ||
|
||
Please copy the migration from the migrations folder in this package to your app and run `php artisan:migrate` | ||
|
||
# Web Checkout Class | ||
|
||
This class will alow you to generate the signature and will hold all the information needed to build a form for the web checkout endpoint in PayU Latam. | ||
|
||
## Env file | ||
|
||
You need to set the following varibles in your .env file | ||
|
||
```bash | ||
PAYU_MERCHANT_ID=500238 | ||
PAYU_ACCOUNT=509171 | ||
PAYU_API_KEY=6u39nqhq8ftd0hlvnjfs66eh8c | ||
PAYU_API_LOGIN=11959c415b33d0c | ||
PAYU_LANG=es | ||
PAYU_RESPONSE_URL=http://example.com/payu/response | ||
PAYU_CONFIRMATION_URL=http://example.com/payu/confirmation | ||
``` | ||
|
||
## Example | ||
|
||
```php | ||
use AnvarCO\PayuLatam\Form\Builder as PayuLatamForm; | ||
|
||
$webCheckout = app('WebCheckoutData'); | ||
/** | ||
* @param $buyerEmail | ||
* @param $description | ||
* @param $referenceCode | ||
* @param $amount | ||
* @param int $tax | ||
* @param int $taxReturnBase | ||
* @return $this | ||
*/ | ||
$webCheckout->init('[email protected]', 'Description', 'Reference', 35000, 0, 0)->process(); | ||
$form = new PayuLatamForm($webCheckout); | ||
echo $form->getForm(); | ||
``` | ||
Don't forget to add this endpoint to the except property in the VerifyCsfrToken Middleware | ||
|
||
``` | ||
'payu/confirmation' | ||
``` | ||
|
||
Something like this | ||
|
||
```php | ||
|
||
namespace App\Http\Middleware; | ||
|
||
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as BaseVerifier; | ||
|
||
class VerifyCsrfToken extends BaseVerifier | ||
{ | ||
/** | ||
* The URIs that should be excluded from CSRF verification. | ||
* | ||
* @var array | ||
*/ | ||
protected $except = [ | ||
'payu/confirmation' | ||
]; | ||
} | ||
|
||
``` | ||
|
||
#Events | ||
|
||
The package fires 2 events in the confirmation post request `AnvarCO\PayuLatam\Events\ConfirmationArrived` once the post arrives and `AnvarCO\PayuLatam\Events\ConfirmationSaved` once the confirmation information has been added to the database. | ||
|
41 changes: 41 additions & 0 deletions
41
migrations/2015_08_25_093443_PayUlatamConfirmationData.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phpunit backupGlobals="false" | ||
backupStaticAttributes="false" | ||
bootstrap="vendor/autoload.php" | ||
colors="true" | ||
convertErrorsToExceptions="true" | ||
convertNoticesToExceptions="true" | ||
convertWarningsToExceptions="true" | ||
processIsolation="false" | ||
stopOnFailure="false" | ||
syntaxCheck="false" | ||
> | ||
<testsuites> | ||
<testsuite name="Package Test Suite"> | ||
<directory suffix=".php">./tests/</directory> | ||
</testsuite> | ||
</testsuites> | ||
</phpunit> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' | ||
]; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
namespace AnvarCO\PayuLatam\Form; | ||
|
||
|
||
use AnvarCO\PayuLatam\WebCheckoutData; | ||
|
||
/** | ||
* Class Builder | ||
* @package AnvarCO\PayuLatam\Form | ||
* @author Jose Luis Fonseca <[email protected]> | ||
*/ | ||
class Builder { | ||
|
||
/** | ||
* @var WebCheckoutData | ||
*/ | ||
private $payu; | ||
|
||
/** | ||
* @param WebCheckoutData $payu | ||
*/ | ||
public function __construct(WebCheckoutData $payu) | ||
{ | ||
$this->payu = $payu; | ||
} | ||
|
||
/** | ||
* ger the form based on the theme in config | ||
* @return string | ||
*/ | ||
public function getForm() | ||
{ | ||
return view('payulatam::templates.'.config('payulatam.theme','bootstrap'))->with($this->payu->toArray())->render(); | ||
} | ||
|
||
} |
Oops, something went wrong.