Browse Source

Merge branch 'dev'

master
Guillaume 3 years ago
parent
commit
bc3bf99026
7 changed files with 881 additions and 744 deletions
  1. +10
    -0
      backend/views/producer/update.php
  2. +3
    -1
      common/models/Producer.php
  3. +20
    -0
      console/migrations/m210917_133352_add_option_online_payment_type.php
  4. +18
    -0
      producer/controllers/CreditController.php
  5. +820
    -741
      producer/controllers/OrderController.php
  6. +3
    -1
      producer/views/order/order.php
  7. +7
    -1
      producer/web/js/vuejs/order-order.js

+ 10
- 0
backend/views/producer/update.php View File

'template' => '{label}<div class="input-group">{input}<span class="input-group-addon"><span class="glyphicon glyphicon-euro"></span></span></div>{hint}', 'template' => '{label}<div class="input-group">{input}<span class="input-group-addon"><span class="glyphicon glyphicon-euro"></span></span></div>{hint}',
])->hint('Limite de crédit que l\'utilisateur ne pourra pas dépasser. Laisser vide pour permettre un crédit négatif et infini.'); ?> ])->hint('Limite de crédit que l\'utilisateur ne pourra pas dépasser. Laisser vide pour permettre un crédit négatif et infini.'); ?>


<br />
<h3>Paiement en ligne</h3>

<?= $form->field($model, 'online_payment') <?= $form->field($model, 'online_payment')
->dropDownList([ ->dropDownList([
0 => 'Non', 0 => 'Non',
0 => 'Non', 0 => 'Non',
1 => 'Oui' 1 => 'Oui'
], []); ?> ], []); ?>

<?= $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_public_key')->textInput(); ?>
<?= $form->field($model, 'option_stripe_private_key')->textInput(); ?> <?= $form->field($model, 'option_stripe_private_key')->textInput(); ?>
<?= $form->field($model, 'option_stripe_endpoint_secret')->textInput(); ?> <?= $form->field($model, 'option_stripe_endpoint_secret')->textInput(); ?>

+ 3
- 1
common/models/Producer.php View File

'option_order_entry_point', 'option_order_entry_point',
'option_stripe_public_key', 'option_stripe_public_key',
'option_stripe_private_key', 'option_stripe_private_key',
'option_stripe_endpoint_secret'
'option_stripe_endpoint_secret',
'option_online_payment_type'
], ],
'string' 'string'
], ],
'type' => 'Type de producteur', 'type' => 'Type de producteur',
'credit_limit_reminder' => 'Seuil de crédit limite avant relance', 'credit_limit_reminder' => 'Seuil de crédit limite avant relance',
'online_payment' => 'Activer le paiement en ligne (Stripe)', 'online_payment' => 'Activer le paiement en ligne (Stripe)',
'option_online_payment_type' => 'Type de paiement',
'option_stripe_mode_test' => 'Mode test', 'option_stripe_mode_test' => 'Mode test',
'option_stripe_public_key' => 'Clé publique', 'option_stripe_public_key' => 'Clé publique',
'option_stripe_private_key' => 'Clé secrète', 'option_stripe_private_key' => 'Clé secrète',

+ 20
- 0
console/migrations/m210917_133352_add_option_online_payment_type.php View File

<?php

use yii\db\Migration;
use yii\db\Schema;

/**
* Class m210917_133352_add_option_online_payment_type
*/
class m210917_133352_add_option_online_payment_type extends Migration
{
public function safeUp()
{
$this->addColumn('producer', 'option_online_payment_type', Schema::TYPE_STRING.' DEFAULT \'credit\'');
}

public function safeDown()
{
$this->dropColumn('producer', 'option_online_payment_type');
}
}

+ 18
- 0
producer/controllers/CreditController.php View File



namespace producer\controllers; namespace producer\controllers;


use common\helpers\GlobalParam;
use common\helpers\Mailjet; use common\helpers\Mailjet;
use common\helpers\MeanPayment; use common\helpers\MeanPayment;
use common\models\CreditHistory; use common\models\CreditHistory;
use common\models\Order;
use common\models\UserProducer; use common\models\UserProducer;
use producer\models\CreditForm; use producer\models\CreditForm;
use common\models\User; use common\models\User;
$creditHistory->mean_payment = MeanPayment::CREDIT_CARD; $creditHistory->mean_payment = MeanPayment::CREDIT_CARD;
$creditHistory->save(); $creditHistory->save();


if(isset($paymentIntentMetadata->order_id)) {
$order = Order::searchOne([
'id' => $paymentIntentMetadata->order_id
]);

if($order) {
$order->saveCreditHistory(
CreditHistory::TYPE_DEBIT,
$amount,
$idProducer,
$order->id_user,
$order->id_user
);
}
}

// envoi d'un email de confirmation // envoi d'un email de confirmation
$user = User::findOne($paymentIntentMetadata->user_id); $user = User::findOne($paymentIntentMetadata->user_id);
$userProducer = UserProducer::find() $userProducer = UserProducer::find()

+ 820
- 741
producer/controllers/OrderController.php
File diff suppressed because it is too large
View File


+ 3
- 1
producer/views/order/order.php View File

<span class="glyphicon glyphicon-chevron-right"></span> <span class="glyphicon glyphicon-chevron-right"></span>
<?php if($producer->option_payment_info && strlen($producer->option_payment_info) > 0): ?> <?php if($producer->option_payment_info && strlen($producer->option_payment_info) > 0): ?>
Confirmez votre commande et retrouvez les informations liées au paiement sur la page suivante. Confirmez votre commande et retrouvez les informations liées au paiement sur la page suivante.
<?php elseif($producer->online_payment && $producer->option_online_payment_type == 'order'): ?>
La commande est à payer en ligne lors de l'étape suivante.
<?php else: ?> <?php else: ?>
La commande sera à régler sur place. La commande sera à régler sur place.
<?php endif; ?> <?php endif; ?>
</div> </div>
</div> </div>


<div v-if="producer.online_payment" id="credit-online-payment">
<div v-if="producer.online_payment && producer.option_online_payment_type == 'credit'" id="credit-online-payment">
<div class="panel panel-default"> <div class="panel panel-default">
<div class="panel-heading"> <div class="panel-heading">
<i class="glyphicon glyphicon-euro"></i> Paiement en ligne <i class="glyphicon glyphicon-euro"></i> Paiement en ligne

+ 7
- 1
producer/web/js/vuejs/order-order.js View File

}).then(function(response) { }).then(function(response) {
if(response.data.status == 'success') { if(response.data.status == 'success') {
app.errors = [] ; app.errors = [] ;
window.location.href = opendistrib_base_url(true)+'order/confirm?idOrder='+response.data.idOrder ;

if(response.data.redirect && response.data.redirect.length > 0) {
window.location.href = response.data.redirect ;
}
else {
window.location.href = opendistrib_base_url(true)+'order/confirm?idOrder='+response.data.idOrder ;
}
} }
else { else {
app.errors = response.data.errors ; app.errors = response.data.errors ;

Loading…
Cancel
Save