Commit a0774dcc by Angel MAS

payment cash, mercado pago

parent 591ef1ff
......@@ -227,7 +227,7 @@ class AdminProductController extends Controller
}
public function showVars()
/*public function showVars()
{
$variable = Variable::first();
......@@ -256,7 +256,7 @@ class AdminProductController extends Controller
return redirect()
->back()
->with('message_success', 'Información actualizada');
}
}*/
public function extraInfo(Request $request)
{
......
......@@ -300,6 +300,66 @@ class CartController extends Controller
return $request;
}
public function paymentCash(Request $request)
{
if (!\Session::has('client')) {
return redirect()->route('cart.shipping');
}
if (!\Session::has('sale')) {
return redirect()->route('cart.shipping');
}
$sale = Sale::find(\Session::get('sale')->id);
$client = $sale->client;
$items = $sale->items;
$addres = $client->shipping;
$detail = '';
foreach ($sale->items as $item) {
$detail = $detail." ".$item->quantity." ".$item->product->name.", ";
}
$detail = $detail." Envio ". $addres->shipping_price->name ." $". $addres->shipping_price->cost .".00";
$mp = new MP('TEST-7957752184054483-101318-9bbc7ef53f975318d2521f05257cb66a__LB_LC__-60150825');
$payment_data = array(
"transaction_amount" => $this->total() + $addres->shipping_price->cost,
"description" => $detail,
"payment_method_id" => $request->payment_id,
"payer" => array (
"email" => $client->email,
"first_name"=>$client->name,
"last_name"=>$client->lastname
)
);
$payment = $mp->post("/v1/payments", $payment_data);
$url_ficha = $payment['response']['transaction_details']['external_resource_url'];
$sale->status = 3;
$sale->transaction_id = $payment['response']['id'];
$sale->save();
\Session::forget('client');
\Session::forget('cart');
\Session::forget('sale');
return redirect()
->route('main.shop')
->with('url_ficha', $url_ficha);
}
private function total()
{
......
......@@ -29,13 +29,13 @@ Route::group(['middleware' => ['web', 'auth', 'is_admin']], function(){
'Onestartup\Shop\Controller\AdminProductController@deleteCover')
->name('admin-shop-product.delete.cover');
Route::get('admin/product/variable',
/*Route::get('admin/product/variable',
'Onestartup\Shop\Controller\AdminProductController@showVars')
->name('admin-shop-product.view.vars');
Route::post('admin/product/variable',
'Onestartup\Shop\Controller\AdminProductController@postVars')
->name('admin-shop-product.store.vars');
->name('admin-shop-product.store.vars');*/
Route::post('admin/shop/product-extra',
'Onestartup\Shop\Controller\AdminProductController@extraInfo')
......@@ -60,6 +60,7 @@ Route::group(['middleware' => ['web']], function(){
Route::post('cart/store/client', 'Onestartup\Shop\Controller\CartController@storeClient')->name('cart.store.client');
Route::post('cart/payment', 'Onestartup\Shop\Controller\CartController@payment')->name('cart.payment');
Route::post('cart/paymentCash', 'Onestartup\Shop\Controller\CartController@paymentCash')->name('cart.paymentCash');
Route::get('cart/update/{product_slug}/{quantity}', 'Onestartup\Shop\Controller\CartController@update')
->where('quantity', '[0-9]+')
......@@ -69,4 +70,12 @@ Route::group(['middleware' => ['web']], function(){
Route::get('producto/{slug}', 'Onestartup\Shop\Controller\ProductController@show')->name('show.shop');
Route::get('shop', 'Onestartup\Shop\Controller\ProductController@index')->name('main.shop');
//Route::get('cart/{product_id}')
Route::get('test/payments', function ()
{
$mp = new Onestartup\Shop\Payment\MP ("TEST-7957752184054483-101318-9bbc7ef53f975318d2521f05257cb66a__LB_LC__-60150825");
$payment_methods = $mp->get ("/v1/payment_methods");
dd ($payment_methods);
});
});
......@@ -59,6 +59,10 @@ setlocale(LC_MONETARY, 'en_US');
@include('shop-public::forms.fields-payment')
<br>
@include('shop-public::forms.fields-payment-cash')
</section>
......
<form action="{{route('cart.paymentCash')}}" method="POST">
{{ csrf_field() }}
<div class="group">
<label>
Selecciona la opcion deseada
</label>
<select name="payment_id">
<option value="oxxo">Oxxo</option>
<option value="bancomer">Bancomer</option>
<option value="serfin">Santander</option>
<option value="banamex">Banamex</option>
</select>
</div>
<button>
Pagar {{ money_format('%(#10n', ($total + $addres->shipping_price->cost)) }}
</button>
</form>
\ No newline at end of file
......@@ -46,6 +46,19 @@
swal("Pago pendiente", "Estamos procesando tu pago, te notificaremos por correo el estatus", "warning")
</script>
@endif
@if(Session::has('url_ficha'))
<script>
$(function() {
var url = "{{Session::get('url_ficha')}}";
swal("Pago pendiente", "Descarga tu ficha y llevala a pagar al lugar correspodiente", "warning")
console.log(url);
window.open(url, '_blank');
})
</script>
@endif
<!-- ******************************************* -->
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment