mirror of
https://github.com/VueFileManager/vuefilemanager.git
synced 2026-05-30 15:44:41 +00:00
Paystack connection test
This commit is contained in:
@@ -623,10 +623,17 @@ export default {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
if (error.response.status === 500) {
|
if ([401, 500].includes(error.response.status)) {
|
||||||
this.isError = true
|
events.$emit('alert:open', {
|
||||||
this.errorMessage = error.response.data.message
|
title: error.response.data.title,
|
||||||
}
|
message: error.response.data.message,
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
events.$emit('toaster', {
|
||||||
|
type: 'danger',
|
||||||
|
message: this.$t('popup_error.title'),
|
||||||
|
})
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.finally(() => (this.isLoading = false))
|
.finally(() => (this.isLoading = false))
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -0,0 +1,60 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Domain\Settings\Actions;
|
||||||
|
|
||||||
|
use ErrorException;
|
||||||
|
use VueFileManager\Subscription\Domain\Plans\DTO\CreateFixedPlanData;
|
||||||
|
use VueFileManager\Subscription\Support\EngineManager;
|
||||||
|
|
||||||
|
class TestPaystackConnectionAction
|
||||||
|
{
|
||||||
|
public function __construct(
|
||||||
|
public EngineManager $subscription
|
||||||
|
){}
|
||||||
|
|
||||||
|
public function __invoke($credentials)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
// Set temporary paystack connection
|
||||||
|
config([
|
||||||
|
'subscription.credentials.paystack' => [
|
||||||
|
'secret' => $credentials['secret'],
|
||||||
|
'public_key' => $credentials['key'],
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Define test plan
|
||||||
|
$data = CreateFixedPlanData::fromArray([
|
||||||
|
'type' => 'fixed',
|
||||||
|
'name' => 'Test Plan',
|
||||||
|
'description' => null,
|
||||||
|
'features' => [
|
||||||
|
'max_storage_amount' => 200,
|
||||||
|
'max_team_members' => 20,
|
||||||
|
],
|
||||||
|
'currency' => 'ZAR',
|
||||||
|
'amount' => 99999,
|
||||||
|
'interval' => 'month',
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Create test plan
|
||||||
|
$plan = $this->subscription
|
||||||
|
->driver('paystack')
|
||||||
|
->createFixedPlan($data);
|
||||||
|
|
||||||
|
// Delete plan
|
||||||
|
$this->subscription
|
||||||
|
->driver('paystack')
|
||||||
|
->deletePlan($plan['id']);
|
||||||
|
|
||||||
|
} catch (ErrorException $error) {
|
||||||
|
abort(
|
||||||
|
response()->json([
|
||||||
|
'type' => 'service-connection-error',
|
||||||
|
'title' => 'Service Connection Error',
|
||||||
|
'message' => $error->getMessage(),
|
||||||
|
], 401)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,10 +4,15 @@ namespace Domain\Settings\Controllers;
|
|||||||
use Artisan;
|
use Artisan;
|
||||||
use Illuminate\Http\Response;
|
use Illuminate\Http\Response;
|
||||||
use Domain\Settings\Models\Setting;
|
use Domain\Settings\Models\Setting;
|
||||||
|
use Domain\Settings\Actions\TestPaystackConnectionAction;
|
||||||
use Domain\Settings\Requests\StorePaymentServiceCredentialsRequest;
|
use Domain\Settings\Requests\StorePaymentServiceCredentialsRequest;
|
||||||
|
|
||||||
class StorePaymentServiceCredentialsController
|
class StorePaymentServiceCredentialsController
|
||||||
{
|
{
|
||||||
|
public function __construct(
|
||||||
|
public TestPaystackConnectionAction $testPaystackConnection,
|
||||||
|
) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Configure stripe additionally
|
* Configure stripe additionally
|
||||||
*/
|
*/
|
||||||
@@ -43,6 +48,15 @@ class StorePaymentServiceCredentialsController
|
|||||||
|
|
||||||
// Get and store credentials
|
// Get and store credentials
|
||||||
if (! app()->runningUnitTests()) {
|
if (! app()->runningUnitTests()) {
|
||||||
|
// Test payment gateway connection
|
||||||
|
match ($request->input('service')) {
|
||||||
|
'paystack' => ($this->testPaystackConnection)([
|
||||||
|
'key' => $request->input('key'),
|
||||||
|
'secret' => $request->input('secret'),
|
||||||
|
]),
|
||||||
|
default => null
|
||||||
|
};
|
||||||
|
|
||||||
$credentials = [
|
$credentials = [
|
||||||
'stripe' => [
|
'stripe' => [
|
||||||
'STRIPE_PUBLIC_KEY' => $request->input('key'),
|
'STRIPE_PUBLIC_KEY' => $request->input('key'),
|
||||||
|
|||||||
Reference in New Issue
Block a user