Compare commits
10 Commits
1.0.0-rc.1
...
1.0.0-rc.3
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f094411f10 | ||
|
|
ccc477f291 | ||
|
|
7217d945a3 | ||
|
|
9185269874 | ||
|
|
e42e3b4c0d | ||
|
|
a7ae946797 | ||
|
|
7a189abf0b | ||
|
|
34fc1c33bf | ||
|
|
61e34b4f4e | ||
|
|
7fe2770d45 |
@@ -93,7 +93,8 @@ RUN mkdir -p /out \
|
||||
--exclude=.editorconfig --exclude=phpunit.xml \
|
||||
--exclude=.travis.yml --exclude=composer.lock --exclude=.styleci.yml \
|
||||
--exclude=Makefile --exclude=.gitkeep --exclude=test \
|
||||
artisan app build config database vendor public resources routes stubs bootstrap storage composer.json \
|
||||
--exclude=resources/shop \
|
||||
artisan app config database vendor public resources routes stubs bootstrap storage composer.json \
|
||||
&& xz -T0 -9e /out/app.tar \
|
||||
&& mv /out/app.tar.xz /out/opensem-prod.tar.xz
|
||||
|
||||
|
||||
48
Gruntfile.js
@@ -19,8 +19,8 @@ var jsSite = [
|
||||
jsBootstrap,
|
||||
'node_modules/jquery-serializejson/jquery.serializejson.min.js',
|
||||
'node_modules/currency.js/dist/currency.min.js',
|
||||
'build/js/plugins/smooth_products/js/smoothproducts.min.js',
|
||||
'build/js/site.js',
|
||||
'resources/shop/js/plugins/smooth_products/js/smoothproducts.min.js',
|
||||
'resources/shop/js/site.js',
|
||||
]
|
||||
|
||||
var cssSite = [
|
||||
@@ -28,8 +28,8 @@ var cssSite = [
|
||||
'node_modules/@fortawesome/fontawesome-free/css/all.min.css',
|
||||
'node_modules/animate.css/animate.min.css',
|
||||
'node_modules/icheck-bootstrap/icheck-bootstrap.min.css',
|
||||
'build/js/plugins/smooth_products/css/smoothproducts.css',
|
||||
'build/css/site.css',
|
||||
'resources/shop/js/plugins/smooth_products/css/smoothproducts.css',
|
||||
'resources/shop/css/site.css',
|
||||
]
|
||||
|
||||
var jsAdminLTE = [
|
||||
@@ -41,15 +41,15 @@ var jsAdminLTE = [
|
||||
]
|
||||
|
||||
var jsCoreInclude = [
|
||||
'build/js/include/core/objectLength.js',
|
||||
'build/js/include/core/url.js',
|
||||
'build/js/include/core/user.js',
|
||||
'build/js/include/form/radio.js',
|
||||
'build/js/include/form/upload.js',
|
||||
'build/js/include/form/validator.js',
|
||||
'build/js/include/layout/animate.js',
|
||||
'build/js/include/layout/scroll.js',
|
||||
'build/js/include/layout/tooltip.js',
|
||||
'resources/shop/js/include/core/objectLength.js',
|
||||
'resources/shop/js/include/core/url.js',
|
||||
'resources/shop/js/include/core/user.js',
|
||||
'resources/shop/js/include/form/radio.js',
|
||||
'resources/shop/js/include/form/upload.js',
|
||||
'resources/shop/js/include/form/validator.js',
|
||||
'resources/shop/js/include/layout/animate.js',
|
||||
'resources/shop/js/include/layout/scroll.js',
|
||||
'resources/shop/js/include/layout/tooltip.js',
|
||||
]
|
||||
|
||||
var jsBundle = [
|
||||
@@ -84,7 +84,7 @@ var jsMain = [
|
||||
var cssPrint = [
|
||||
// 'node_modules/bootstrap/dist/css/bootstrap.min.css',
|
||||
'cssIcons',
|
||||
'build/print.css'
|
||||
'resources/shop/print.css'
|
||||
]
|
||||
|
||||
var cssBundle = [
|
||||
@@ -109,7 +109,7 @@ var cssIcons = [
|
||||
var cssMain = [
|
||||
cssBundle,
|
||||
cssIcons,
|
||||
'build/css/main.css',
|
||||
'resources/shop/css/main.css',
|
||||
]
|
||||
|
||||
var jsDataTables = [
|
||||
@@ -251,31 +251,31 @@ module.exports = function(grunt) {
|
||||
},
|
||||
{
|
||||
expand: true,
|
||||
cwd: 'build/fonts',
|
||||
cwd: 'resources/shop/fonts',
|
||||
src: ['**'],
|
||||
dest: 'public/fonts/'
|
||||
},
|
||||
{
|
||||
expand: true,
|
||||
cwd: 'build/img',
|
||||
cwd: 'resources/shop/img',
|
||||
src: ['**'],
|
||||
dest: 'public/img/'
|
||||
},
|
||||
{
|
||||
expand: true,
|
||||
cwd: 'build/lang',
|
||||
cwd: 'resources/shop/lang',
|
||||
src: ['**'],
|
||||
dest: 'public/assets/lang/'
|
||||
},
|
||||
{
|
||||
expand: true,
|
||||
cwd: 'build/plugins',
|
||||
cwd: 'resources/shop/plugins',
|
||||
src: ['**'],
|
||||
dest: 'public/assets/plugins/'
|
||||
},
|
||||
{
|
||||
expand: true,
|
||||
cwd: 'build/assets/tpl',
|
||||
cwd: 'resources/shop/assets/tpl',
|
||||
src: ['**'],
|
||||
dest: 'public/assets/tpl/'
|
||||
},
|
||||
@@ -395,7 +395,7 @@ module.exports = function(grunt) {
|
||||
},
|
||||
{
|
||||
expand: true,
|
||||
cwd: 'build/plugins/pdfjs/',
|
||||
cwd: 'resources/shop/plugins/pdfjs/',
|
||||
src: ['**'],
|
||||
dest: 'public/assets/plugins/pdfjs',
|
||||
},
|
||||
@@ -461,7 +461,7 @@ module.exports = function(grunt) {
|
||||
},
|
||||
{
|
||||
expand: true,
|
||||
cwd: 'build/js/include/plugins/datatables_lang/',
|
||||
cwd: 'resources/shop/js/include/plugins/datatables_lang/',
|
||||
src: ['*.json'],
|
||||
dest: 'public/assets/plugins/datatables_lang',
|
||||
},
|
||||
@@ -539,7 +539,7 @@ module.exports = function(grunt) {
|
||||
},
|
||||
{
|
||||
expand: true,
|
||||
cwd: 'build/js/include/',
|
||||
cwd: 'resources/shop/js/include/',
|
||||
src: ['boilerplate.js'],
|
||||
dest: 'public/assets/plugins',
|
||||
},
|
||||
@@ -548,7 +548,7 @@ module.exports = function(grunt) {
|
||||
},
|
||||
watch: {
|
||||
dist: {
|
||||
files: ['build/js/*', 'build/css/*'],
|
||||
files: ['resources/shop/js/*', 'resources/shop/css/*'],
|
||||
// tasks: ['concat', 'copy']
|
||||
tasks: ['concat']
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace App\Http\Controllers\Shop;
|
||||
use App\Repositories\Shop\CustomerAddresses;
|
||||
use App\Repositories\Shop\Customers;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
|
||||
class CustomerController extends Controller
|
||||
{
|
||||
@@ -56,10 +57,89 @@ class CustomerController extends Controller
|
||||
return redirect()->route('Shop.Customers.edit');
|
||||
}
|
||||
|
||||
public function storeAddress(Request $request)
|
||||
{
|
||||
if (Customers::isNotConnected()) {
|
||||
return response()->json(['message' => __('Authentification requise.')], 403);
|
||||
}
|
||||
|
||||
$prefix = $request->input('prefix');
|
||||
$types = ['deliveries' => 1, 'invoices' => 2];
|
||||
|
||||
if (! array_key_exists($prefix, $types)) {
|
||||
return response()->json(['message' => __('Type d\'adresse inconnu.')], 422);
|
||||
}
|
||||
|
||||
$addressData = $request->input($prefix, []);
|
||||
|
||||
$validator = Validator::make($addressData, [
|
||||
'name' => ['nullable', 'string', 'max:150'],
|
||||
'address' => ['required', 'string', 'max:255'],
|
||||
'address2' => ['nullable', 'string', 'max:255'],
|
||||
'zipcode' => ['required', 'string', 'max:30'],
|
||||
'city' => ['required', 'string', 'max:255'],
|
||||
], [
|
||||
'address.required' => __('Merci de renseigner l\'adresse.'),
|
||||
'zipcode.required' => __('Merci de renseigner le code postal.'),
|
||||
'city.required' => __('Merci de renseigner la ville.'),
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
return response()->json([
|
||||
'message' => __('Merci de vérifier les informations saisies.'),
|
||||
'errors' => $validator->errors(),
|
||||
], 422);
|
||||
}
|
||||
|
||||
$data = $validator->validated();
|
||||
$customerId = Customers::getId();
|
||||
$data['customer_id'] = $customerId;
|
||||
$data['type'] = $types[$prefix];
|
||||
|
||||
if (empty($data['name'])) {
|
||||
$data['name'] = Customers::getName($customerId);
|
||||
}
|
||||
|
||||
$address = CustomerAddresses::store($data);
|
||||
CustomerAddresses::setDefault($customerId, $address->id, $types[$prefix]);
|
||||
|
||||
$html = view('Shop.Customers.partials.address_item', [
|
||||
'address' => $address->toArray(),
|
||||
'prefix' => $prefix,
|
||||
'with_name' => true,
|
||||
'selected' => $address->id,
|
||||
])->render();
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'html' => $html,
|
||||
'message' => __('Adresse enregistrée.'),
|
||||
'id' => $address->id,
|
||||
]);
|
||||
}
|
||||
|
||||
public function delete_address($id)
|
||||
{
|
||||
$ret = CustomerAddresses::destroy($id);
|
||||
$address = CustomerAddresses::get($id);
|
||||
|
||||
return redirect()->route('Shop.Customers.edit');
|
||||
if (! $address || (int) $address->customer_id !== (int) Customers::getId()) {
|
||||
abort(404);
|
||||
}
|
||||
|
||||
$remaining = CustomerAddresses::getModel()
|
||||
->byCustomer($address->customer_id)
|
||||
->byType($address->type)
|
||||
->count();
|
||||
|
||||
if ($remaining <= 1) {
|
||||
return redirect()->route('Shop.Customers.edit')
|
||||
->with('growl', [__('Vous devez conserver au moins une adresse par type.'), 'warning']);
|
||||
}
|
||||
|
||||
CustomerAddresses::destroy($id);
|
||||
CustomerAddresses::ensureDefault($address->customer_id, $address->type);
|
||||
|
||||
return redirect()->route('Shop.Customers.edit')
|
||||
->with('growl', [__('Adresse supprimée.'), 'success']);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,9 @@ class InvoiceController extends Controller
|
||||
|
||||
public function pdf($uuid)
|
||||
{
|
||||
\Debugbar::disable();
|
||||
if (app()->bound('debugbar')) {
|
||||
app('debugbar')->disable();
|
||||
}
|
||||
|
||||
return InvoicePDF::getByUUID($uuid);
|
||||
}
|
||||
|
||||
@@ -3,13 +3,19 @@
|
||||
namespace App\Http\Controllers\Shop;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Repositories\Core\User\ShopCart;
|
||||
use App\Repositories\Shop\Paybox as PayboxGateway;
|
||||
use App\Repositories\Shop\Contents;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
|
||||
class PayboxController extends Controller
|
||||
{
|
||||
public function accepted()
|
||||
{
|
||||
ShopCart::clear();
|
||||
|
||||
return view('paybox.paybox', ['content' => Contents::getPayboxConfirmedContent()]);
|
||||
}
|
||||
|
||||
@@ -30,8 +36,20 @@ class PayboxController extends Controller
|
||||
|
||||
public function process(Request $request)
|
||||
{
|
||||
$data = $request->all();
|
||||
$invoiceId = $request->input('order_number');
|
||||
|
||||
return view('paybox.send', $data);
|
||||
if (! $invoiceId) {
|
||||
Log::warning('Paybox callback missing order_number', ['payload' => $request->all()]);
|
||||
|
||||
return response('Missing order_number', 400);
|
||||
}
|
||||
|
||||
$success = PayboxGateway::verifyPayment($invoiceId);
|
||||
|
||||
if (! $success) {
|
||||
return response('KO', 400);
|
||||
}
|
||||
|
||||
return response('OK');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,17 +12,35 @@ class CustomerAddresses
|
||||
public static function storeByCustomer($customer, $data)
|
||||
{
|
||||
$deliveries = $data['deliveries'] ?? false;
|
||||
if ($deliveries && $deliveries['zipcode'] && $deliveries['city']) {
|
||||
$deliveries['customer_id'] = $customer->id;
|
||||
$deliveries['type'] = 1;
|
||||
self::store($deliveries);
|
||||
if ($deliveries) {
|
||||
if (! empty($deliveries['address_id'])) {
|
||||
self::setDefault($customer->id, (int) $deliveries['address_id'], 1);
|
||||
}
|
||||
|
||||
if (! empty($deliveries['zipcode']) && ! empty($deliveries['city'])) {
|
||||
$payload = $deliveries;
|
||||
unset($payload['address_id']);
|
||||
$payload['customer_id'] = $customer->id;
|
||||
$payload['type'] = 1;
|
||||
$newAddress = self::store($payload);
|
||||
self::setDefault($customer->id, $newAddress->id, 1);
|
||||
}
|
||||
}
|
||||
|
||||
$invoices = $data['invoices'] ?? false;
|
||||
if ($invoices && $invoices['zipcode'] && $invoices['city']) {
|
||||
$invoices['customer_id'] = $customer->id;
|
||||
$invoices['type'] = 2;
|
||||
self::store($invoices);
|
||||
if ($invoices) {
|
||||
if (! empty($invoices['address_id'])) {
|
||||
self::setDefault($customer->id, (int) $invoices['address_id'], 2);
|
||||
}
|
||||
|
||||
if (! empty($invoices['zipcode']) && ! empty($invoices['city'])) {
|
||||
$payload = $invoices;
|
||||
unset($payload['address_id']);
|
||||
$payload['customer_id'] = $customer->id;
|
||||
$payload['type'] = 2;
|
||||
$newAddress = self::store($payload);
|
||||
self::setDefault($customer->id, $newAddress->id, 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,14 +88,24 @@ class CustomerAddresses
|
||||
|
||||
public static function getInvoiceAddress($customerId)
|
||||
{
|
||||
$addresses = CustomerAddress::byCustomer($customerId)->byInvoicing()->get();
|
||||
return count($addresses) ? $addresses->first() : self::getByCustomer($customerId);
|
||||
$address = CustomerAddress::byCustomer($customerId)
|
||||
->byInvoicing()
|
||||
->orderByDesc('priority')
|
||||
->orderBy('id')
|
||||
->first();
|
||||
|
||||
return $address ?? self::getByCustomer($customerId);
|
||||
}
|
||||
|
||||
public static function getDeliveryAddress($customerId)
|
||||
{
|
||||
$addresses = CustomerAddress::byCustomer($customerId)->byDelivery()->get();
|
||||
return count($addresses) ? $addresses->first() : self::getByCustomer($customerId);
|
||||
$address = CustomerAddress::byCustomer($customerId)
|
||||
->byDelivery()
|
||||
->orderByDesc('priority')
|
||||
->orderBy('id')
|
||||
->first();
|
||||
|
||||
return $address ?? self::getByCustomer($customerId);
|
||||
}
|
||||
|
||||
public static function getByCustomer($customerId = false)
|
||||
@@ -92,6 +120,40 @@ class CustomerAddresses
|
||||
return ((int) $type === 1) ? '<i class="fa fa-fw fa-truck"></i>' : '<i class="fa fa-fw fa-file-invoice"></i>';
|
||||
}
|
||||
|
||||
public static function setDefault($customerId, $addressId, $type)
|
||||
{
|
||||
if (! $addressId) {
|
||||
return;
|
||||
}
|
||||
|
||||
$address = self::get($addressId);
|
||||
|
||||
if (! $address || (int) $address->customer_id !== (int) $customerId || (int) $address->type !== (int) $type) {
|
||||
return;
|
||||
}
|
||||
|
||||
self::getModel()->byCustomer($customerId)->byType($type)->update(['priority' => null]);
|
||||
|
||||
$address->priority = 1;
|
||||
$address->save();
|
||||
}
|
||||
|
||||
public static function ensureDefault($customerId, $type)
|
||||
{
|
||||
$hasDefault = self::getModel()->byCustomer($customerId)->byType($type)->where('priority', 1)->exists();
|
||||
|
||||
if ($hasDefault) {
|
||||
return;
|
||||
}
|
||||
|
||||
$address = self::getModel()->byCustomer($customerId)->byType($type)->orderBy('id')->first();
|
||||
|
||||
if ($address) {
|
||||
$address->priority = 1;
|
||||
$address->save();
|
||||
}
|
||||
}
|
||||
|
||||
public static function toggleActive($id, $active)
|
||||
{
|
||||
return self::update(['active' => $active], $id);
|
||||
|
||||
@@ -6,6 +6,7 @@ use App\Datatables\Shop\CustomerInvoicesDataTable;
|
||||
use App\Datatables\Shop\CustomerOrdersDataTable;
|
||||
use App\Models\Shop\Customer;
|
||||
use App\Traits\Model\Basic;
|
||||
use App\Repositories\Shop\CustomerAddresses;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
@@ -95,6 +96,16 @@ class Customers
|
||||
$data = $customer->toArray();
|
||||
$data['sale_channels'] = $customer->sale_channels->pluck('id')->toArray();
|
||||
$data['deliveries'] = Deliveries::getBySaleChannels($data['sale_channels'])->toArray();
|
||||
$data['delivery_address_id'] = optional(CustomerAddresses::getDeliveryAddress($id))->id;
|
||||
$data['invoice_address_id'] = optional(CustomerAddresses::getInvoiceAddress($id))->id;
|
||||
|
||||
if (! $data['delivery_address_id'] && ! empty($data['delivery_addresses'])) {
|
||||
$data['delivery_address_id'] = $data['delivery_addresses'][0]['id'] ?? null;
|
||||
}
|
||||
|
||||
if (! $data['invoice_address_id'] && ! empty($data['invoice_addresses'])) {
|
||||
$data['invoice_address_id'] = $data['invoice_addresses'][0]['id'] ?? null;
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
@@ -102,8 +113,8 @@ class Customers
|
||||
public static function storeFull($data)
|
||||
{
|
||||
$data2 = $data;
|
||||
if ($data['sale_channels'] ?? false) {
|
||||
$saleChannels = $data['sale_channels'] ?? false;
|
||||
$saleChannels = array_key_exists('sale_channels', $data) ? $data['sale_channels'] : null;
|
||||
if ($saleChannels !== null) {
|
||||
unset($data['sale_channels']);
|
||||
}
|
||||
if ($data['deliveries'] ?? false) {
|
||||
@@ -113,7 +124,9 @@ class Customers
|
||||
unset($data['invoices']);
|
||||
}
|
||||
$customer = self::store($data);
|
||||
$customer->sale_channels()->sync($saleChannels);
|
||||
if ($saleChannels !== null) {
|
||||
$customer->sale_channels()->sync($saleChannels);
|
||||
}
|
||||
CustomerAddresses::storeByCustomer($customer, $data2);
|
||||
|
||||
return $customer->id;
|
||||
|
||||
@@ -2,12 +2,15 @@
|
||||
|
||||
namespace App\Repositories\Shop;
|
||||
|
||||
use App\Models\Shop\Invoice;
|
||||
use App\Models\Shop\InvoicePayment;
|
||||
use App\Repositories\Core\DateTime;
|
||||
use Bnb\PayboxGateway\Requests\Paybox\AuthorizationWithCapture;
|
||||
use Bnb\PayboxGateway\Requests\PayboxDirect\Capture;
|
||||
use Bnb\PayboxGateway\Responses\Exceptions\InvalidSignature;
|
||||
use Bnb\PayboxGateway\Responses\Paybox\Verify;
|
||||
use Illuminate\Support\Facades\App;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class Paybox
|
||||
@@ -23,17 +26,141 @@ class Paybox
|
||||
|
||||
public static function verifyPayment($invoiceId)
|
||||
{
|
||||
$invoice = Invoices::get($invoiceId);
|
||||
$payboxVerify = App::make(Verify::class);
|
||||
try {
|
||||
$success = $payboxVerify->isSuccess($invoice->total_shipped);
|
||||
if ($success) {
|
||||
// process order here after making sure it was real payment
|
||||
}
|
||||
echo 'OK';
|
||||
} catch (InvalidSignature $e) {
|
||||
Log::alert('Invalid payment signature detected');
|
||||
$invoice = Invoices::get($invoiceId, ['order']);
|
||||
|
||||
if (! $invoice) {
|
||||
Log::warning('Paybox callback received for unknown invoice', [
|
||||
'invoice_id' => $invoiceId,
|
||||
'payload' => request()->all(),
|
||||
]);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
$payboxVerify = App::make(Verify::class);
|
||||
|
||||
try {
|
||||
$isSuccessful = $payboxVerify->isSuccess($invoice->total_shipped);
|
||||
} catch (InvalidSignature $e) {
|
||||
Log::alert('Invalid payment signature detected', [
|
||||
'invoice_id' => $invoiceId,
|
||||
'payload' => request()->except('signature'),
|
||||
]);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if (! $isSuccessful) {
|
||||
Log::warning('Paybox payment verification failed', [
|
||||
'invoice_id' => $invoiceId,
|
||||
'response_code' => $payboxVerify->getResponseCode(),
|
||||
'payload' => request()->except('signature'),
|
||||
]);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return self::finalizeInvoicePayment($invoice);
|
||||
}
|
||||
|
||||
protected static function finalizeInvoicePayment(Invoice $invoice)
|
||||
{
|
||||
$order = $invoice->order;
|
||||
|
||||
if (! $order) {
|
||||
Log::error('Paybox payment cannot be finalized: missing related order', [
|
||||
'invoice_id' => $invoice->id,
|
||||
]);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
$request = request();
|
||||
$referenceParts = array_filter([
|
||||
$request->input('call_number'),
|
||||
$request->input('transaction_number'),
|
||||
]);
|
||||
$reference = $referenceParts ? implode('-', $referenceParts) : $request->input('authorization_number');
|
||||
if (! $reference) {
|
||||
$reference = 'paybox-'.$invoice->id;
|
||||
}
|
||||
|
||||
$payload = $request->except('signature');
|
||||
$existingPayment = InvoicePayment::where('invoice_id', $invoice->id)
|
||||
->where('reference', $reference)
|
||||
->first();
|
||||
$shouldNotify = false;
|
||||
$validatedTotal = InvoicePayment::where('invoice_id', $invoice->id)
|
||||
->validated()
|
||||
->sum('amount');
|
||||
|
||||
if (! $existingPayment && (float) $validatedTotal >= (float) $invoice->total_shipped) {
|
||||
Log::info('Paybox payment ignored: invoice already fully settled', [
|
||||
'invoice_id' => $invoice->id,
|
||||
'order_id' => $order->id,
|
||||
'reference' => $reference,
|
||||
]);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
DB::transaction(function () use ($invoice, $order, $reference, $payload, $existingPayment, &$shouldNotify) {
|
||||
$attributes = [
|
||||
'payment_type' => 1,
|
||||
'amount' => $invoice->total_shipped,
|
||||
'date' => DateTime::getDate(),
|
||||
'data' => json_encode($payload, JSON_UNESCAPED_UNICODE),
|
||||
'validated' => 1,
|
||||
];
|
||||
|
||||
if ($existingPayment) {
|
||||
$previousValidationState = (int) ($existingPayment->validated ?? 0);
|
||||
$existingPayment->fill($attributes);
|
||||
|
||||
if ($existingPayment->isDirty()) {
|
||||
$existingPayment->save();
|
||||
}
|
||||
|
||||
if ($previousValidationState !== 1 && (int) $existingPayment->validated === 1) {
|
||||
$shouldNotify = true;
|
||||
}
|
||||
} else {
|
||||
InvoicePayment::create($attributes + [
|
||||
'invoice_id' => $invoice->id,
|
||||
'reference' => $reference,
|
||||
]);
|
||||
$shouldNotify = true;
|
||||
}
|
||||
|
||||
Invoices::checkPayments($invoice->id);
|
||||
|
||||
$paidStatus = Orders::getStatusByName('Préparation');
|
||||
if ($paidStatus !== '' && (int) $order->status !== (int) $paidStatus) {
|
||||
$order->status = $paidStatus;
|
||||
$order->save();
|
||||
}
|
||||
});
|
||||
|
||||
if ($shouldNotify) {
|
||||
try {
|
||||
OrderMails::sendOrderConfirmed($order->id);
|
||||
} catch (\Throwable $exception) {
|
||||
Log::error('Unable to send order confirmation email after Paybox payment', [
|
||||
'order_id' => $order->id,
|
||||
'invoice_id' => $invoice->id,
|
||||
'exception' => $exception->getMessage(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
Log::info('Paybox payment finalized successfully', [
|
||||
'invoice_id' => $invoice->id,
|
||||
'order_id' => $order->id,
|
||||
'reference' => $reference,
|
||||
'notified' => $shouldNotify,
|
||||
]);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function getPreviousAuthorizedRequest($request)
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
// Prevent closing from click inside dropdown
|
||||
$(document).on('click', '.dropdown-menu', function (e) {
|
||||
e.stopPropagation();
|
||||
});
|
||||
|
||||
// make it as accordion for smaller screens
|
||||
if ($(window).width() < 992) {
|
||||
$('.dropdown-menu a').click(function(e) {
|
||||
e.preventDefault();
|
||||
if ($(this).next('.submenu').length) {
|
||||
$(this).next('.submenu').toggle();
|
||||
}
|
||||
$('.dropdown').on('hide.bs.dropdown', function () {
|
||||
$(this).find('.submenu').hide();
|
||||
});
|
||||
});
|
||||
}
|
||||
0
resources/shop/assets/tpl/.gitkeep
Normal file
|
Before Width: | Height: | Size: 71 KiB After Width: | Height: | Size: 71 KiB |
|
Before Width: | Height: | Size: 70 KiB After Width: | Height: | Size: 70 KiB |
|
Before Width: | Height: | Size: 82 KiB After Width: | Height: | Size: 82 KiB |
|
Before Width: | Height: | Size: 69 KiB After Width: | Height: | Size: 69 KiB |
|
Before Width: | Height: | Size: 75 KiB After Width: | Height: | Size: 75 KiB |
BIN
resources/shop/img/favicon.ico
Normal file
|
After Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 2.7 KiB |
|
Before Width: | Height: | Size: 5.0 KiB After Width: | Height: | Size: 5.0 KiB |
|
Before Width: | Height: | Size: 4.3 KiB After Width: | Height: | Size: 4.3 KiB |
|
Before Width: | Height: | Size: 3.4 KiB After Width: | Height: | Size: 3.4 KiB |
|
Before Width: | Height: | Size: 43 KiB After Width: | Height: | Size: 43 KiB |
|
Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 2.7 KiB |
|
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 2.1 KiB |
|
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 2.1 KiB |
|
Before Width: | Height: | Size: 3.0 KiB After Width: | Height: | Size: 3.0 KiB |
|
Before Width: | Height: | Size: 2.6 KiB After Width: | Height: | Size: 2.6 KiB |
|
Before Width: | Height: | Size: 2.6 KiB After Width: | Height: | Size: 2.6 KiB |
|
Before Width: | Height: | Size: 48 KiB After Width: | Height: | Size: 48 KiB |
|
Before Width: | Height: | Size: 8.8 KiB After Width: | Height: | Size: 8.8 KiB |
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 36 KiB After Width: | Height: | Size: 36 KiB |
|
Before Width: | Height: | Size: 61 KiB After Width: | Height: | Size: 61 KiB |
43
resources/shop/js/site.js
Normal file
@@ -0,0 +1,43 @@
|
||||
// Simple notification helper used by blade templates (fallback to Bootstrap alerts)
|
||||
window.growl = function(message, type) {
|
||||
var alertTypes = {
|
||||
success: 'alert-success',
|
||||
error: 'alert-danger',
|
||||
warning: 'alert-warning',
|
||||
info: 'alert-info'
|
||||
};
|
||||
var cssClass = alertTypes[type] || alertTypes.info;
|
||||
var $container = $('#growl-container');
|
||||
|
||||
if (!$container.length) {
|
||||
$container = $('<div id="growl-container" class="growl-container position-fixed w-100" style="top: 1rem; left: 0; z-index: 1080; pointer-events: none;"></div>');
|
||||
$('body').append($container);
|
||||
}
|
||||
|
||||
var $alert = $('<div class="alert ' + cssClass + ' alert-dismissible fade show mx-auto shadow" role="alert" style="max-width: 420px; pointer-events: all;"></div>');
|
||||
$alert.append($('<span></span>').text(message));
|
||||
$alert.append('<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>');
|
||||
$container.append($alert);
|
||||
|
||||
setTimeout(function() {
|
||||
$alert.alert('close');
|
||||
}, 4000);
|
||||
};
|
||||
|
||||
// Prevent closing from click inside dropdown
|
||||
$(document).on('click', '.dropdown-menu', function (e) {
|
||||
e.stopPropagation();
|
||||
});
|
||||
|
||||
// make it as accordion for smaller screens
|
||||
if ($(window).width() < 992) {
|
||||
$('.dropdown-menu a').click(function(e) {
|
||||
e.preventDefault();
|
||||
if ($(this).next('.submenu').length) {
|
||||
$(this).next('.submenu').toggle();
|
||||
}
|
||||
$('.dropdown').on('hide.bs.dropdown', function () {
|
||||
$(this).find('.submenu').hide();
|
||||
});
|
||||
});
|
||||
}
|
||||