¨4.0.1¨

This commit is contained in:
¨NW¨
2023-12-03 14:07:47 +00:00
parent c08b36d1b6
commit f35052522d
1112 changed files with 43019 additions and 24987 deletions

View File

@@ -4,47 +4,41 @@ namespace Modules\Payment\Gateways;
use Exception;
use Illuminate\Http\Request;
use MercadoPago\SDK as MercadoPagoSDK;
use MercadoPago\Preference as MercadoPagoPreference;
use MercadoPago\Item as MercadoPagoItem;
use Modules\Order\Entities\Order;
use MercadoPago\SDK as MercadoPagoSDK;
use Modules\Payment\GatewayInterface;
use MercadoPago\Item as MercadoPagoItem;
use Modules\Payment\Responses\MercadoPagoResponse;
use Modules\Support\Money;
use MercadoPago\Preference as MercadoPagoPreference;
class MercadoPago implements GatewayInterface
{
public const CURRENCIES = ['UYU', 'PEN', 'COP', 'MXN', 'CLP', 'BRL', 'ARS'];
public $label;
public $description;
public const CURRENCIES = ['UYU', 'PEN', 'COP', 'MXN', 'CLP', 'BRL', 'ARS'];
public function __construct()
{
$this->label = setting('mercadopago_label');
$this->description = setting('mercadopago_description');
$this->init();
}
public function init()
{
if (setting('mercadopago_enabled')) {
MercadoPagoSDK::setAccessToken(setting('mercadopago_access_token'));
}
}
/**
* @throws Exception
*/
public function purchase(Order $order, Request $request)
{
$this->init();
if (!in_array(currency(), $this->getSupportedCurrencies())) {
throw new Exception(trans('payment::messages.currency_not_supported'));
}
$preference = new MercadoPagoPreference();
try {
$preference = new MercadoPagoPreference();
$preference->items = $this->prepareItems($order);
$preference->binary_mode = true;
@@ -69,15 +63,17 @@ class MercadoPago implements GatewayInterface
}
private function getRedirectUrl($order)
public function init()
{
return route('checkout.complete.store', ['orderId' => $order->id, 'paymentMethod' => 'mercadopago']);
if (setting('mercadopago_enabled')) {
MercadoPagoSDK::setAccessToken(setting('mercadopago_access_token'));
}
}
private function getPaymentFailedUrl($order)
public function getSupportedCurrencies()
{
return route('checkout.payment_canceled.store', ['orderId' => $order->id, 'paymentMethod' => 'mercadopago']);
return [setting('mercadopago_supported_currency'), 'USD'];
}
@@ -155,14 +151,20 @@ class MercadoPago implements GatewayInterface
}
public function getSupportedCurrencies()
{
return [setting('mercadopago_supported_currency'), 'USD'];
}
public function complete(Order $order)
{
return new MercadoPagoResponse($order, request());
}
private function getRedirectUrl($order)
{
return route('checkout.complete.store', ['orderId' => $order->id, 'paymentMethod' => 'mercadopago']);
}
private function getPaymentFailedUrl($order)
{
return route('checkout.payment_canceled.store', ['orderId' => $order->id, 'paymentMethod' => 'mercadopago']);
}
}