Skip to content

Instantly share code, notes, and snippets.

@brayancruces
Last active March 17, 2017 22:12
Show Gist options
  • Save brayancruces/9bfeeb1bf1755d8db5a9334ee0fcb472 to your computer and use it in GitHub Desktop.
Save brayancruces/9bfeeb1bf1755d8db5a9334ee0fcb472 to your computer and use it in GitHub Desktop.
Ejemplo de instalación de Culqi en Laravel 5.4
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"type": "project",
"require": {
"php": ">=5.6.4",
"laravel/framework": "5.4.*",
"laravel/tinker": "~1.0",
"culqi/culqi-php": "1.3.3"
},
"require-dev": {
"fzaninotto/faker": "~1.4",
"mockery/mockery": "0.9.*",
"phpunit/phpunit": "~5.7"
},
"autoload": {
"classmap": [
"database"
],
"psr-4": {
"App\\": "app/"
}
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
},
"scripts": {
"post-root-package-install": [
"php -r \"file_exists('.env') || copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"php artisan key:generate"
],
"post-install-cmd": [
"Illuminate\\Foundation\\ComposerScripts::postInstall",
"php artisan optimize"
],
"post-update-cmd": [
"Illuminate\\Foundation\\ComposerScripts::postUpdate",
"php artisan optimize"
]
},
"config": {
"preferred-install": "dist",
"sort-packages": true
}
}
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Culqi\Culqi;
class PaymentController extends Controller
{
protected function index()
{
try {
$SECRET_KEY = "<< Aqui tu llave secreta >>";
$culqi = new Culqi(array('api_key' => $SECRET_KEY));
//dd($_POST["token"]);
$charge = $culqi->Charges->create(
array(
"amount" => 200,
"currency_code" => "PEN",
"email" => "prueba@culqi.com",
"source_id" => "<< Aqui un token, generado por Culqi Checkout >>",
"antifraud_details" => array(
"address" =>"Calle Narciso de la Colina",
"address_city"=> "Lima",
"country_code" => "PE",
"first_name" => "Liz",
"last_name" => "Ruelas",
"phone_number" => 123456789
)
)
);
//dd($charge);
echo "ok";
} catch (Exception $e) {
echo json_encode($e->getMessage());
}
}
}
<?php
/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/
Route::get('/', function () {
return view('welcome');
});
// Prueba de Culqi
Route::get('payment', 'PaymentController@index');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment