Update showcomprar.blade.php
This commit is contained in:
@@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
<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>
|
||||||
@@ -15,30 +15,35 @@
|
|||||||
// Agrega credenciales
|
// Agrega credenciales
|
||||||
MercadoPago\SDK::setAccessToken(config('services.mercadopago.token'));
|
MercadoPago\SDK::setAccessToken(config('services.mercadopago.token'));
|
||||||
|
|
||||||
|
|
||||||
// Crea un objeto de preferencia
|
// Crea un objeto de preferencia
|
||||||
$preference = new MercadoPago\Preference();
|
$preference = new MercadoPago\Preference();
|
||||||
|
|
||||||
//$payment_methods = MercadoPago::get("/v1/payment_methods");
|
|
||||||
// Crea un ítem en la preferencia
|
// Crea un ítem en la preferencia
|
||||||
$item = new MercadoPago\Item();
|
$item = new MercadoPago\Item();
|
||||||
$item->id = $historial_id;
|
$item->id = $historial_id;
|
||||||
$item->title = 'Compra SrPremium';
|
$item->title = 'Compra SrPremium';
|
||||||
$item->quantity = 1;
|
$item->quantity = 1;
|
||||||
$item->unit_price = $monto;
|
$item->unit_price = $monto;
|
||||||
$preference->back_urls = array(
|
|
||||||
|
|
||||||
|
$preference->back_urls = array(
|
||||||
"success" => url('/compras/'),
|
"success" => url('/compras/'),
|
||||||
"failure" => url('/compras/error'),
|
"failure" => url('/compras/error'),
|
||||||
"pending" => url('/compras/pendiente')
|
"pending" => url('/compras/pendiente')
|
||||||
);
|
);
|
||||||
$preference->auto_return = "approved";
|
$preference->auto_return = "approved";
|
||||||
|
|
||||||
|
// 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->items = array($item);
|
||||||
$preference->save();
|
$preference->save();
|
||||||
|
|
||||||
|
|
||||||
@endphp
|
@endphp
|
||||||
|
|
||||||
|
|
||||||
<div class="grid grid-cols-1 mb-8">
|
<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="bg-white w-full sm:w-[26rem] m-auto justify-center rounded-xl shadow-md">
|
||||||
<div class="text-center bg-[#000029] text-white text-lg font-semibold rounded-lg py-2 mb-4">
|
<div class="text-center bg-[#000029] text-white text-lg font-semibold rounded-lg py-2 mb-4">
|
||||||
@@ -48,7 +53,7 @@
|
|||||||
<div class="text-center mb-6">
|
<div class="text-center mb-6">
|
||||||
Monto a recargar
|
Monto a recargar
|
||||||
<p class="font-semibold">
|
<p class="font-semibold">
|
||||||
${{number_format($monto)}}
|
${{ number_format($monto) }}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -61,7 +66,8 @@
|
|||||||
|
|
||||||
<div class="bg-white px-4 py-3 md:flex justify-center mt-2 mb-4">
|
<div class="bg-white px-4 py-3 md:flex justify-center mt-2 mb-4">
|
||||||
<a href="javascript:location.reload()">
|
<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>
|
<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>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -78,13 +84,13 @@
|
|||||||
<script src="https://sdk.mercadopago.com/js/v2"></script>
|
<script src="https://sdk.mercadopago.com/js/v2"></script>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
const mp = new MercadoPago("{{config('services.mercadopago.key')}}", {
|
const mp = new MercadoPago("{{ config('services.mercadopago.key') }}", {
|
||||||
locale: 'es-CO'
|
locale: 'es-CO'
|
||||||
});
|
});
|
||||||
|
|
||||||
mp.checkout({
|
mp.checkout({
|
||||||
preference: {
|
preference: {
|
||||||
id: '{{$preference->id}}'
|
id: '{{ $preference->id }}'
|
||||||
},
|
},
|
||||||
|
|
||||||
autoOpen: true, // Habilita la apertura automática del Checkout Pro
|
autoOpen: true, // Habilita la apertura automática del Checkout Pro
|
||||||
|
|||||||
Reference in New Issue
Block a user