Browse Source

Mise en place modes de paiement

feature/rotating_product
Guillaume Bourgeois 5 months ago
parent
commit
204271b34c
5 changed files with 30 additions and 14 deletions
  1. +3
    -3
      backend/controllers/PointSaleController.php
  2. +2
    -2
      backend/views/producer/update.php
  3. +13
    -3
      console/commands/InitPointSalePaymentMethodsFromSettingsController.php
  4. +1
    -1
      domain/PointSale/PointSale/PointSaleBuilder.php
  5. +11
    -5
      domain/Producer/Producer/ProducerSolver.php

+ 3
- 3
backend/controllers/PointSaleController.php View File

@@ -99,7 +99,7 @@ class PointSaleController extends BackendController
if ($pointSale->load(\Yii::$app->request->post()) && $pointSale->save()) {
$pointSaleModule->updatePointSalePointProduction($pointSale);
$pointSaleModule->processRestrictedAccess($pointSale);
$this->initPaymentMethodOnsiteByCreditFunctioning($pointSale);
$this->initPaymentMethodsByCreditFunctioning($pointSale);
$distributionModule->addPointSaleIncomingDistributions($pointSale);

return $this->redirect(['index']);
@@ -128,7 +128,7 @@ class PointSaleController extends BackendController

$pointSaleModule->updatePointSalePointProduction($model);
$pointSaleModule->processRestrictedAccess($model);
$this->initPaymentMethodOnsiteByCreditFunctioning($model);
$this->initPaymentMethodsByCreditFunctioning($model);
$distributionModule->addPointSaleIncomingDistributions($model);

$this->setFlash('success', 'Point de vente modifié.');
@@ -143,7 +143,7 @@ class PointSaleController extends BackendController

public function initPaymentMethodOnsiteByCreditFunctioning(PointSale $pointSale)
{
if($this->getPointSaleModule()->getBuilder()->initPaymentMethodOnsiteByCreditFunctioning($pointSale)) {
if($this->getPointSaleModule()->getBuilder()->initPaymentMethodsByCreditFunctioning($pointSale)) {
$this->addFlash('info', 'Le paiement sur place a été ajusté par rapport au fonctionnement de la cagnotte.');
}
}

+ 2
- 2
backend/views/producer/update.php View File

@@ -375,11 +375,11 @@ $this->addBreadcrumb($this->getTitle());
->dropDownList(Dropdown::noYesChoices()); ?>

<?= $form->field($model, 'option_stripe_mode_test')->dropDownList(Dropdown::noYesChoices()); ?>
<?= $form->field($model, 'option_online_payment_type')
<?php /*$form->field($model, 'option_online_payment_type')
->dropDownList([
'credit' => 'Alimentation de la cagnotte',
'order' => 'Paiement à la commande',
], []); ?>
], []);*/ ?>
<?= $form->field($model, 'option_stripe_public_key')->textInput(); ?>
<?= $form->field($model, 'option_stripe_private_key')->textInput(); ?>
<?= $form->field($model, 'option_stripe_endpoint_secret')->textInput(); ?>

console/commands/InitPointSaleCreditFunctioningFromSettingsController.php → console/commands/InitPointSalePaymentMethodsFromSettingsController.php View File

@@ -8,9 +8,9 @@ use domain\Producer\Producer\Producer;
use domain\Producer\Producer\ProducerModule;
use yii\console\Controller;

class InitPointSaleCreditFunctioningFromSettingsController extends Controller
class InitPointSalePaymentMethodsFromSettingsController extends Controller
{
// ./yii init-point-sale-credit-functioning-from-settings/index
// ./yii init-point-sale-payment-methods-from-settings/index
public function actionIndex()
{
$producerModule = ProducerModule::getInstance();
@@ -22,15 +22,25 @@ class InitPointSaleCreditFunctioningFromSettingsController extends Controller
\Yii::$app->logic->setProducerContext($producer);
$pointSaleArray = $pointSaleModule->getRepository()->findPointSales();
$creditFunctioningProducer = $producerModule->getConfig('credit_functioning');
$isOnlinePaymentActiveAndTypeOrder = $producerModule->isOnlinePaymentActiveAndTypeOrder($producer, false);
foreach($pointSaleArray as $pointSale) {
if($pointSale->payment_method_credit && !$pointSale->credit_functioning) {
$pointSale->credit_functioning = $creditFunctioningProducer;
if($pointSale->credit_functioning == Producer::CREDIT_FUNCTIONING_OPTIONAL) {
$pointSale->payment_method_onsite = 1;
$pointSale->payment_method_onsite = true;
}
$pointSale->save();
echo 'Point de vente "'.$pointSale->name. '" configuré sur "'.$pointSale->credit_functioning.'"'."\n";
}
$return = $pointSaleModule->getBuilder()->initPaymentMethodsByCreditFunctioning($pointSale);
if($return) {
echo 'Point de vente "'.$pointSale->name. '" : modes de paiements adaptés'."\n";
}
if($isOnlinePaymentActiveAndTypeOrder) {
$pointSale->payment_method_online = true;
$pointSale->save();
echo 'Point de vente "'.$pointSale->name. '" : paiement en ligne activé'."\n";
}
}
}
}

+ 1
- 1
domain/PointSale/PointSale/PointSaleBuilder.php View File

@@ -90,7 +90,7 @@ class PointSaleBuilder extends AbstractBuilder
return $this->userPointSaleBuilder->createUserPointSaleIfNotExist($user, $pointSale);
}

public function initPaymentMethodOnsiteByCreditFunctioning(PointSale $pointSale): bool
public function initPaymentMethodsByCreditFunctioning(PointSale $pointSale): bool
{
if($pointSale->payment_method_credit) {
if($pointSale->credit_functioning == Producer::CREDIT_FUNCTIONING_OPTIONAL && !$pointSale->payment_method_onsite) {

+ 11
- 5
domain/Producer/Producer/ProducerSolver.php View File

@@ -212,17 +212,23 @@ class ProducerSolver extends AbstractService implements SolverInterface
return $this->getPrivateKeyStripe($this->getFilenamePrivateKeyEndpointStripe($producer));
}

public function isOnlinePaymentActive(Producer $producer): bool
public function isOnlinePaymentActive(Producer $producer, bool $checkModeTest = true): bool
{
return $producer->online_payment
|| ($producer->option_stripe_mode_test
$return = $producer->online_payment;

if($checkModeTest) {
$return = $return
|| ($producer->option_stripe_mode_test
&& !\Yii::$app->user->isGuest
&& \Yii::$app->user->identity->status > 10);
}

return (bool) $return;
}

public function isOnlinePaymentActiveAndTypeOrder(Producer $producer): bool
public function isOnlinePaymentActiveAndTypeOrder(Producer $producer, bool $checkModeTest = true): bool
{
return $this->isOnlinePaymentActive($producer)
return $this->isOnlinePaymentActive($producer, $checkModeTest)
&& $producer->option_online_payment_type == 'order';
}


Loading…
Cancel
Save