Update showcomprar.blade.php

This commit is contained in:
lizandrogd
2024-08-13 09:44:11 -05:00
parent d7dee58d6e
commit b9be5825c1
+81 -75
View File
@@ -1,96 +1,102 @@
<div> <div>
<div class="bg-[#f5f5f5] mt-5 w-[90%] m-auto p-5 rounded-[1.2rem] border-b border-gray-200 shadow-md mb-4 relative"> <div class="bg-[#f5f5f5] mt-5 w-[90%] m-auto p-5 rounded-[1.2rem] border-b border-gray-200 shadow-md mb-4 relative">
<div class="flex justify-start my-2 items-center mb-4"> <div class="flex justify-start my-2 items-center mb-4">
<div class="flex text-sm"> <div class="flex text-sm">
<x-icon-arrow-right/> <x-icon-arrow-right />
Saldo Saldo
</div> </div>
</div> </div>
@php @php
// SDK de Mercado Pago // SDK de Mercado Pago
require base_path('vendor/autoload.php'); require base_path('vendor/autoload.php');
// Agrega credenciales // Agrega credenciales
MercadoPago\SDK::setAccessToken(config('services.mercadopago.token')); MercadoPago\SDK::setAccessToken(config('services.mercadopago.token'));
// Crea un objeto de preferencia
$preference = new MercadoPago\Preference();
// Crea un objeto de preferencia // Crea un ítem en la preferencia
$preference = new MercadoPago\Preference(); $item = new MercadoPago\Item();
$item->id = $historial_id;
$item->title = 'Compra SrPremium';
$item->quantity = 1;
$item->unit_price = $monto;
//$payment_methods = MercadoPago::get("/v1/payment_methods"); $preference->back_urls = array(
// Crea un ítem en la preferencia "success" => url('/compras/'),
$item = new MercadoPago\Item(); "failure" => url('/compras/error'),
$item->id = $historial_id; "pending" => url('/compras/pendiente')
$item->title = 'Compra SrPremium'; );
$item->quantity = 1; $preference->auto_return = "approved";
$item->unit_price = $monto;
$preference->back_urls = array(
"success" => url('/compras/'),
"failure" => url('/compras/error'),
"pending" => url('/compras/pendiente')
);
$preference->auto_return = "approved";
$preference->items = array($item);
$preference->save();
// Excluye el método de pago con tarjeta de crédito
$preference->payment_methods = array(
"excluded_payment_types" => array(
array("id" => "credit_card")
)
);
$preference->items = array($item);
$preference->save();
@endphp @endphp
<div class="grid grid-cols-1 mb-8">
<div class="bg-white w-full sm:w-[26rem] m-auto justify-center rounded-xl shadow-md"> <div class="grid grid-cols-1 mb-8">
<div class="text-center bg-[#000029] text-white text-lg font-semibold rounded-lg py-2 mb-4"> <div class="bg-white w-full sm:w-[26rem] m-auto justify-center rounded-xl shadow-md">
Recargar saldo <div class="text-center bg-[#000029] text-white text-lg font-semibold rounded-lg py-2 mb-4">
Recargar saldo
</div>
<div class="text-center mb-6">
Monto a recargar
<p class="font-semibold">
${{ number_format($monto) }}
</p>
</div>
<div class="flex justify-center">
<a href="javascript:location.reload()">
<img class="w-28 rounded-full shadow-lg" src="./img/mercadopago.jpg" alt="">
</a>
</div>
<div class="bg-white px-4 py-3 md:flex justify-center mt-2 mb-4">
<a href="javascript:location.reload()">
<button
class="inline-flex justify-center w-full rounded-md border border-transparent px-12 py-2 sm:mb-[0] mb-2 text-white bg-[#B221FD] hover:bg-[#7a02b8] focus:shadow-outline-green ease-in-out sm-text-sm sm-leading-5">Continuar</button>
</a>
</div>
</div>
</div> </div>
<div class="text-center mb-6">
Monto a recargar
<p class="font-semibold">
${{number_format($monto)}}
</p> <div class="cho-container">
</div> </div>
<div class="flex justify-center"> <script src="https://sdk.mercadopago.com/js/v2"></script>
<a href="javascript:location.reload()">
<img class="w-28 rounded-full shadow-lg" src="./img/mercadopago.jpg" alt="">
</a> <script>
</div> const mp = new MercadoPago("{{ config('services.mercadopago.key') }}", {
locale: 'es-CO'
});
<div class="bg-white px-4 py-3 md:flex justify-center mt-2 mb-4"> mp.checkout({
<a href="javascript:location.reload()"> preference: {
<button class="inline-flex justify-center w-full rounded-md border border-transparent px-12 py-2 sm:mb-[0] mb-2 text-white bg-[#B221FD] hover:bg-[#7a02b8] focus:shadow-outline-green ease-in-out sm-text-sm sm-leading-5">Continuar</button> id: '{{ $preference->id }}'
</a> },
</div>
</div>
</div>
autoOpen: true, // Habilita la apertura automática del Checkout Pro
});
</script>
</div>
<div class="cho-container">
</div>
<script src="https://sdk.mercadopago.com/js/v2"></script>
<script>
const mp = new MercadoPago("{{config('services.mercadopago.key')}}", {
locale: 'es-CO'
});
mp.checkout({
preference: {
id: '{{$preference->id}}'
},
autoOpen: true, // Habilita la apertura automática del Checkout Pro
});
</script>
</div>
</div> </div>