Clean up for password resets

This commit is contained in:
David Bomba 2024-03-19 12:17:25 +11:00
parent abc3cc5897
commit 81385e4857
4 changed files with 66 additions and 10 deletions

View File

@ -69,6 +69,9 @@ class UpdateCalculatedFields
$project->save(); $project->save();
}); });
//Clean password resets table
\DB::connection($db)->table('password_resets')->where('created_at', '<', now()->subHour())->delete();
} }
} }
} }

View File

@ -292,7 +292,32 @@ class PayPalPPCPPaymentDriver extends BaseDriver
} }
try {
$r = $this->gatewayRequest("/v2/checkout/orders/{$orderID}/capture", 'post', ['body' => '']); $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;

View File

@ -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;
@ -212,6 +213,7 @@ 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
} }
try{
$r = $this->gatewayRequest("/v2/checkout/orders/{$orderID}/capture", 'post', ['body' => '']); $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;