@@ -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.'); | |||
} | |||
} |
@@ -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(); ?> |
@@ -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"; | |||
} | |||
} | |||
} | |||
} |
@@ -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) { |
@@ -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'; | |||
} | |||