feat: ✨ Support csrf ignoring routes for extensions & moved extension config to own file
This commit is contained in:
parent
3909202958
commit
d11bb52038
5 changed files with 37 additions and 78 deletions
12
app/Extensions/PaymentGateways/PayPal/config.php
Normal file
12
app/Extensions/PaymentGateways/PayPal/config.php
Normal file
|
@ -0,0 +1,12 @@
|
|||
<?php
|
||||
|
||||
namespace App\Extensions\PaymentGateways\PayPal;
|
||||
|
||||
function getConfig()
|
||||
{
|
||||
return [
|
||||
"name" => "PayPal",
|
||||
"description" => "PayPal payment gateway",
|
||||
"RoutesIgnoreCsrf" => [],
|
||||
];
|
||||
}
|
|
@ -174,41 +174,3 @@ function getPaypalClientSecret()
|
|||
{
|
||||
return env('APP_ENV') == 'local' ? config("SETTINGS::PAYMENTS:PAYPAL:SANDBOX_SECRET") : config("SETTINGS::PAYMENTS:PAYPAL:SECRET");
|
||||
}
|
||||
function getPayPalConfig()
|
||||
{
|
||||
return [
|
||||
"name" => "PayPal",
|
||||
"description" => "PayPal payment gateway",
|
||||
"settings" => [
|
||||
"mode" => [
|
||||
"type" => "select",
|
||||
"label" => "Mode",
|
||||
"value" => config("APP_ENV") == 'local' ? "sandbox" : "live",
|
||||
"options" => [
|
||||
"sandbox" => "Sandbox",
|
||||
"live" => "Live",
|
||||
],
|
||||
],
|
||||
"CLIENT_ID" => [
|
||||
"type" => "text",
|
||||
"label" => "PayPal Client ID",
|
||||
"value" => config("SETTINGS::PAYMENTS:PAYPAL:CLIENT_ID"),
|
||||
],
|
||||
"SECRET" => [
|
||||
"type" => "text",
|
||||
"label" => "PayPal Secret",
|
||||
"value" => config("SETTINGS::PAYMENTS:PAYPAL:SECRET"),
|
||||
],
|
||||
"SANDBOX_CLIENT_ID" => [
|
||||
"type" => "text",
|
||||
"label" => "PayPal Sandbox Client ID",
|
||||
"value" => config("SETTINGS::PAYMENTS:PAYPAL:SANDBOX_CLIENT_ID"),
|
||||
],
|
||||
"SANDBOX_SECRET" => [
|
||||
"type" => "text",
|
||||
"label" => "PayPal Sandbox Secret",
|
||||
"value" => config("SETTINGS::PAYMENTS:PAYPAL:SANDBOX_SECRET"),
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
|
14
app/Extensions/PaymentGateways/Stripe/config.php
Normal file
14
app/Extensions/PaymentGateways/Stripe/config.php
Normal file
|
@ -0,0 +1,14 @@
|
|||
<?php
|
||||
|
||||
namespace App\Extensions\PaymentGateways\Stripe;
|
||||
|
||||
function getConfig()
|
||||
{
|
||||
return [
|
||||
"name" => "Stripe",
|
||||
"description" => "Stripe payment gateway",
|
||||
"RoutesIgnoreCsrf" => [
|
||||
"payment/StripeWebhooks",
|
||||
],
|
||||
];
|
||||
}
|
|
@ -371,40 +371,3 @@ function checkPriceAmount($amount, $currencyCode, $payment_method)
|
|||
];
|
||||
return $amount >= $minimums[$currencyCode][$payment_method];
|
||||
}
|
||||
|
||||
function getStripeConfig()
|
||||
{
|
||||
return [
|
||||
"name" => "Stripe",
|
||||
"description" => "Stripe payment gateway",
|
||||
"mode" => [
|
||||
"type" => "select",
|
||||
"label" => "Mode",
|
||||
"value" => config("APP_ENV") == 'local' ? "sandbox" : "live",
|
||||
"options" => [
|
||||
"sandbox" => "Sandbox",
|
||||
"live" => "Live",
|
||||
],
|
||||
],
|
||||
"TEST_SECRET" => [
|
||||
"type" => "text",
|
||||
"label" => "Test Secret Key",
|
||||
"value" => config("SETTINGS::PAYMENTS:STRIPE:TEST_SECRET"),
|
||||
],
|
||||
"SECRET" => [
|
||||
"type" => "text",
|
||||
"label" => "Live Secret Key",
|
||||
"value" => config("SETTINGS::PAYMENTS:STRIPE:SECRET"),
|
||||
],
|
||||
"ENDPOINT_TEST_SECRET" => [
|
||||
"type" => "text",
|
||||
"label" => "Test Endpoint Secret",
|
||||
"value" => config("SETTINGS::PAYMENTS:STRIPE:ENDPOINT_TEST_SECRET"),
|
||||
],
|
||||
"ENDPOINT_SECRET" => [
|
||||
"type" => "text",
|
||||
"label" => "Live Endpoint Secret",
|
||||
"value" => config("SETTINGS::PAYMENTS:STRIPE:ENDPOINT_SECRET"),
|
||||
],
|
||||
];
|
||||
}
|
||||
|
|
|
@ -2,7 +2,10 @@
|
|||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use App\Helpers\ExtensionHelper;
|
||||
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as Middleware;
|
||||
use Illuminate\Contracts\Encryption\Encrypter;
|
||||
use Illuminate\Contracts\Foundation\Application;
|
||||
|
||||
class VerifyCsrfToken extends Middleware
|
||||
{
|
||||
|
@ -11,7 +14,12 @@ class VerifyCsrfToken extends Middleware
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $except = [
|
||||
'payment/StripeWebhooks',
|
||||
];
|
||||
protected $except = [];
|
||||
|
||||
public function __construct(Application $app, Encrypter $encrypter)
|
||||
{
|
||||
$this->app = $app;
|
||||
$this->encrypter = $encrypter;
|
||||
$this->except = ExtensionHelper::getAllCsrfIgnoredRoutes();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue