Просмотр исходного кода

[Global] Système de feature flag #1385

feature/souke
Guillaume Bourgeois 1 год назад
Родитель
Сommit
5aba135f8a
19 измененных файлов: 367 добавлений и 157 удалений
  1. +13
    -1
      backend/controllers/FeatureAdminController.php
  2. +10
    -1
      backend/views/feature-admin/index.php
  3. +8
    -1
      backend/views/feature-admin/update.php
  4. +24
    -15
      backend/views/producer/update.php
  5. +7
    -1
      backend/web/js/backend.js
  6. +5
    -0
      common/logic/AbstractRepository.php
  7. +1
    -0
      common/logic/Feature/Feature/Model/Feature.php
  8. +8
    -1
      common/logic/Feature/Feature/Repository/FeatureRepository.php
  9. +8
    -0
      common/logic/Feature/Feature/Repository/FeatureRepositoryQuery.php
  10. +1
    -0
      common/logic/Feature/Feature/Service/FeatureDefinition.php
  11. +2
    -1
      composer.json
  12. +104
    -2
      composer.lock
  13. +1
    -0
      console/commands/ImportFeaturesController.php
  14. +25
    -0
      console/migrations/m231113_073008_add_column_feature_position.php
  15. +4
    -1
      frontend/controllers/SiteController.php
  16. +7
    -6
      frontend/views/site/_prices_producer.php
  17. +4
    -1
      frontend/views/site/service.php
  18. +131
    -125
      producer/controllers/CreditController.php
  19. +4
    -1
      producer/views/credit/history.php

+ 13
- 1
backend/controllers/FeatureAdminController.php Просмотреть файл

@@ -71,7 +71,7 @@ class FeatureAdminController extends BackendController
public function actionIndex()
{
$featureModule = $this->getFeatureModule();
$dataProviderFeatures = $featureModule->getRepository()->queryAll()->getDataProvider(100);
$dataProviderFeatures = $featureModule->getRepository()->queryDefaultAll()->getDataProvider(100);

return $this->render('index', [
'producerCurrent' => $this->getProducerCurrent(),
@@ -128,6 +128,18 @@ class FeatureAdminController extends BackendController
}
}

public function actionPosition()
{
$array = \Yii::$app->request->post('array');
$positionArray = json_decode(stripslashes($array));

foreach ($positionArray as $id => $position) {
$feature = $this->findModel($id);
$feature->position = $position;
$feature->save();
}
}

protected function findModel($id)
{
$featureModule = $this->getFeatureModule();

+ 10
- 1
backend/views/feature-admin/index.php Просмотреть файл

@@ -50,6 +50,15 @@ $this->addBreadcrumb($this->getTitle());
<?= GridView::widget([
'dataProvider' => $dataProviderFeatures,
'columns' => [
[
'attribute' => 'position',
'headerOptions' => ['class' => 'position'],
'format' => 'raw',
'filter' => '',
'value' => function ($model) {
return '<a class="btn-position btn btn-default" href="javascript:void(0);"><span class="glyphicon glyphicon-resize-vertical"></span></a>';
}
],
'name',
[
'attribute' => 'status',
@@ -121,7 +130,7 @@ $this->addBreadcrumb($this->getTitle());
'format' => 'raw',
'value' => function ($model) {
if($model->is_paid_feature && $model->price) {
return Price::format($model->price);
return Price::format($model->price, 0);
}

return '';

+ 8
- 1
backend/views/feature-admin/update.php Просмотреть файл

@@ -49,7 +49,14 @@ $this->addBreadcrumb('Modifier') ;
<?php $form = ActiveForm::begin(); ?>
<?= $form->field($model, 'status')->radioList([1 => 'Oui', 0 => 'Non']) ?>
<?= $form->field($model, 'name') ?>
<?= $form->field($model, 'description')->textarea(['rows' => '4']) ; ?>
<?= $form->field($model, 'description')->widget(letyii\tinymce\Tinymce::class, [
'options' => [
'id' => 'testid',
],
'configs' => [ // Read more: https://www.tiny.cloud/docs/tinymce/6/full-featured-open-source-demo/
'plugins' => 'preview importcss searchreplace autolink autosave save directionality code visualblocks visualchars fullscreen image link media template codesample table charmap pagebreak nonbreaking anchor insertdatetime advlist lists wordcount help charmap quickbars emoticons accordion' ,
]
]) ; ?>
<?= $form->field($model, 'only_for_selected_producers')->radioList([1 => 'Oui', 0 => 'Non']) ?>
<?= $form->field($model, 'is_paid_feature')->radioList([1 => 'Oui', 0 => 'Non']) ?>
<?= $form->field($model, 'price') ?>

+ 24
- 15
backend/views/producer/update.php Просмотреть файл

@@ -39,6 +39,8 @@
use common\helpers\Dropdown;
use common\helpers\GlobalParam;
use common\logic\Distribution\Distribution\Module\DistributionModule;
use common\logic\Feature\Feature\Model\Feature;
use common\logic\Feature\Feature\Module\FeatureModule;
use common\logic\User\User\Module\UserModule;
use common\logic\User\UserGroup\Module\UserGroupModule;
use yii\helpers\Html;
@@ -53,6 +55,7 @@ use yii\helpers\ArrayHelper;
$userModule = UserModule::getInstance();
$userGroupModule = UserGroupModule::getInstance();
$distributionExportManager = DistributionModule::getInstance()->getExportManager();
$featureManager = FeatureModule::getInstance()->getManager();

$userCurrent = GlobalParam::getCurrentUser();

@@ -350,21 +353,27 @@ $this->addBreadcrumb($this->getTitle());
<?= $form->field($model, 'option_check_by_default_prevent_user_credit')
->dropDownList(Dropdown::noYesChoices()); ?>

<h4>Paiement en ligne</h4>
<?= $form->field($model, 'online_payment')
->dropDownList(Dropdown::noYesChoices()); ?>
<?= $form->field($model, 'option_online_payment_minimum_amount')
->hint('Valeur par défaut si non défini : ' . Producer::ONLINE_PAYMENT_MINIMUM_AMOUNT_DEFAULT . ' €')
->textInput(); ?>
<?= $form->field($model, 'option_stripe_mode_test')->dropDownList(Dropdown::noYesChoices()); ?>
<?= $form->field($model, 'option_online_payment_type')
->dropDownList([
'credit' => 'Alimentation du crédit',
'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(); ?>
<?php if($featureManager->isEnabled(Feature::ALIAS_ONLINE_PAYMENT)): ?>
<h4>Paiement en ligne</h4>
<?php if($userModule->getAuthorizationChecker()->isGrantedAsAdministrator($userCurrent)): ?>
<?= $form->field($model, 'online_payment')
->dropDownList(Dropdown::noYesChoices()); ?>

<?= $form->field($model, 'option_stripe_mode_test')->dropDownList(Dropdown::noYesChoices()); ?>
<?= $form->field($model, 'option_online_payment_type')
->dropDownList([
'credit' => 'Alimentation du crédit',
'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(); ?>
<?php endif; ?>

<?= $form->field($model, 'option_online_payment_minimum_amount')
->hint('Valeur par défaut si non défini : ' . Producer::ONLINE_PAYMENT_MINIMUM_AMOUNT_DEFAULT . ' €')
->textInput(); ?>
<?php endif; ?>
</div>
</div>


+ 7
- 1
backend/web/js/backend.js Просмотреть файл

@@ -464,7 +464,13 @@ function opendistrib_features_index() {
.then(function (response) {
appAlerts.alertResponse(response);
});
})
});

opendistrib_sortable_list(
'.feature-admin-index',
'.btn-position',
'feature-admin/position'
);
}

function opendistrib_datepicker() {

+ 5
- 0
common/logic/AbstractRepository.php Просмотреть файл

@@ -89,4 +89,9 @@ abstract class AbstractRepository extends AbstractService implements RepositoryI
{
return $this->createQuery();
}

public function queryDefaultAll()
{
return $this->createDefaultQuery();
}
}

+ 1
- 0
common/logic/Feature/Feature/Model/Feature.php Просмотреть файл

@@ -47,6 +47,7 @@ class Feature extends ActiveRecordCommon
{
const ALIAS_CONTACT = 'contact';
const ALIAS_PRODUCT_PRICE_IMPORT = 'product_price_import';
const ALIAS_ONLINE_PAYMENT = 'online_payment';

/**
* @inheritdoc

+ 8
- 1
common/logic/Feature/Feature/Repository/FeatureRepository.php Просмотреть файл

@@ -19,7 +19,7 @@ class FeatureRepository extends AbstractRepository
return [
self::WITH => ['featureProducers'],
self::JOIN_WITH => [],
self::ORDER_BY => '',
self::ORDER_BY => 'position ASC',
self::ATTRIBUTE_ID_PRODUCER => ''
];
}
@@ -37,4 +37,11 @@ class FeatureRepository extends AbstractRepository
->filterByAlias($alias)
->findOne();
}

public function findPaidFeatures(): array
{
return $this->createQuery()
->filterIsPaidFeature()
->find();
}
}

+ 8
- 0
common/logic/Feature/Feature/Repository/FeatureRepositoryQuery.php Просмотреть файл

@@ -19,4 +19,12 @@ class FeatureRepositoryQuery extends AbstractRepositoryQuery
$this->andWhere(['alias' => $alias]);
return $this;
}

public function filterIsPaidFeature(): self
{
$this->andWhere(['is_paid_feature' => true]);
return $this;
}


}

+ 1
- 0
common/logic/Feature/Feature/Service/FeatureDefinition.php Просмотреть файл

@@ -17,6 +17,7 @@ class FeatureDefinition extends AbstractDefinition
return [
Feature::ALIAS_CONTACT => $this->buildFeatureArray('Formulaire de contact', true, false),
Feature::ALIAS_PRODUCT_PRICE_IMPORT => $this->buildFeatureArray('Produits : import prix', true, false),
Feature::ALIAS_ONLINE_PAYMENT => $this->buildFeatureArray('Paiement en ligne', true, false),
];
}


+ 2
- 1
composer.json Просмотреть файл

@@ -37,7 +37,8 @@
"weluse/yii2-mailjet": "^0.2.0",
"ext-json": "*",
"ext-curl": "*",
"yiisoft/yii2-twig": "^2.4"
"yiisoft/yii2-twig": "^2.4",
"letyii/yii2-tinymce": "dev-master"
},
"require-dev": {
"yiisoft/yii2-codeception": "*",

+ 104
- 2
composer.lock Просмотреть файл

@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "a8cbf9ba6bfa2f0b47fba2344732ac95",
"content-hash": "95e88fd70427210dc0d1edd79d17cce1",
"packages": [
{
"name": "2amigos/yii2-chartjs-widget",
@@ -1190,6 +1190,48 @@
],
"time": "2022-09-19T18:31:07+00:00"
},
{
"name": "letyii/yii2-tinymce",
"version": "dev-master",
"source": {
"type": "git",
"url": "https://github.com/letyii/yii2-tinymce.git",
"reference": "861873f30d9e16f76239ae827f2848879f66f78f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/letyii/yii2-tinymce/zipball/861873f30d9e16f76239ae827f2848879f66f78f",
"reference": "861873f30d9e16f76239ae827f2848879f66f78f",
"shasum": ""
},
"require": {
"php": ">=5.4",
"tinymce/tinymce": ">=4",
"yiisoft/yii2": "*"
},
"default-branch": true,
"type": "library",
"autoload": {
"psr-4": {
"letyii\\tinymce\\": ""
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"description": "TinyMce for yii2 textarea",
"homepage": "https://github.com/letyii/yii2-tinymce",
"keywords": [
"tinymce",
"yii2"
],
"support": {
"issues": "https://github.com/letyii/yii2-tinymce/issues",
"source": "https://github.com/letyii/yii2-tinymce/tree/master"
},
"time": "2015-07-08T08:11:14+00:00"
},
{
"name": "linslin/yii2-curl",
"version": "1.5.0",
@@ -2546,6 +2588,65 @@
],
"time": "2022-11-03T14:55:06+00:00"
},
{
"name": "tinymce/tinymce",
"version": "6.7.2",
"source": {
"type": "git",
"url": "https://github.com/tinymce/tinymce-dist.git",
"reference": "a4c139bde17a4e8b2e84d225020cd5acc24a728a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/tinymce/tinymce-dist/zipball/a4c139bde17a4e8b2e84d225020cd5acc24a728a",
"reference": "a4c139bde17a4e8b2e84d225020cd5acc24a728a",
"shasum": ""
},
"type": "component",
"extra": {
"component": {
"scripts": [
"tinymce.js",
"plugins/*/plugin.js",
"themes/*/theme.js",
"models/*/model.js",
"icons/*/icons.js"
],
"files": [
"tinymce.min.js",
"plugins/*/plugin.min.js",
"themes/*/theme.min.js",
"models/*/model.min.js",
"skins/**",
"icons/*/icons.min.js"
]
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT-only"
],
"description": "Web based JavaScript HTML WYSIWYG editor control.",
"homepage": "https://www.tiny.cloud/",
"keywords": [
"contenteditable",
"editing",
"html",
"javascript",
"rich editor",
"rich text",
"rich text editor",
"richtext",
"rte",
"text",
"tinymce",
"wysiwyg"
],
"support": {
"source": "https://github.com/tinymce/tinymce-dist/tree/6.7.2"
},
"time": "2023-10-25T06:42:18+00:00"
},
{
"name": "twig/twig",
"version": "v3.7.1",
@@ -6669,7 +6770,8 @@
"stability-flags": {
"kartik-v/yii2-mpdf": 20,
"c006/yii2-paypal-ipn": 20,
"yurkinx/yii2-image": 20
"yurkinx/yii2-image": 20,
"letyii/yii2-tinymce": 20
},
"prefer-stable": false,
"prefer-lowest": false,

+ 1
- 0
console/commands/ImportFeaturesController.php Просмотреть файл

@@ -7,6 +7,7 @@ use yii\console\Controller;

class ImportFeaturesController extends Controller
{
// ./yii import-features/index
public function actionIndex()
{
$featureModule = FeatureModule::getInstance();

+ 25
- 0
console/migrations/m231113_073008_add_column_feature_position.php Просмотреть файл

@@ -0,0 +1,25 @@
<?php

use yii\db\Migration;

/**
* Class m231113_073008_add_column_feature_position
*/
class m231113_073008_add_column_feature_position extends Migration
{
/**
* {@inheritdoc}
*/
public function safeUp()
{
$this->addColumn('feature', 'position', $this->integer()->notNull()->defaultValue(0));
}

/**
* {@inheritdoc}
*/
public function safeDown()
{
$this->dropColumn('feature', 'position');
}
}

+ 4
- 1
frontend/controllers/SiteController.php Просмотреть файл

@@ -138,9 +138,12 @@ class SiteController extends FrontendController

public function actionService()
{
$paidFeaturesArray = $this->getFeatureModule()->getRepository()->findPaidFeatures();

return $this->render('service', [
'producerDemoAccount' => $this->getProducerModule()->findOneProducerDemoAccount(),
'dataProviderPrices' => $this->getDataProviderPrices()
'dataProviderPrices' => $this->getDataProviderPrices(),
'paidFeaturesArray' => $paidFeaturesArray
]);
}


+ 7
- 6
frontend/views/site/_prices_producer.php Просмотреть файл

@@ -36,7 +36,9 @@
* termes.
*/

use common\helpers\Price;
use yii\grid\GridView;
use yii\helpers\Html;

?>

@@ -89,16 +91,15 @@ GridView::widget([
</tr>
</thead>
<tbody>
<?php foreach($paidFeaturesArray as $paidFeature): ?>
<tr>
<td>
<strong>Paiement en ligne</strong><br>
<p>Le paiement en ligne permet à vos clients d'alimenter leur crédit (compte prépayé en ligne) par carte bancaire.<br>
Le logiciel fonctionne avec la plateforme <a href="https://stripe.com/fr">Stripe</a> pour accepter les paiements.<br>
<a href="https://stripe.com/fr/pricing">Voir les tarifs Stripe</a>
</p>
<div><strong><?= Html::encode($paidFeature->name) ?></strong></div>
<div><?= $paidFeature->description ?></div>
</td>
<td>120 €</td>
<td><?= Price::format($paidFeature->price, 0) ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>


+ 4
- 1
frontend/views/site/service.php Просмотреть файл

@@ -140,7 +140,10 @@ $this->setIcon('console');
</h2>
</div>
<div class="panel-body">
<?= $this->render('_prices_producer', ['dataProviderPrices' => $dataProviderPrices]); ?>
<?= $this->render('_prices_producer', [
'dataProviderPrices' => $dataProviderPrices,
'paidFeaturesArray' => $paidFeaturesArray
]); ?>
</div>
</div>


+ 131
- 125
producer/controllers/CreditController.php Просмотреть файл

@@ -40,6 +40,7 @@ namespace producer\controllers;

use common\helpers\GlobalParam;
use common\helpers\MeanPayment;
use common\logic\Feature\Feature\Model\Feature;
use common\logic\Payment\Model\Payment;
use producer\models\CreditForm;
use yii\filters\VerbFilter;
@@ -108,12 +109,14 @@ class CreditController extends ProducerBaseController

public function actionAdd()
{
$featureManager = $this->getFeatureModule()->getManager();
$producer = $this->getProducerCurrent();
if (\Yii::$app->user->isGuest) {
return $this->redirect($this->getUrlManagerFrontend()->createAbsoluteUrl(['site/producer', 'id' => $producer->id]));
}

if ($producer->online_payment || $producer->option_stripe_mode_test) {
if ($featureManager->isEnabled(Feature::ALIAS_ONLINE_PAYMENT)
&& ($producer->online_payment || $producer->option_stripe_mode_test)) {

$creditForm = new CreditForm;

@@ -132,7 +135,7 @@ class CreditController extends ProducerBaseController
'product_data' => [
'name' => 'Alimentation crédit',
],
'unit_amount' => (float) $creditForm->amount * 100,
'unit_amount' => (float)$creditForm->amount * 100,
],
'quantity' => 1,
]
@@ -180,153 +183,156 @@ class CreditController extends ProducerBaseController
$paymentManager = $this->getPaymentModule();
$producerModule = $this->getProducerModule();
$userModule = $this->getUserModule();
$producer = $this->getProducerCurrent();
$contactProducer = $producerModule->getMainContact($producer);

$payload = @file_get_contents('php://input');
$sig_header = $_SERVER['HTTP_STRIPE_SIGNATURE'];

try {
$event = \Stripe\Webhook::constructEvent(
$payload,
$sig_header,
$producerModule->getPrivateKeyEndpointStripe($producer)
);
} catch (\UnexpectedValueException $e) {
// Invalid payload
http_response_code(400);
exit();
} catch (\Stripe\Exception\SignatureVerificationException $e) {
// Invalid signature
http_response_code(400);
exit();
}
$featureManager = $this->getFeatureModule()->getManager();

$paymentIntent = $event->data->object;
$paymentIntentMetadata = $paymentIntent->metadata;
$amount = $paymentIntent->amount / 100;
$idUser = $paymentIntentMetadata->user_id;
if ($featureManager->isEnabled(Feature::ALIAS_ONLINE_PAYMENT)) {
$producer = $this->getProducerCurrent();
$contactProducer = $producerModule->getMainContact($producer);

if($idUser) {
$user = $userModule->findOneUserById($idUser);
$payload = @file_get_contents('php://input');
$sig_header = $_SERVER['HTTP_STRIPE_SIGNATURE'];

if (isset($paymentIntentMetadata->order_id)) {
$order = $this->getOrderModule()->findOneOrderById($paymentIntentMetadata->order_id);
$orderModule->initOrder($order);
$pointSale = $this->getPointSaleModule()->findOnePointSaleById($order->id_point_sale);
$distribution = $this-> getDistributionModule()->findOneDistributionById($order->id_distribution);
try {
$event = \Stripe\Webhook::constructEvent(
$payload,
$sig_header,
$producerModule->getPrivateKeyEndpointStripe($producer)
);
} catch (\UnexpectedValueException $e) {
// Invalid payload
http_response_code(400);
exit();
} catch (\Stripe\Exception\SignatureVerificationException $e) {
// Invalid signature
http_response_code(400);
exit();
}

// Handle the event
switch ($event->type) {
case 'charge.succeeded':
$paymentIntent = $event->data->object;
$paymentIntentMetadata = $paymentIntent->metadata;
$amount = $paymentIntent->amount / 100;
$idUser = $paymentIntentMetadata->user_id;

$paymentExist = Payment::searchOne([
'id_user' => $idUser,
'amount' => $amount,
], [
'conditions' => [
'date > DATE_SUB(NOW(), INTERVAL 1 MINUTE)'
]
]);
if ($idUser) {
$user = $userModule->findOneUserById($idUser);

if (!$paymentExist) {
if (isset($paymentIntentMetadata->order_id)) {
$order = $this->getOrderModule()->findOneOrderById($paymentIntentMetadata->order_id);
$orderModule->initOrder($order);
$pointSale = $this->getPointSaleModule()->findOnePointSaleById($order->id_point_sale);
$distribution = $this->getDistributionModule()->findOneDistributionById($order->id_distribution);
}

$paymentManager->creditUser($user, $amount, MeanPayment::CREDIT_CARD, $user);
// Handle the event
switch ($event->type) {
case 'charge.succeeded':

if (isset($order) && $order) {
$paymentExist = Payment::searchOne([
'id_user' => $idUser,
'amount' => $amount,
], [
'conditions' => [
'date > DATE_SUB(NOW(), INTERVAL 1 MINUTE)'
]
]);

if (!$paymentExist) {

$paymentManager->creditUser($user, $amount, MeanPayment::CREDIT_CARD, $user);

if (isset($order) && $order) {

$paymentManager->payOrder($order, MeanPayment::CREDIT_CARD, $user, true);


// client : envoi d'un email de confirmation de paiement
/*\Yii::$app->mailerService->sendFromProducer(
'Confirmation de commande',
'paymentOrderConfirm',
[
'amount' => $amount,
'user' => $user,
'producer' => $producer,
],
$user->email,
$producer
);*/

// producteur : mail de confirmation
\Yii::$app->mailerService->sendFromSite(
'Confirmation de commande',
'orderConfirmProducer',
[
'order' => $order,
'pointSale' => $pointSale,
'distribution' => $distribution,
'user' => $user,
'producer' => $producer
],
$contactProducer->email
);
} else {
$userProducer = $this->getUserProducerModule()->findOneUserProducer($user);

\Yii::$app->mailerService->sendFromProducer(
'Alimentation de votre crédit',
'creditConfirm',
[
'user' => $user,
'userProducer' => $userProducer,
'producer' => $producer,
'amount' => $amount,
],
$user->email,
$producer
);
}
}

$paymentManager->payOrder($order, MeanPayment::CREDIT_CARD, $user, true);
break;

case 'charge.failed':

// client : envoi d'un email de confirmation de paiement
/*\Yii::$app->mailerService->sendFromProducer(
'Confirmation de commande',
'paymentOrderConfirm',
[
'amount' => $amount,
'user' => $user,
'producer' => $producer,
],
$user->email,
$producer
);*/
// client
\Yii::$app->mailerService->sendFromProducer(
'Erreur de paiement',
'paymentError',
[
'amount' => $amount,
'user' => $user,
'producer' => $producer,
],
$user->email,
$producer
);

// producteur : mail de confirmation
// producteur
if (isset($order) && $order) {
\Yii::$app->mailerService->sendFromSite(
'Confirmation de commande',
'orderConfirmProducer',
[
'order' => $order,
'pointSale' => $pointSale,
'distribution' => $distribution,
'user' => $user,
'producer' => $producer
],
$contactProducer->email
);
} else {
$userProducer = $this->getUserProducerModule()->findOneUserProducer($user);

\Yii::$app->mailerService->sendFromProducer(
'Alimentation de votre crédit',
'creditConfirm',
'Erreur de paiement',
'paymentErrorProducer',
[
'amount' => $amount,
'user' => $user,
'userProducer' => $userProducer,
'producer' => $producer,
'amount' => $amount,
'order' => $order,
'distribution' => $distribution
],
$user->email,
$producer
$contactProducer->email,
);
}
}

break;

case 'charge.failed':

// client
\Yii::$app->mailerService->sendFromProducer(
'Erreur de paiement',
'paymentError',
[
'amount' => $amount,
'user' => $user,
'producer' => $producer,
],
$user->email,
$producer
);

// producteur
if (isset($order) && $order) {
\Yii::$app->mailerService->sendFromSite(
'Erreur de paiement',
'paymentErrorProducer',
[
'amount' => $amount,
'user' => $user,
'producer' => $producer,
'order' => $order,
'distribution' => $distribution
],
$contactProducer->email,
);
}
break;

break;
// handle other event types
default:
echo 'Received unknown event type ' . $event->type;
}

// handle other event types
default:
echo 'Received unknown event type ' . $event->type;
http_response_code(200);
} else {
http_response_code(200);
}

http_response_code(200);
}
else {
http_response_code(200);
}

die();

+ 4
- 1
producer/views/credit/history.php Просмотреть файл

@@ -36,15 +36,18 @@
* termes.
*/

use common\logic\Feature\Feature\Model\Feature;
use common\logic\Feature\Feature\Module\FeatureModule;
use common\logic\Payment\Module\PaymentModule;
use yii\grid\GridView;

$paymentManager = PaymentModule::getInstance();
$featureManager = FeatureModule::getInstance();
$producer = $this->context->getProducerCurrent();
$this->setTitle('Crédit : <span id="credit-user">' . number_format($creditUser, 2) . ' €</span>');
$this->setPageTitle('Crédit');

if ($this->context->getProducerCurrent()->online_payment) {
if ($featureManager->isEnabled(Feature::ALIAS_ONLINE_PAYMENT) && $this->context->getProducerCurrent()->online_payment) {
$this->addButton(
[
'label' => '<span class="glyphicon glyphicon-credit-card"></span> Créditer mon compte',

Загрузка…
Отмена
Сохранить