toggle paypal sandbox/live

This commit is contained in:
Čarodej
2022-01-14 11:55:14 +01:00
parent 7dd116a769
commit 51701214a2
7 changed files with 32 additions and 4 deletions

View File

@@ -56,6 +56,8 @@ PAYSTACK_PUBLIC_KEY=
PAYPAL_CLIENT_ID=
PAYPAL_CLIENT_SECRET=
PAYPAL_WEBHOOK_ID=
PAYPAL_IS_LIVE=true
FACEBOOK_CLIENT_ID=
FACEBOOK_CLIENT_SECRET=

View File

@@ -56,7 +56,7 @@
"/chunks/pages.js": "/chunks/pages.js?id=fc74b3c4250317f9955f",
"/chunks/payments.js": "/chunks/payments.js?id=56a633689fc98ab71b92",
"/chunks/payments/billings.js": "/chunks/payments/billings.js?id=ddeb484509e788db1eda",
"/chunks/payments/settings.js": "/chunks/payments/settings.js?id=f8614cf0ade51919247a",
"/chunks/payments/settings.js": "/chunks/payments/settings.js?id=cab5d58684a2c8c2a147",
"/chunks/plan.js": "/chunks/plan.js?id=fc9e9e0b9bac63514475",
"/chunks/plan-create/fixed.js": "/chunks/plan-create/fixed.js?id=75b6e639a1fb66d34f10",
"/chunks/plan-create/metered.js": "/chunks/plan-create/metered.js?id=22a5c4fb60a77b72cd4e",
@@ -185,5 +185,11 @@
"/chunks/user-storage.6bd3ab1a8a2e99a1e4af.hot-update.js": "/chunks/user-storage.6bd3ab1a8a2e99a1e4af.hot-update.js",
"/chunks/user-subscription.6bd3ab1a8a2e99a1e4af.hot-update.js": "/chunks/user-subscription.6bd3ab1a8a2e99a1e4af.hot-update.js",
"/chunks/billing.728ac9ab3e5a2a3b0004.hot-update.js": "/chunks/billing.728ac9ab3e5a2a3b0004.hot-update.js",
"/chunks/billing.41e0a6e034deea202f37.hot-update.js": "/chunks/billing.41e0a6e034deea202f37.hot-update.js"
"/chunks/billing.41e0a6e034deea202f37.hot-update.js": "/chunks/billing.41e0a6e034deea202f37.hot-update.js",
"/chunks/payments/settings.300ac4824a3419b1c208.hot-update.js": "/chunks/payments/settings.300ac4824a3419b1c208.hot-update.js",
"/chunks/payments/settings.3d78d96f322fd3beaae2.hot-update.js": "/chunks/payments/settings.3d78d96f322fd3beaae2.hot-update.js",
"/chunks/payments/settings.6ec6ebd9434dc12d3a2b.hot-update.js": "/chunks/payments/settings.6ec6ebd9434dc12d3a2b.hot-update.js",
"/chunks/payments/settings.f9e50fd42e9b6a20e51d.hot-update.js": "/chunks/payments/settings.f9e50fd42e9b6a20e51d.hot-update.js",
"/chunks/payments/settings.3ad4539db6a81f4c469b.hot-update.js": "/chunks/payments/settings.3ad4539db6a81f4c469b.hot-update.js",
"/chunks/payments/settings.194aed09083333a609f6.hot-update.js": "/chunks/payments/settings.194aed09083333a609f6.hot-update.js"
}

View File

@@ -170,6 +170,10 @@
<!--Stripe credentials are set up-->
<div v-if="paypal.allowedService">
<div v-if="paypal.isConfigured">
<AppInputSwitch :title="$t('Live Mode')" :description="$t('Toggle amid live and sandbox mode')">
<SwitchInput @input="$updateText('/admin/settings', 'paypal_live', config.isPayPalLive)" v-model="config.isPayPalLive" :state="config.isPayPalLive" />
</AppInputSwitch>
<AppInputText @input="$updateText('/admin/settings', 'paypal_payment_description', paypal.paymentDescription)" :title="$t('Payment Description')" :description="$t('The description showed below user payment method selection.')">
<textarea rows="2" @input="$updateText('/admin/settings', 'paypal_payment_description', paypal.paymentDescription, true)" v-model="paypal.paymentDescription" :placeholder="$t('Describe in short which methods user can pay with this payment method...')" type="text" class="focus-border-theme input-dark" />
</AppInputText>

View File

@@ -107,6 +107,7 @@
// PayPal
isPayPal: {{ $settings->allowed_paypal ?? 0 }},
isPayPalLive: {{ env('PAYPAL_IS_LIVE') ? 1 : 0 }},
paypal_client_id: '{{ env('PAYPAL_CLIENT_ID') }}',
paypal_payment_description: '{{ $settings->paypal_payment_description ?? '' }}',

View File

@@ -55,6 +55,7 @@ class StorePaymentServiceCredentialsController
'PAYPAL_CLIENT_ID' => $request->input('key'),
'PAYPAL_CLIENT_SECRET' => $request->input('secret'),
'PAYPAL_WEBHOOK_ID' => $request->input('webhook'),
'PAYPAL_IS_LIVE' => 'true',
],
];

View File

@@ -5,6 +5,7 @@ use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Domain\Settings\Models\Setting;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Artisan;
class UpdateSettingValueController extends Controller
{
@@ -28,6 +29,21 @@ class UpdateSettingValueController extends Controller
return response('Done', 204);
}
// Set paypal live option
if ($request->input('name') === 'paypal_live') {
setEnvironmentValue([
'PAYPAL_IS_LIVE' => $request->input('value') ? 'true' : 'false',
]);
// Clear config cache
if (! is_dev()) {
Artisan::call('config:clear');
Artisan::call('config:cache');
}
return response('Done', 204);
}
// Find and update variable
Setting::updateOrCreate(
['name' => $request->input('name')],

View File

@@ -156,8 +156,6 @@ if (! function_exists('setEnvironmentValue')) {
/**
* Set environment value
*
* @param $key
* @param $value
* @return bool
*/
function setEnvironmentValue(array $values)