mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Clean up for password resets
This commit is contained in:
parent
abc3cc5897
commit
81385e4857
@ -63,11 +63,14 @@ class UpdateCalculatedFields
|
|||||||
Project::query()->with('tasks')->whereHas('tasks', function ($query) {
|
Project::query()->with('tasks')->whereHas('tasks', function ($query) {
|
||||||
$query->where('updated_at', '>', now()->subHours(2));
|
$query->where('updated_at', '>', now()->subHours(2));
|
||||||
})
|
})
|
||||||
->cursor()
|
->cursor()
|
||||||
->each(function ($project) {
|
->each(function ($project) {
|
||||||
$project->current_hours = $this->calculateDuration($project);
|
$project->current_hours = $this->calculateDuration($project);
|
||||||
$project->save();
|
$project->save();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
//Clean password resets table
|
||||||
|
\DB::connection($db)->table('password_resets')->where('created_at', '<', now()->subHour())->delete();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -292,7 +292,32 @@ class PayPalPPCPPaymentDriver extends BaseDriver
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$r = $this->gatewayRequest("/v2/checkout/orders/{$orderID}/capture", 'post', ['body' => '']);
|
try {
|
||||||
|
$r = $this->gatewayRequest("/v2/checkout/orders/{$orderID}/capture", 'post', ['body' => '']);
|
||||||
|
} catch(\Exception $e) {
|
||||||
|
|
||||||
|
//Rescue for duplicate invoice_id
|
||||||
|
if(stripos($e->getMessage(), 'DUPLICATE_INVOICE_ID') !== false) {
|
||||||
|
|
||||||
|
|
||||||
|
$_invoice = collect($this->payment_hash->data->invoices)->first();
|
||||||
|
$invoice = Invoice::withTrashed()->find($this->decodePrimaryKey($_invoice->invoice_id));
|
||||||
|
$new_invoice_number = $invoice->number."_".Str::random(5);
|
||||||
|
|
||||||
|
$update_data =
|
||||||
|
[[
|
||||||
|
"op" => "replace",
|
||||||
|
"path" => "/purchase_units/@reference_id=='default'/invoice_id",
|
||||||
|
"value" => $new_invoice_number,
|
||||||
|
]];
|
||||||
|
|
||||||
|
$r = $this->gatewayRequest("/v2/checkout/orders/{$orderID}", 'patch', $update_data);
|
||||||
|
|
||||||
|
$r = $this->gatewayRequest("/v2/checkout/orders/{$orderID}/capture", 'post', ['body' => '']);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
$response = $r;
|
$response = $r;
|
||||||
|
|
||||||
|
@ -18,6 +18,7 @@ use App\Models\Invoice;
|
|||||||
use App\Models\SystemLog;
|
use App\Models\SystemLog;
|
||||||
use App\Models\GatewayType;
|
use App\Models\GatewayType;
|
||||||
use App\Models\PaymentType;
|
use App\Models\PaymentType;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
use App\Jobs\Util\SystemLogger;
|
use App\Jobs\Util\SystemLogger;
|
||||||
use App\Utils\Traits\MakesHash;
|
use App\Utils\Traits\MakesHash;
|
||||||
use App\Exceptions\PaymentFailed;
|
use App\Exceptions\PaymentFailed;
|
||||||
@ -211,7 +212,8 @@ class PayPalRestPaymentDriver extends BaseDriver
|
|||||||
|
|
||||||
$request['gateway_response'] = str_replace("Error: ", "", $request['gateway_response']);
|
$request['gateway_response'] = str_replace("Error: ", "", $request['gateway_response']);
|
||||||
$response = json_decode($request['gateway_response'], true);
|
$response = json_decode($request['gateway_response'], true);
|
||||||
|
|
||||||
|
nlog($response);
|
||||||
//capture
|
//capture
|
||||||
$orderID = $response['orderID'];
|
$orderID = $response['orderID'];
|
||||||
|
|
||||||
@ -235,7 +237,33 @@ class PayPalRestPaymentDriver extends BaseDriver
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$r = $this->gatewayRequest("/v2/checkout/orders/{$orderID}/capture", 'post', ['body' => '']);
|
try{
|
||||||
|
$r = $this->gatewayRequest("/v2/checkout/orders/{$orderID}/capture", 'post', ['body' => '']);
|
||||||
|
}
|
||||||
|
catch(\Exception $e) {
|
||||||
|
|
||||||
|
//Rescue for duplicate invoice_id
|
||||||
|
if(stripos($e->getMessage(), 'DUPLICATE_INVOICE_ID') !== false){
|
||||||
|
|
||||||
|
|
||||||
|
$_invoice = collect($this->payment_hash->data->invoices)->first();
|
||||||
|
$invoice = Invoice::withTrashed()->find($this->decodePrimaryKey($_invoice->invoice_id));
|
||||||
|
$new_invoice_number = $invoice->number."_".Str::random(5);
|
||||||
|
|
||||||
|
$update_data =
|
||||||
|
[[
|
||||||
|
"op" => "replace",
|
||||||
|
"path" => "/purchase_units/@reference_id=='default'/invoice_id",
|
||||||
|
"value" => $new_invoice_number,
|
||||||
|
]];
|
||||||
|
|
||||||
|
$r = $this->gatewayRequest("/v2/checkout/orders/{$orderID}", 'patch', $update_data);
|
||||||
|
|
||||||
|
$r = $this->gatewayRequest("/v2/checkout/orders/{$orderID}/capture", 'post', ['body' => '']);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
$response = $r;
|
$response = $r;
|
||||||
|
|
||||||
|
@ -46,8 +46,8 @@
|
|||||||
|
|
||||||
var errorDetail = Array.isArray(data.details) && data.details[0];
|
var errorDetail = Array.isArray(data.details) && data.details[0];
|
||||||
if (errorDetail && ['INSTRUMENT_DECLINED', 'PAYER_ACTION_REQUIRED'].includes(errorDetail.issue)) {
|
if (errorDetail && ['INSTRUMENT_DECLINED', 'PAYER_ACTION_REQUIRED'].includes(errorDetail.issue)) {
|
||||||
return actions.restart();
|
return actions.restart();
|
||||||
}
|
}
|
||||||
|
|
||||||
document.getElementById("gateway_response").value =JSON.stringify( data );
|
document.getElementById("gateway_response").value =JSON.stringify( data );
|
||||||
document.getElementById("server_response").submit();
|
document.getElementById("server_response").submit();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user