mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-07 19:04:41 -04:00
Set most recent payment method as default
This commit is contained in:
parent
0138d8d246
commit
bff5b627fd
@ -132,7 +132,7 @@ class PaymentMethodController extends Controller
|
|||||||
public function destroy(ClientGatewayToken $payment_method)
|
public function destroy(ClientGatewayToken $payment_method)
|
||||||
{
|
{
|
||||||
/** @var \App\Models\ClientContact auth()->user() **/
|
/** @var \App\Models\ClientContact auth()->user() **/
|
||||||
$client_contact = auth()->user();
|
$client_contact = auth()->guard('contact')->user();
|
||||||
|
|
||||||
if ($payment_method->gateway()->exists()) {
|
if ($payment_method->gateway()->exists()) {
|
||||||
$payment_method->gateway
|
$payment_method->gateway
|
||||||
@ -145,9 +145,19 @@ class PaymentMethodController extends Controller
|
|||||||
event(new MethodDeleted($payment_method, auth()->guard('contact')->user()->company, Ninja::eventVars(auth()->guard('contact')->user()->id)));
|
event(new MethodDeleted($payment_method, auth()->guard('contact')->user()->company, Ninja::eventVars(auth()->guard('contact')->user()->id)));
|
||||||
|
|
||||||
$payment_method->is_deleted = true;
|
$payment_method->is_deleted = true;
|
||||||
|
$payment_method->is_default = false;
|
||||||
$payment_method->delete();
|
$payment_method->delete();
|
||||||
$payment_method->save();
|
$payment_method->save();
|
||||||
|
|
||||||
|
|
||||||
|
$def_cgt = auth()->guard('contact')->user()->client->gateway_tokens()->orderBy('id','desc')->first();
|
||||||
|
|
||||||
|
if($def_cgt)
|
||||||
|
{
|
||||||
|
$def_cgt->is_default = true;
|
||||||
|
$def_cgt->save();
|
||||||
|
}
|
||||||
|
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
nlog($e->getMessage());
|
nlog($e->getMessage());
|
||||||
|
|
||||||
|
@ -515,7 +515,7 @@ class BaseDriver extends AbstractPaymentDriver
|
|||||||
|
|
||||||
$cgt->save();
|
$cgt->save();
|
||||||
|
|
||||||
if ($this->client->gateway_tokens->count() == 1) {
|
if ($this->client->gateway_tokens->count() > 1) {
|
||||||
$this->client->gateway_tokens()->update(['is_default' => 0]);
|
$this->client->gateway_tokens()->update(['is_default' => 0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -326,7 +326,7 @@ class BaseRepository
|
|||||||
try{
|
try{
|
||||||
$model->service()->getEInvoice();
|
$model->service()->getEInvoice();
|
||||||
}
|
}
|
||||||
catch(\Exception $e){
|
catch(\Throwable $e){
|
||||||
nlog("EXCEPTION:: BASEREPOSITORY:: Error generating e_invoice for model {$model->id}");
|
nlog("EXCEPTION:: BASEREPOSITORY:: Error generating e_invoice for model {$model->id}");
|
||||||
nlog($e->getMessage());
|
nlog($e->getMessage());
|
||||||
}
|
}
|
||||||
|
@ -348,10 +348,11 @@ class Storecove
|
|||||||
private function httpClient(string $uri, string $verb, array $data, ?array $headers = [])
|
private function httpClient(string $uri, string $verb, array $data, ?array $headers = [])
|
||||||
{
|
{
|
||||||
|
|
||||||
try {
|
$r = Http::withToken(config('ninja.storecove_api_key'));
|
||||||
$r = Http::withToken(config('ninja.storecove_api_key'))
|
|
||||||
->withHeaders($this->getHeaders($headers))
|
try {
|
||||||
->{$verb}("{$this->base_url}{$uri}", $data)->throw();
|
$r->withHeaders($this->getHeaders($headers))
|
||||||
|
->{$verb}("{$this->base_url}{$uri}", $data)->throw();
|
||||||
}
|
}
|
||||||
catch (ClientException $e) {
|
catch (ClientException $e) {
|
||||||
// 4xx errors
|
// 4xx errors
|
||||||
|
@ -1278,7 +1278,7 @@ class Peppol extends AbstractService
|
|||||||
private function checkRequired(bool $required, string $section): self
|
private function checkRequired(bool $required, string $section): self
|
||||||
{
|
{
|
||||||
|
|
||||||
return $required ? throw new \Exception("e-invoice generation halted:: {$section} required") : $this;
|
return $required ? throw new \Exception("e-invoice generation halted:: {$section} required", 400) : $this;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user