When a Paybox callback confirms payment on an order with status 4 (Annulé), the payment is still recorded but the order status is no longer forced to « Préparation ». Instead, an alert email is sent to ``commande@jardinenvie.com`` warning that a refund is likely needed. New ``AlertePaiementAnnule`` mailable with DB template providing order ref, amount, customer info and payment reference. New method ``OrderMails::sendCancelledOrderPaymentAlert()`` handles the dispatch.
52 lines
1.3 KiB
PHP
52 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Mail;
|
|
|
|
use App\Models\Core\Mail\MailTemplate;
|
|
use Illuminate\Bus\Queueable;
|
|
use Illuminate\Mail\Mailables\Address;
|
|
use Illuminate\Mail\Mailables\Envelope;
|
|
use Illuminate\Queue\SerializesModels;
|
|
use Spatie\MailTemplates\TemplateMailable;
|
|
|
|
class AlertePaiementAnnule extends TemplateMailable
|
|
{
|
|
use Queueable, SerializesModels;
|
|
|
|
public $subject;
|
|
|
|
public $numero_commande;
|
|
|
|
public $date_commande;
|
|
|
|
public $montant;
|
|
|
|
public $client_nom;
|
|
|
|
public $client_email;
|
|
|
|
public $reference_paiement;
|
|
|
|
protected static $templateModelClass = MailTemplate::class;
|
|
|
|
public function __construct($order, $reference)
|
|
{
|
|
$this->numero_commande = $order->ref;
|
|
$this->date_commande = $order->created_at->format('d/m/Y H:i');
|
|
$this->montant = number_format($order->total_shipped, 2, ',', ' ').' €';
|
|
$this->client_nom = $order->customer
|
|
? $order->customer->last_name.' '.$order->customer->first_name
|
|
: 'Client supprimé';
|
|
$this->client_email = $order->customer->email ?? 'inconnu';
|
|
$this->reference_paiement = $reference;
|
|
}
|
|
|
|
public function envelope()
|
|
{
|
|
return new Envelope(
|
|
from: new Address('boutique@jardinenvie.com', 'Jardin\'en\'Vie'),
|
|
subject: $this->subject,
|
|
);
|
|
}
|
|
}
|