fix on payment by cb
This commit is contained in:
@@ -32,7 +32,7 @@ class OrdersDataTable extends DataTable
|
||||
return Orders::getStatus($order->status);
|
||||
})
|
||||
->editColumn('created_at', function (Order $order) {
|
||||
return $order->created_at->toDateTimeString();
|
||||
return $order->created_at->format('d/m/Y H:i:s');
|
||||
})
|
||||
->editColumn('customer.last_name', function (Order $order) {
|
||||
return $order->customer->last_name.' '.$order->customer->first_name;
|
||||
|
||||
@@ -65,12 +65,13 @@ class OrderController extends Controller
|
||||
$order = Orders::saveOrder($data);
|
||||
if ($order) {
|
||||
if ($data['payment_type'] == '1') {
|
||||
return Paybox::makeAuthorizationRequest($data['basket']['total_shipped']);
|
||||
// return redirect()->route('Shop.Payments.online');
|
||||
return Paybox::makeAuthorizationRequest($order);
|
||||
} else {
|
||||
return redirect()->route('Shop.Orders.confirmed');
|
||||
}
|
||||
OrderMails::sendOrderConfirmed($order->id);
|
||||
if ($ret) {
|
||||
OrderMails::sendOrderConfirmed($order->id);
|
||||
}
|
||||
} else {
|
||||
return view('Shop.Orders.order');
|
||||
}
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Shop;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
class OrderPaymentController extends Controller
|
||||
{
|
||||
}
|
||||
@@ -12,8 +12,10 @@ class PayboxController extends Controller
|
||||
return view('paybox.accepted');
|
||||
}
|
||||
|
||||
public function refused()
|
||||
public function refused(Request $request)
|
||||
{
|
||||
dump($request->all());
|
||||
exit;
|
||||
return view('paybox.refused');
|
||||
}
|
||||
|
||||
|
||||
@@ -57,17 +57,12 @@ class Article extends Model implements HasMedia
|
||||
return $this->belongsTo(ArticleNature::class);
|
||||
}
|
||||
|
||||
public function invoiceItems(): HasMany
|
||||
{
|
||||
return $this->hasMany(InvoiceItem::class);
|
||||
}
|
||||
|
||||
public function offers(): HasMany
|
||||
{
|
||||
return $this->hasMany(Offer::class);
|
||||
}
|
||||
|
||||
public function price_lists(): HasManyDeep
|
||||
public function price_lists()
|
||||
{
|
||||
return $this->hasManyDeep(
|
||||
PriceList::class,
|
||||
@@ -77,7 +72,7 @@ class Article extends Model implements HasMedia
|
||||
);
|
||||
}
|
||||
|
||||
public function prices(): HasManyDeep
|
||||
public function prices()
|
||||
{
|
||||
return $this->hasManyDeep(
|
||||
PriceListValue::class,
|
||||
@@ -166,6 +161,16 @@ class Article extends Model implements HasMedia
|
||||
return $query->byProduct(Merchandise::class);
|
||||
}
|
||||
|
||||
public function scopeVisible($query)
|
||||
{
|
||||
return $query->where($this->table.'.visible', 1);
|
||||
}
|
||||
|
||||
public function scopeHomepage($query)
|
||||
{
|
||||
return $query->where($this->table.'.homepage', 1);
|
||||
}
|
||||
|
||||
public function scopeByProduct($query, $model)
|
||||
{
|
||||
return $model ? $query->where($this->table.'.product_type', $model) : $query;
|
||||
@@ -179,23 +184,14 @@ class Article extends Model implements HasMedia
|
||||
public function scopeByTag($query, $tagId)
|
||||
{
|
||||
return $tagId ? $query->whereHas('tags', function ($query) use ($tagId) {
|
||||
$query->where('id', $tagId);
|
||||
$query->byId($tagId);
|
||||
}) : $query;
|
||||
}
|
||||
|
||||
public function scopeByTags($query, $tags)
|
||||
{
|
||||
return $tags ? $query->whereHas('tags', function ($query) use ($tags) {
|
||||
$query->whereIn('id', $tags);
|
||||
}) : $query;
|
||||
}
|
||||
|
||||
public function scopeByTagsSelected($query, $tags)
|
||||
{
|
||||
return $tags ? $query->whereHas('tags', function ($query) use ($tags) {
|
||||
foreach ($tags as $tag) {
|
||||
$query->where('id', $tag);
|
||||
}
|
||||
$query->byIds($tags);
|
||||
}) : $query;
|
||||
}
|
||||
|
||||
@@ -210,14 +206,4 @@ class Article extends Model implements HasMedia
|
||||
$query->active()->byStockAvailable()->bySaleChannel($saleChannelId);
|
||||
});
|
||||
}
|
||||
|
||||
public function scopeVisible($query)
|
||||
{
|
||||
return $query->where($this->table.'.visible', 1);
|
||||
}
|
||||
|
||||
public function scopeHomepage($query)
|
||||
{
|
||||
return $query->where($this->table.'.homepage', 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,6 +44,11 @@ class Invoice extends Model
|
||||
return $query->where('uuid', $uuid);
|
||||
}
|
||||
|
||||
public function scopeById($query, $id)
|
||||
{
|
||||
return $query->where('id', $id);
|
||||
}
|
||||
|
||||
public function scopeByPeriod($query, $start, $end)
|
||||
{
|
||||
return $query->whereBetween('created_at', [$start, $end]);
|
||||
|
||||
@@ -3,9 +3,13 @@
|
||||
namespace App\Models\Shop;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Venturecraft\Revisionable\RevisionableTrait;
|
||||
use Wildside\Userstamps\Userstamps;
|
||||
|
||||
class InvoicePayment extends Model
|
||||
{
|
||||
use RevisionableTrait, Userstamps;
|
||||
|
||||
protected $guarded = ['id'];
|
||||
|
||||
protected $table = 'shop_invoice_payments';
|
||||
@@ -15,8 +19,30 @@ class InvoicePayment extends Model
|
||||
return $this->belongsTo(Invoice::class);
|
||||
}
|
||||
|
||||
public function scopeByInvoice($query, $invoice_id)
|
||||
public function order()
|
||||
{
|
||||
return $query->where('invoice_id', $invoice_id);
|
||||
return $this->belongsToThrough(Order::class, Invoice::class);
|
||||
}
|
||||
|
||||
public function scopeByInvoice($query, $invoiceId)
|
||||
{
|
||||
return $query->where('invoice_id', $invoiceId);
|
||||
}
|
||||
|
||||
public function scopeValidated($query)
|
||||
{
|
||||
return $query->where('validated', 1);
|
||||
}
|
||||
|
||||
public function scopeByOrder($query, $orderId)
|
||||
{
|
||||
return $query->whereHas('order', function($query) use ($orderId) {
|
||||
return $query->byOrder($orderId);
|
||||
});
|
||||
}
|
||||
|
||||
public function scopeByPaymentType($query, $paymentType)
|
||||
{
|
||||
return $query->where('payment_type', $paymentType);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,4 +92,11 @@ class Order extends Model
|
||||
{
|
||||
return $query->whereBetween($field, [$start, $end]);
|
||||
}
|
||||
|
||||
public function scopeByInvoice($query, $invoiceId)
|
||||
{
|
||||
return $query->whereHas('invoice', function ($query) use ($invoiceId) {
|
||||
$query->byId($invoiceId);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,13 +21,6 @@ class Tag extends parentTag
|
||||
|
||||
public $translatable = [];
|
||||
|
||||
/*
|
||||
public function taggable()
|
||||
{
|
||||
return $this->hasMany('App\Models\Shop\Taggable');
|
||||
}
|
||||
*/
|
||||
|
||||
// TODO
|
||||
public function offers()
|
||||
{
|
||||
@@ -80,4 +73,14 @@ class Tag extends parentTag
|
||||
$query->byCategoryParent($category_id);
|
||||
}]);
|
||||
}
|
||||
|
||||
public function scopeById($query, $id)
|
||||
{
|
||||
return $query->where($this->table.'.id', $id);
|
||||
}
|
||||
|
||||
public function scopeByIds($query, $ids)
|
||||
{
|
||||
return $query->whereIn($this->table.'.id', $ids);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -222,7 +222,8 @@ class Articles
|
||||
{
|
||||
$saleChannelId = $options['sale_channel_id'] ?? SaleChannels::getDefaultID();
|
||||
$model = self::getModelByOptions($options);
|
||||
$data = $model->withAvailableOffers($saleChannelId)->with([
|
||||
|
||||
return $model->withAvailableOffers($saleChannelId)->with([
|
||||
'image',
|
||||
'product',
|
||||
'article_nature',
|
||||
@@ -238,14 +239,6 @@ class Articles
|
||||
'offers.tariff.price_lists.price_list_values',
|
||||
'offers.variation.package',
|
||||
])->get();
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
public static function getArticleNaturesOptionsWithOffers($options = false)
|
||||
{
|
||||
$ids = self::getArticleNaturesIdsWithOffers($options);
|
||||
|
||||
}
|
||||
|
||||
public static function getArticleNaturesWithOffers($options = false)
|
||||
@@ -294,7 +287,7 @@ class Articles
|
||||
|
||||
$model = ($options['homepage'] ?? false) ? Article::homepage()->visible() : Article::visible();
|
||||
$model = $category_id ? $model->byCategoryParent($category_id) : $model;
|
||||
$model = $tags ? $model->byTagsSelected($tags) : $model;
|
||||
$model = $tags ? $model->byTags($tags) : $model;
|
||||
$model = $search ? $model->search($search) : $model;
|
||||
$model = $article_nature_id ? $model->byArticleNature($article_nature_id) : $model;
|
||||
$model = $article_nature_ids ? $model->byArticleNatures($article_nature_ids) : $model;
|
||||
@@ -305,6 +298,8 @@ class Articles
|
||||
case 'merchandise':
|
||||
$model = $model->merchandise();
|
||||
break;
|
||||
default:
|
||||
$model = $model->botanic();
|
||||
}
|
||||
|
||||
return $model;
|
||||
@@ -313,9 +308,8 @@ class Articles
|
||||
public static function getFull($id)
|
||||
{
|
||||
$data['article'] = self::getArticleEdit($id);
|
||||
self::getMeta($data);
|
||||
|
||||
return $data;
|
||||
|
||||
return self::getMeta($data);
|
||||
}
|
||||
|
||||
public static function getArticleEdit($id)
|
||||
@@ -378,6 +372,7 @@ class Articles
|
||||
'tags' => $product->tags->toArray(),
|
||||
];
|
||||
break;
|
||||
default:
|
||||
}
|
||||
|
||||
return $data ?? false;
|
||||
@@ -395,6 +390,7 @@ class Articles
|
||||
case 'App\Models\Shop\Merchandise':
|
||||
$images = Merchandises::getImages($product_id);
|
||||
break;
|
||||
default:
|
||||
}
|
||||
|
||||
return $images ?? false ? ['images' => $images] : false;
|
||||
@@ -538,8 +534,12 @@ class Articles
|
||||
case 'App\Models\Botanic\Variety':
|
||||
$variety = $article->product ?? false;
|
||||
$specie = $variety->specie ?? false;
|
||||
$images = $variety ? (count($variety->images ?? []) ? $images->merge($variety->images) : $images) : $images;
|
||||
$images = $specie ? (count($specie->images ?? []) ? $images->merge($specie->images) : $images) : $images;
|
||||
if ($variety) {
|
||||
$images = count($variety->images ?? []) ? $images->merge($variety->images) : $images;
|
||||
}
|
||||
if ($specie) {
|
||||
$images = count($specie->images ?? []) ? $images->merge($specie->images) : $images;
|
||||
}
|
||||
break;
|
||||
case 'App\Models\Botanic\Specie':
|
||||
$specie = $article->product ?? false;
|
||||
|
||||
@@ -2,24 +2,27 @@
|
||||
|
||||
namespace App\Repositories\Shop;
|
||||
|
||||
use App;
|
||||
use Bnb\PayboxGateway\Requests\AuthorizationWithCapture;
|
||||
use Bnb\PayboxGateway\Requests\Capture;
|
||||
use Bnb\PayboxGateway\Responses\Verify;
|
||||
use Illuminate\Support\Facades\App;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Bnb\PayboxGateway\Requests\Paybox\AuthorizationWithCapture;
|
||||
use Bnb\PayboxGateway\Requests\PayboxDirect\Capture;
|
||||
use Bnb\PayboxGateway\Responses\Paybox\Verify;
|
||||
use Bnb\PayboxGateway\Responses\Exceptions\InvalidSignature;
|
||||
|
||||
class Paybox
|
||||
{
|
||||
public static function makeAuthorizationRequest($amount, $customer_email = 'test@example.com')
|
||||
public static function makeAuthorizationRequest($order, $customer_email = 'test@example.com')
|
||||
{
|
||||
$authorizationRequest = App::make(AuthorizationWithCapture::class);
|
||||
$invoiceId = $order->invoice->id;
|
||||
|
||||
return $authorizationRequest->setAmount($amount)->setCustomerEmail($customer_email)
|
||||
->setPaymentNumber(1)->send('paybox.send');
|
||||
return $authorizationRequest->setAmount($order->total_shipped)->setCustomerEmail($customer_email)
|
||||
->setPaymentNumber($invoiceId)->send('paybox.send');
|
||||
}
|
||||
|
||||
public static function verifyPayment($invoice_id)
|
||||
public static function verifyPayment($invoiceId)
|
||||
{
|
||||
$invoice = Invoices::get($invoice_id);
|
||||
$invoice = Invoices::get($invoiceId);
|
||||
$payboxVerify = App::make(Verify::class);
|
||||
try {
|
||||
$success = $payboxVerify->isSuccess($invoice->total_shipped);
|
||||
@@ -34,7 +37,7 @@ class Paybox
|
||||
|
||||
public static function getPreviousAuthorizedRequest()
|
||||
{
|
||||
$payment = PaymentModel::find($idOfAuthorizedPayment);
|
||||
$payment = Payment::where('number', $request->input('order_number'))->firstOrFail();
|
||||
$captureRequest = App::make(Capture::class);
|
||||
$response = $captureRequest->setAmount($payment->amount)
|
||||
->setPayboxCallNumber($payment->call_number)
|
||||
|
||||
Reference in New Issue
Block a user