Merge Invoice and Bill into Document

This commit is contained in:
Burak Çakırel
2020-12-24 01:28:38 +03:00
parent 830cc05957
commit 0c1424db47
436 changed files with 31655 additions and 37350 deletions

View File

@@ -3,9 +3,9 @@
namespace Modules\PaypalStandard\Http\Controllers;
use App\Abstracts\Http\PaymentController;
use App\Events\Sale\PaymentReceived;
use App\Events\Document\PaymentReceived;
use App\Http\Requests\Portal\InvoicePayment as PaymentRequest;
use App\Models\Sale\Invoice;
use App\Models\Document\Document;
use GuzzleHttp\Client;
use Illuminate\Http\Request;
use Monolog\Handler\StreamHandler;
@@ -17,17 +17,17 @@ class Payment extends PaymentController
public $type = 'redirect';
public function show(Invoice $invoice, PaymentRequest $request)
public function show(Document $document, PaymentRequest $request)
{
$setting = $this->setting;
$this->setContactFirstLastName($invoice);
$this->setContactFirstLastName($document);
$setting['action'] = ($setting['mode'] == 'live') ? 'https://www.paypal.com/cgi-bin/webscr' : 'https://www.sandbox.paypal.com/cgi-bin/webscr';
$invoice_url = $this->getInvoiceUrl($invoice);
$document_url = $this->getInvoiceUrl($document);
$html = view('paypal-standard::show', compact('setting', 'invoice', 'invoice_url'))->render();
$html = view('paypal-standard::show', compact('setting', 'document', 'document_url'))->render();
return response()->json([
'code' => $setting['code'],
@@ -38,7 +38,7 @@ class Payment extends PaymentController
]);
}
public function return(Invoice $invoice, Request $request)
public function return(Document $document, Request $request)
{
$success = true;
@@ -66,12 +66,12 @@ class Payment extends PaymentController
flash($message)->warning();
}
$invoice_url = $this->getInvoiceUrl($invoice);
$document_url = $this->getInvoiceUrl($document);
return redirect($invoice_url);
return redirect($document_url);
}
public function complete(Invoice $invoice, Request $request)
public function complete(Document $document, Request $request)
{
$setting = $this->setting;
@@ -79,7 +79,7 @@ class Payment extends PaymentController
$paypal_log->pushHandler(new StreamHandler(storage_path('logs/paypal.log')), Logger::INFO);
if (!$invoice) {
if (!$document) {
return;
}
@@ -115,10 +115,10 @@ class Payment extends PaymentController
case 'Completed':
$receiver_match = (strtolower($request['receiver_email']) == strtolower($setting['email']));
$total_paid_match = ((double) $request['mc_gross'] == $invoice->amount);
$total_paid_match = ((double) $request['mc_gross'] == $document->amount);
if ($receiver_match && $total_paid_match) {
event(new PaymentReceived($invoice, $request));
event(new PaymentReceived($document, $request));
}
if (!$receiver_match) {

View File

@@ -21,29 +21,29 @@
<input type="hidden" name="upload" value="1" />
<input type="hidden" name="business" value="{{ $setting['email'] }}" />
<?php $i = 1; ?>
@foreach ($invoice->items as $item)
@foreach ($document->items as $item)
<input type="hidden" name="item_name_{{ $i }}" value="{{ $item->name }}" />
<input type="hidden" name="amount_{{ $i }}" value="{{ $item->price }}" />
<input type="hidden" name="quantity_{{ $i }}" value="{{ $item->quantity }}" />
<?php $i++; ?>
@endforeach
<input type="hidden" name="currency_code" value="{{ $invoice->currency_code}}" />
<input type="hidden" name="first_name" value="{{ $invoice->first_name }}" />
<input type="hidden" name="last_name" value="{{ $invoice->last_name }}" />
<input type="hidden" name="address1" value="{{ $invoice->customer_address }}" />
<input type="hidden" name="currency_code" value="{{ $document->currency_code}}" />
<input type="hidden" name="first_name" value="{{ $document->first_name }}" />
<input type="hidden" name="last_name" value="{{ $document->last_name }}" />
<input type="hidden" name="address1" value="{{ $document->customer_address }}" />
<input type="hidden" name="address_override" value="0" />
<input type="hidden" name="email" value="{{ $invoice->customer_email }}" />
<input type="hidden" name="invoice" value="{{ $invoice->id . '-' . $invoice->customer_name }}" />
<input type="hidden" name="email" value="{{ $document->customer_email }}" />
<input type="hidden" name="invoice" value="{{ $document->id . '-' . $document->customer_name }}" />
<input type="hidden" name="lc" value="{{ $setting['language'] }}" />
<input type="hidden" name="rm" value="2" />
<input type="hidden" name="no_note" value="1" />
<input type="hidden" name="no_shipping" value="1" />
<input type="hidden" name="charset" value="utf-8" />
<input type="hidden" name="return" value="{{ route('portal.invoices.paypal-standard.return', $invoice->id) }}" />
<input type="hidden" name="notify_url" value="{{ route('portal.invoices.paypal-standard.complete', $invoice->id) }}" />
<input type="hidden" name="cancel_return" value="{{ $invoice_url }}" />
<input type="hidden" name="return" value="{{ route('portal.invoices.paypal-standard.return', $document->id) }}" />
<input type="hidden" name="notify_url" value="{{ route('portal.invoices.paypal-standard.complete', $document->id) }}" />
<input type="hidden" name="cancel_return" value="{{ $document_url }}" />
<input type="hidden" name="paymentaction" value="{{ $setting['transaction'] }}" />
<input type="hidden" name="custom" value="{{ $invoice->id }}" />
<input type="hidden" name="custom" value="{{ $document->id }}" />
<input type="hidden" name="bn" value="Akaunting_2.0_WPS" />
<input type="submit" value="{{ trans('general.confirm') }}" class="btn btn-success" />

View File

@@ -5,6 +5,6 @@ Route::group([
'middleware' => 'guest',
'namespace' => 'Modules\PaypalStandard\Http\Controllers'
], function () {
Route::post('invoices/{invoice}/paypal-standard/return', 'Payment@return')->name('portal.invoices.paypal-standard.return');
Route::post('invoices/{invoice}/paypal-standard/complete', 'Payment@complete')->name('portal.invoices.paypal-standard.complete');
Route::post('invoices/{document}/paypal-standard/return', 'Payment@return')->name('portal.invoices.paypal-standard.return');
Route::post('invoices/{document}/paypal-standard/complete', 'Payment@complete')->name('portal.invoices.paypal-standard.complete');
});

View File

@@ -5,5 +5,5 @@ Route::group([
'middleware' => 'portal',
'namespace' => 'Modules\PaypalStandard\Http\Controllers'
], function () {
Route::get('invoices/{invoice}/paypal-standard', 'Payment@show')->name('portal.invoices.paypal-standard.show');
Route::get('invoices/{document}/paypal-standard', 'Payment@show')->name('portal.invoices.paypal-standard.show');
});

View File

@@ -5,5 +5,5 @@ Route::group([
'middleware' => 'signed',
'namespace' => 'Modules\PaypalStandard\Http\Controllers'
], function () {
Route::get('invoices/{invoice}/paypal-standard', 'Payment@show')->name('signed.invoices.paypal-standard.show');
Route::get('invoices/{document}/paypal-standard', 'Payment@show')->name('signed.invoices.paypal-standard.show');
});