Browse Source

Merge branch 'dev'

prodstable
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

@@ -363,6 +363,9 @@ $this->addBreadcrumb($this->getTitle()) ;
'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.'); ?>

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

<?= $form->field($model, 'online_payment')
->dropDownList([
0 => 'Non',
@@ -372,6 +375,13 @@ $this->addBreadcrumb($this->getTitle()) ;
0 => 'Non',
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_private_key')->textInput(); ?>
<?= $form->field($model, 'option_stripe_endpoint_secret')->textInput(); ?>

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

@@ -204,7 +204,8 @@ class Producer extends ActiveRecordCommon
'option_order_entry_point',
'option_stripe_public_key',
'option_stripe_private_key',
'option_stripe_endpoint_secret'
'option_stripe_endpoint_secret',
'option_online_payment_type'
],
'string'
],
@@ -309,6 +310,7 @@ class Producer extends ActiveRecordCommon
'type' => 'Type de producteur',
'credit_limit_reminder' => 'Seuil de crédit limite avant relance',
'online_payment' => 'Activer le paiement en ligne (Stripe)',
'option_online_payment_type' => 'Type de paiement',
'option_stripe_mode_test' => 'Mode test',
'option_stripe_public_key' => 'Clé publique',
'option_stripe_private_key' => 'Clé secrète',

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

@@ -0,0 +1,20 @@
<?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

@@ -38,9 +38,11 @@

namespace producer\controllers;

use common\helpers\GlobalParam;
use common\helpers\Mailjet;
use common\helpers\MeanPayment;
use common\models\CreditHistory;
use common\models\Order;
use common\models\UserProducer;
use producer\models\CreditForm;
use common\models\User;
@@ -231,6 +233,22 @@ class CreditController extends ProducerBaseController
$creditHistory->mean_payment = MeanPayment::CREDIT_CARD;
$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
$user = User::findOne($paymentIntentMetadata->user_id);
$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

@@ -400,6 +400,8 @@ $producer = GlobalParam::getCurrentProducer() ;
<span class="glyphicon glyphicon-chevron-right"></span>
<?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.
<?php elseif($producer->online_payment && $producer->option_online_payment_type == 'order'): ?>
La commande est à payer en ligne lors de l'étape suivante.
<?php else: ?>
La commande sera à régler sur place.
<?php endif; ?>
@@ -456,7 +458,7 @@ $producer = GlobalParam::getCurrentProducer() ;
</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-heading">
<i class="glyphicon glyphicon-euro"></i> Paiement en ligne

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

@@ -493,7 +493,13 @@ var app = new Vue({
}).then(function(response) {
if(response.data.status == 'success') {
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 {
app.errors = response.data.errors ;

Loading…
Cancel
Save