Merge branch 'v5-develop' into v5-2701-payable-draft-invoices

This commit is contained in:
Benjamin Beganović 2021-01-28 15:44:22 +01:00 committed by GitHub
commit 3b31953d14
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
22 changed files with 38484 additions and 38451 deletions

View File

@ -1 +1 @@
5.0.54
5.0.55

View File

@ -218,6 +218,8 @@ class MigrationController extends BaseController
*/
public function startMigration(Request $request)
{
nlog("Starting Migration");
$companies = json_decode($request->companies);
if (app()->environment() === 'local') {
@ -290,6 +292,9 @@ class MigrationController extends BaseController
// If there's no existing company migrate just normally.
if ($checks['existing_company'] == false) {
nlog("creating fresh company");
$account = auth()->user()->account;
$fresh_company = (new ImportMigrations())->getCompany($account);
@ -325,11 +330,13 @@ class MigrationController extends BaseController
);
if (app()->environment() == 'testing') {
nlog("environment is testing = bailing out now");
return;
}
try {
// StartMigration::dispatch(base_path("storage/app/public/$migration_file"), $user, $fresh_company)->delay(now()->addSeconds(5));
nlog("starting migration job");
nlog($migration_file);
StartMigration::dispatch($migration_file, $user, $fresh_company);
} catch (\Exception $e) {

View File

@ -73,6 +73,8 @@ class StartMigration implements ShouldQueue
*/
public function handle()
{
nlog("Inside Migration Job");
set_time_limit(0);
MultiDB::setDb($this->company->db);

View File

@ -40,6 +40,5 @@ class PaymentEmailedActivity implements ShouldQueue
$payment = $event->payment;
nlog("i succeeded in emailing payment {$payment->number}");
}
}

View File

@ -55,39 +55,6 @@ class PaymentEmailEngine extends BaseEmailEngine
$body_template = EmailTemplateDefaults::getDefaultTemplate('email_template_payment', $this->client->locale());
}
/* Use default translations if a custom message has not been set*/
if (iconv_strlen($body_template) == 0) {
if ($payment->invoices()->exists())
{
$invoice_texts = ctrans('texts.invoice_number_short');
foreach ($this->payment->invoices as $invoice) {
$invoice_texts .= $invoice->number.',';
}
$invoice_texts = substr($invoice_texts, 0, -1);
$body_template = trans(
'texts.payment_message_extended',
['amount' => $payment->amount, 'company' => $payment->company->present()->name(), 'invoice' => $invoice_texts],
null,
$this->client->locale()
);
}
else
{
$body_template = trans(
'texts.payment_message',
['amount' => $payment->amount, 'company' => $payment->company->present()->name()],
null,
$this->client->locale()
);
}
}
if (is_array($this->template_data) && array_key_exists('subject', $this->template_data) && strlen($this->template_data['subject']) > 0) {
$subject_template = $this->template_data['subject'];
} elseif (strlen($this->client->getSetting('email_subject_payment')) > 0) {
@ -96,15 +63,6 @@ class PaymentEmailEngine extends BaseEmailEngine
$subject_template = EmailTemplateDefaults::getDefaultTemplate('email_subject_payment', $this->client->locale());
}
if (iconv_strlen($subject_template) == 0) {
$subject_template = trans(
'texts.payment_subject',
['number' => $payment->number, 'company' => $payment->company->present()->name()],
null,
$this->client->locale()
);
}
$this->setTemplate($this->client->getSetting('email_style'))
->setContact($this->contact)
->setVariables($this->makeValues())
@ -221,7 +179,7 @@ class PaymentEmailEngine extends BaseEmailEngine
private function formatInvoices()
{
$invoice_list = '';
$invoice_list = '<br><br>';
foreach ($this->payment->invoices as $invoice) {
$invoice_list .= ctrans('texts.invoice_number_short') . " {$invoice->number} - " . Number::formatMoney($invoice->pivot->amount, $this->client) . "<br>";

View File

@ -12,6 +12,7 @@
namespace App\PaymentDrivers\Authorize;
use App\Exceptions\PaymentFailed;
use App\Jobs\Mail\PaymentFailureMailer;
use App\Jobs\Util\SystemLogger;
use App\Models\ClientGatewayToken;
@ -81,7 +82,14 @@ class AuthorizeCreditCard
private function processTokenPayment($request)
{
$client_gateway_token =ClientGatewayToken::where('token', $request->token)->firstOrFail();
$client_gateway_token = ClientGatewayToken::query()
->where('id', $this->decodePrimaryKey($request->token))
->where('company_id', auth('contact')->user()->client->company->id)
->first();
if (!$client_gateway_token) {
throw new PaymentFailed(ctrans('texts.payment_token_not_found'), 401);
}
$data = (new ChargePaymentProfile($this->authorize))->chargeCustomerProfile($client_gateway_token->gateway_customer_reference, $client_gateway_token->token, $request->input('amount_with_fee'));
@ -129,7 +137,7 @@ class AuthorizeCreditCard
PaymentFailureMailer::dispatch($this->authorize->client, $response->getTransactionResponse()->getTransId(), $this->authorize->client->company, $amount);
SystemLogger::dispatch($logger_message, SystemLog::CATEGORY_GATEWAY_RESPONSE, SystemLog::EVENT_GATEWAY_FAILURE, SystemLog::TYPE_AUTHORIZE, $this->authorize->client);
return false;
}
}
@ -140,7 +148,6 @@ class AuthorizeCreditCard
$response = $data['response'];
if ($response != null && $response->getMessages()->getResultCode() == 'Ok') {
$this->authorize->confirmGatewayFee($request);
return $this->processSuccessfulResponse($data, $request);
}
@ -157,7 +164,7 @@ class AuthorizeCreditCard
$payment_record = [];
$payment_record['amount'] = $amount;
$payment_record['payment_type'] = PaymentType::CREDIT_CARD_OTHER;
$payment_record['gateway_type_id'] = GatewayType::CREDIT_CARD;
$payment_record['gateway_type_id'] = GatewayType::CREDIT_CARD;
$payment_record['transaction_reference'] = $response->getTransactionResponse()->getTransId();
$payment = $this->authorize->createPayment($payment_record);

View File

@ -69,7 +69,7 @@ class AuthorizePaymentDriver extends BaseDriver
['name' => 'client_name', 'label' => ctrans('texts.name'), 'type' => 'text', 'validation' => 'required|min:2'],
['name' => 'contact_email', 'label' => ctrans('texts.email'), 'type' => 'text', 'validation' => 'required|email:rfc'],
['name' => 'client_address_line_1', 'label' => ctrans('texts.address1'), 'type' => 'text', 'validation' => 'required'],
['name' => 'client_address_line_2', 'label' => ctrans('texts.address1'), 'type' => 'text', 'validation' => 'sometimes'],
['name' => 'client_address_line_2', 'label' => ctrans('texts.address2'), 'type' => 'text', 'validation' => 'sometimes'],
['name' => 'client_city', 'label' => ctrans('texts.city'), 'type' => 'text', 'validation' => 'required'],
['name' => 'client_state', 'label' => ctrans('texts.state'), 'type' => 'text', 'validation' => 'required'],
['name' => 'client_postal_code', 'label' => ctrans('texts.postal_code'), 'type' => 'text', 'validation' => 'required'],
@ -104,8 +104,6 @@ class AuthorizePaymentDriver extends BaseDriver
public function tokenBilling(ClientGatewayToken $cgt, PaymentHash $payment_hash)
{
$this->setPaymentHash($payment_hash);
$this->setPaymentMethod($cgt->gateway_type_id);
return $this->payment_method->tokenBilling($cgt, $payment_hash);

View File

@ -202,14 +202,15 @@ class BaseDriver extends AbstractPaymentDriver
*/
public function createPayment($data, $status = Payment::STATUS_COMPLETED): Payment
{
$this->confirmGatewayFee();
$payment = PaymentFactory::create($this->client->company->id, $this->client->user->id);
$payment->client_id = $this->client->id;
$payment->company_gateway_id = $this->company_gateway->id;
$payment->status_id = $status;
$payment->currency_id = $this->client->getSetting('currency_id');
$payment->date = Carbon::now();
//$payment->gateway_type_id = $data['gateway_type_id'];
$payment->gateway_type_id = $data['gateway_type_id'];
$client_contact = $this->getContact();
$client_contact_id = $client_contact ? $client_contact->id : null;
@ -245,19 +246,14 @@ class BaseDriver extends AbstractPaymentDriver
* @param PaymentResponseRequest $request The incoming payment request
* @return void Success/Failure
*/
public function confirmGatewayFee(PaymentResponseRequest $request) :void
public function confirmGatewayFee() :void
{
/*Payment meta data*/
$payment_hash = $request->getPaymentHash();
/*Payment invoices*/
$payment_invoices = $payment_hash->invoices();
$payment_invoices = $this->payment_hash->invoices();
/*Fee charged at gateway*/
$fee_total = $payment_hash->fee_total;
// Sum of invoice amounts
// $invoice_totals = array_sum(array_column($payment_invoices,'amount'));
$fee_total = $this->payment_hash->fee_total;
/*Hydrate invoices*/
$invoices = Invoice::whereIn('id', $this->transformKeys(array_column($payment_invoices, 'invoice_id')))->get();

View File

@ -12,9 +12,12 @@
namespace App\PaymentDrivers\CheckoutCom;
use App\Exceptions\PaymentFailed;
use App\Http\Requests\ClientPortal\Payments\PaymentResponseRequest;
use App\Jobs\Mail\PaymentFailureMailer;
use App\Models\ClientGatewayToken;
use App\PaymentDrivers\CheckoutComPaymentDriver;
use App\Utils\Traits\MakesHash;
use Checkout\Library\Exceptions\CheckoutHttpException;
use Checkout\Models\Payments\IdSource;
use Checkout\Models\Payments\Payment;
@ -25,6 +28,7 @@ use Illuminate\View\View;
class CreditCard
{
use Utilities;
use MakesHash;
/**
* @var CheckoutComPaymentDriver
@ -78,6 +82,15 @@ class CreditCard
{
$this->checkout->init();
$cgt = ClientGatewayToken::query()
->where('id', $this->decodePrimaryKey($request->input('token')))
->where('company_id', auth('contact')->user()->client->company->id)
->first();
if (!$cgt) {
throw new PaymentFailed(ctrans('texts.payment_token_not_found'), 401);
}
$state = [
'server_response' => json_decode($request->gateway_response),
'value' => $request->value,
@ -90,11 +103,12 @@ class CreditCard
$state = array_merge($state, $request->all());
$state['store_card'] = boolval($state['store_card']);
$state['token'] = $cgt;
$this->checkout->payment_hash->data = array_merge((array) $this->checkout->payment_hash->data, $state);
$this->checkout->payment_hash->data = array_merge((array)$this->checkout->payment_hash->data, $state);
$this->checkout->payment_hash->save();
if ($request->has('token') && !is_null($request->token) && !empty($request->token)) {
if ($request->has('token')) {
return $this->attemptPaymentUsingToken($request);
}
@ -103,7 +117,7 @@ class CreditCard
private function attemptPaymentUsingToken(PaymentResponseRequest $request)
{
$method = new IdSource($this->checkout->payment_hash->data->token);
$method = new IdSource($this->checkout->payment_hash->data->token->token);
return $this->completePayment($method, $request);
}
@ -125,7 +139,7 @@ class CreditCard
$payment->amount = $this->checkout->payment_hash->data->value;
$payment->reference = $this->checkout->payment_hash->data->reference;
$this->checkout->payment_hash->data = array_merge((array) $this->checkout->payment_hash->data, ['checkout_payment_ref' => $payment]);
$this->checkout->payment_hash->data = array_merge((array)$this->checkout->payment_hash->data, ['checkout_payment_ref' => $payment]);
$this->checkout->payment_hash->save();
if ($this->checkout->client->currency()->code === 'EUR') {
@ -142,7 +156,6 @@ class CreditCard
$response = $this->checkout->gateway->payments()->request($payment);
if ($response->status == 'Authorized') {
$this->checkout->confirmGatewayFee($request);
return $this->processSuccessfulPayment($response);
}
@ -156,7 +169,7 @@ class CreditCard
if ($response->status == 'Declined') {
$this->checkout->unWindGatewayFees($this->checkout->payment_hash);
PaymentFailureMailer::dispatch($this->checkout->client, $response->response_summary, $this->checkout->client->company, $this->checkout->payment_hash->data->value);
PaymentFailureMailer::dispatch($this->checkout->client, $response->response_summary, $this->checkout->client->company, $this->checkout->payment_hash->data->value);
return $this->processUnsuccessfulPayment($response);

View File

@ -95,7 +95,6 @@ class CreditCard
$server_response = $this->stripe->payment_hash->data->server_response;
if ($server_response->status == 'succeeded') {
$this->stripe->confirmGatewayFee($request);
$this->stripe->logSuccessfulGatewayResponse(['response' => json_decode($request->gateway_response), 'data' => $this->stripe->payment_hash], SystemLog::TYPE_STRIPE);

View File

@ -322,8 +322,6 @@ class StripePaymentDriver extends BaseDriver
public function tokenBilling(ClientGatewayToken $cgt, PaymentHash $payment_hash)
{
$this->setPaymentHash($payment_hash);
return (new Charge($this))->tokenBilling($cgt, $payment_hash);
}

View File

@ -141,7 +141,6 @@ class PaymentMethod
if ($this->validGatewayForAmount($gateway->fees_and_limits->{$type}, $this->amount) && $gateway->fees_and_limits->{$type}->is_enabled) {
if($type == GatewayType::BANK_TRANSFER);
nlog($gateway->fees_and_limits);
$this->payment_methods[] = [$gateway->id => $type];
}

View File

@ -41,9 +41,8 @@ class AutoBillInvoice extends AbstractService
public function run()
{
/* Is the invoice payable? */
if (! $this->invoice->isPayable()) {
if (! $this->invoice->isPayable())
return $this->invoice;
}
/* Mark the invoice as sent */
$this->invoice = $this->invoice->service()->markSent()->save();
@ -67,6 +66,7 @@ class AutoBillInvoice extends AbstractService
info("balance remains to be paid!!");
/* Retrieve the Client Gateway Token */
$gateway_token = $this->getGateway($amount);
/* Bail out if no payment methods available */
@ -74,7 +74,10 @@ class AutoBillInvoice extends AbstractService
return $this->invoice;
/* $gateway fee */
$fee = $gateway_token->gateway->calcGatewayFee($amount, $gateway_token->gateway_type_id, $this->invoice->uses_inclusive_taxes);
//$fee = $gateway_token->gateway->calcGatewayFee($amount, $gateway_token->gateway_type_id, $this->invoice->uses_inclusive_taxes);
$this->invoice = $this->invoice->service()->addGatewayFee($gateway_token->gateway, $gateway_token->gateway_type_id, $amount)->save();
$fee = $this->invoice->amount - $amount;
/* Build payment hash */
$payment_hash = PaymentHash::create([
@ -86,6 +89,7 @@ class AutoBillInvoice extends AbstractService
$payment = $gateway_token->gateway
->driver($this->client)
->setPaymentHash($payment_hash)
->tokenBilling($gateway_token, $payment_hash);
return $this->invoice;

View File

@ -337,7 +337,6 @@ class Design extends BaseDesign
if (count($items) == 0) {
return [];
}
if ($type == 'delivery_note') {
foreach ($items as $row) {
$element = ['element' => 'tr', 'elements' => []];

View File

@ -13,7 +13,7 @@ return [
'require_https' => env('REQUIRE_HTTPS', true),
'app_url' => rtrim(env('APP_URL', ''), '/'),
'app_domain' => env('APP_DOMAIN', ''),
'app_version' => '5.0.54',
'app_version' => '5.0.55',
'minimum_client_version' => '5.0.16',
'terms_version' => '1.0.1',
'api_secret' => env('API_SECRET', false),

View File

@ -3,35 +3,35 @@ const MANIFEST = 'flutter-app-manifest';
const TEMP = 'flutter-temp-cache';
const CACHE_NAME = 'flutter-app-cache';
const RESOURCES = {
"icons/Icon-512.png": "0f9aff01367f0a0c69773d25ca16ef35",
"icons/Icon-192.png": "bb1cf5f6982006952211c7c8404ffbed",
"favicon.ico": "51636d3a390451561744c42188ccd628",
"manifest.json": "77215c1737c7639764e64a192be2f7b8",
"assets/packages/material_design_icons_flutter/lib/fonts/materialdesignicons-webfont.ttf": "3e722fd57a6db80ee119f0e2c230ccff",
"assets/NOTICES": "c3e1cbfaeb1a4f54fadae1bd6558d91b",
"assets/assets/images/logo.png": "090f69e23311a4b6d851b3880ae52541",
"assets/assets/images/payment_types/mastercard.png": "6f6cdc29ee2e22e06b1ac029cb52ef71",
"assets/assets/images/payment_types/amex.png": "c49a4247984b3732a4af50a3390aa978",
"assets/assets/images/payment_types/unionpay.png": "7002f52004e0ab8cc0b7450b0208ccb2",
"assets/assets/images/payment_types/switch.png": "4fa11c45327f5fdc20205821b2cfd9cc",
"assets/assets/images/google-icon.png": "0f118259ce403274f407f5e982e681c3",
"assets/assets/images/payment_types/paypal.png": "8e06c094c1871376dfea1da8088c29d1",
"assets/assets/images/payment_types/visa.png": "3ddc4a4d25c946e8ad7e6998f30fd4e3",
"assets/assets/images/payment_types/laser.png": "b4e6e93dd35517ac429301119ff05868",
"assets/assets/images/payment_types/other.png": "d936e11fa3884b8c9f1bd5c914be8629",
"assets/assets/images/payment_types/dinerscard.png": "06d85186ba858c18ab7c9caa42c92024",
"assets/assets/images/payment_types/carteblanche.png": "d936e11fa3884b8c9f1bd5c914be8629",
"assets/assets/images/payment_types/ach.png": "7433f0aff779dc98a649b7a2daf777cf",
"assets/assets/images/payment_types/solo.png": "2030c3ccaccf5d5e87916a62f5b084d6",
"assets/assets/images/payment_types/mastercard.png": "6f6cdc29ee2e22e06b1ac029cb52ef71",
"assets/assets/images/payment_types/discover.png": "6c0a386a00307f87db7bea366cca35f5",
"assets/assets/images/payment_types/amex.png": "c49a4247984b3732a4af50a3390aa978",
"assets/assets/images/payment_types/solo.png": "2030c3ccaccf5d5e87916a62f5b084d6",
"assets/assets/images/payment_types/other.png": "d936e11fa3884b8c9f1bd5c914be8629",
"assets/assets/images/payment_types/unionpay.png": "7002f52004e0ab8cc0b7450b0208ccb2",
"assets/assets/images/payment_types/visa.png": "3ddc4a4d25c946e8ad7e6998f30fd4e3",
"assets/assets/images/payment_types/maestro.png": "e533b92bfb50339fdbfa79e3dfe81f08",
"assets/assets/images/payment_types/laser.png": "b4e6e93dd35517ac429301119ff05868",
"assets/assets/images/payment_types/switch.png": "4fa11c45327f5fdc20205821b2cfd9cc",
"assets/assets/images/payment_types/jcb.png": "07e0942d16c5592118b72e74f2f7198c",
"assets/assets/images/google-icon.png": "0f118259ce403274f407f5e982e681c3",
"assets/AssetManifest.json": "659dcf9d1baf3aed3ab1b9c42112bf8f",
"assets/assets/images/payment_types/ach.png": "7433f0aff779dc98a649b7a2daf777cf",
"assets/assets/images/payment_types/carteblanche.png": "d936e11fa3884b8c9f1bd5c914be8629",
"assets/assets/images/payment_types/dinerscard.png": "06d85186ba858c18ab7c9caa42c92024",
"assets/assets/images/logo.png": "090f69e23311a4b6d851b3880ae52541",
"assets/NOTICES": "c3e1cbfaeb1a4f54fadae1bd6558d91b",
"assets/FontManifest.json": "cf3c681641169319e61b61bd0277378f",
"assets/AssetManifest.json": "659dcf9d1baf3aed3ab1b9c42112bf8f",
"assets/packages/material_design_icons_flutter/lib/fonts/materialdesignicons-webfont.ttf": "3e722fd57a6db80ee119f0e2c230ccff",
"assets/fonts/MaterialIcons-Regular.otf": "1288c9e28052e028aba623321f7826ac",
"/": "23224b5e03519aaa87594403d54412cf",
"main.dart.js": "9fa4964ce079e27f67880b0d542ff67e",
"icons/Icon-512.png": "0f9aff01367f0a0c69773d25ca16ef35",
"icons/Icon-192.png": "bb1cf5f6982006952211c7c8404ffbed",
"manifest.json": "77215c1737c7639764e64a192be2f7b8",
"favicon.ico": "51636d3a390451561744c42188ccd628",
"version.json": "24380404aa64649901a0878a4f6aae18",
"main.dart.js": "1071216a656504599447ac0e362ca27a",
"favicon.png": "dca91c54388f52eded692718d5a98b8b"
};

76731
public/main.dart.js vendored

File diff suppressed because one or more lines are too long

View File

@ -3384,4 +3384,5 @@ return [
'number' => 'Number',
'payment_message_extended' => 'Thank you for your payment of :amount for :invoice',
'online_payments_minimum_note' => 'Note: Online payments are supported only if amount is bigger than $1 or currency equivalent.',
'payment_token_not_found' => 'Payment token not found, please try again. If an issue still persist, try with another payment method',
];

View File

@ -38,7 +38,7 @@
<label class="mr-4">
<input
type="radio"
data-token="{{ $token->token }}"
data-token="{{ $token->hashed_id }}"
name="payment-type"
class="form-radio cursor-pointer toggle-payment-with-token"/>
<span class="ml-1 cursor-pointer">**** {{ optional($token->meta)->last4 }}</span>

View File

@ -141,7 +141,7 @@
<label class="mr-4">
<input
type="radio"
data-token="{{ $token->token }}"
data-token="{{ $token->hashed_id }}"
name="payment-type"
class="form-radio cursor-pointer toggle-payment-with-token"/>
<span class="ml-1 cursor-pointer">**** {{ optional($token->meta)->last4 }}</span>

View File

@ -48,7 +48,8 @@
<div class="sm:flex sm:items-start sm:justify-between">
<div>
<h3 class="text-lg leading-6 font-medium text-gray-900">
{{ ctrans('texts.invoice_number_placeholder', ['invoice' => $invoice->number])}} - {{ ctrans('texts.unpaid') }}
{{ ctrans('texts.invoice_number_placeholder', ['invoice' => $invoice->number])}}
- {{ ctrans('texts.paid') }}
</h3>
</div>
</div>
@ -70,7 +71,7 @@
</svg>
</button>
</div>
<span class="text-sm text-gray-700 ml-2">{{ ctrans('texts.page') }}:
<span class="text-sm text-gray-700 ml-2">{{ ctrans('texts.page') }}:
<span id="current-page-container"></span>
<span>{{ strtolower(ctrans('texts.of')) }}</span>
<span id="total-page-container"></span>

View File

@ -21,7 +21,8 @@
</div>
</div>
<div class="mt-5 sm:mt-0 sm:ml-6 sm:flex-shrink-0 sm:flex sm:items-center">
<a href="{{ route('client.invoice.show', $invoice->hashed_id) }}?mode=portal" class="mr-4 text-primary">
<a href="{{ route('client.invoice.show', $invoice->hashed_id) }}?mode=portal"
class="mr-4 text-primary">
&#8592; {{ ctrans('texts.client_portal') }}
</a>
@ -36,15 +37,17 @@
</div>
</form>
@else
<div class="bg-white shadow sm:rounded-lg mb-4" translate>
<div class="bg-white shadow sm:rounded-lg mb-4">
<div class="px-4 py-5 sm:p-6">
<div class="sm:flex sm:items-start sm:justify-between">
<div>
<h3 class="text-lg leading-6 font-medium text-gray-900">
{{ ctrans('texts.invoice_number_placeholder', ['invoice' => $invoice->number])}}
- {{ ctrans('texts.unpaid') }}
</h3>
</div>
<h3 class="text-lg leading-6 font-medium text-gray-900">
{{ ctrans('texts.invoice_number_placeholder', ['invoice' => $invoice->number])}}
- {{ ctrans('texts.paid') }}
</h3>
<a href="{{ route('client.invoice.show', $invoice->hashed_id) }}?mode=portal"
class="mr-4 text-primary">
&#8592; {{ ctrans('texts.client_portal') }}
</a>
</div>
</div>
</div>