Minor fixeS

This commit is contained in:
David Bomba 2022-12-21 12:27:47 +11:00
parent cb823ef8b5
commit b1454d11ab
6 changed files with 22 additions and 8 deletions

View File

@ -110,7 +110,8 @@ class UpdateCompanyRequest extends Request
}
}
$settings['email_style_custom'] = str_replace(['{{','}}'], ['',''], $settings['email_style_custom']);
if(isset($settings['email_style_custom']))
$settings['email_style_custom'] = str_replace(['{{','}}'], ['',''], $settings['email_style_custom']);
if (! $account->isFreeHostedClient()) {
return $settings;

View File

@ -117,6 +117,11 @@ class Vendor extends BaseModel
}
public function timezone()
{
return $this->company->timezone();
}
public function company()
{
return $this->belongsTo(Company::class);

View File

@ -627,18 +627,16 @@ class StripePaymentDriver extends BaseDriver
public function processWebhookRequest(PaymentWebhookRequest $request)
{
// Allow app to catch up with webhook request.
sleep(2);
//payment_intent.succeeded - this will confirm or cancel the payment
if ($request->type === 'payment_intent.succeeded') {
PaymentIntentWebhook::dispatch($request->data, $request->company_key, $this->company_gateway->id)->delay(now()->addSeconds(rand(2, 10)));
PaymentIntentWebhook::dispatch($request->data, $request->company_key, $this->company_gateway->id)->delay(now()->addSeconds(rand(5, 10)));
return response()->json([], 200);
}
if (in_array($request->type, ['payment_intent.payment_failed', 'charge.failed'])) {
PaymentIntentFailureWebhook::dispatch($request->data, $request->company_key, $this->company_gateway->id)->delay(now()->addSeconds(rand(2, 10)));
PaymentIntentFailureWebhook::dispatch($request->data, $request->company_key, $this->company_gateway->id)->delay(now()->addSeconds(rand(5, 10)));
return response()->json([], 200);
}

View File

@ -129,12 +129,12 @@ class Helpers
if(!$string_hit)
return $value;
// 04-10-2022 Return Early if no reserved keywords are present, this is a very expensive process
// 04-10-2022 Return Early if no reserved keywords are present, this is a very expensive process
Carbon::setLocale($entity->locale());
if (!$currentDateTime) {
$currentDateTime = Carbon::now();
$currentDateTime = Carbon::now()->timezone($entity->timezone()->name);
}
$replacements = [

View File

@ -52,7 +52,7 @@ trait SettingsSaver
continue;
}
/*Separate loop if it is a _id field which is an integer cast as a string*/
elseif (substr($key, -3) == '_id' || substr($key, -14) == 'number_counter' || ($key == 'payment_terms' && strlen($settings->{$key}) >= 1) || ($key == 'valid_until' && property_exists($settings, $key) && strlen($settings->{$key}) >= 1)) {
elseif (substr($key, -3) == '_id' || substr($key, -14) == 'number_counter' || ($key == 'payment_terms' && property_exists($settings, $key) && strlen($settings->{$key}) >= 1) || ($key == 'valid_until' && property_exists($settings, $key) && strlen($settings->{$key}) >= 1)) {
$value = 'integer';
if($key == 'gmail_sending_user_id' || $key == 'besr_id')

View File

@ -70,4 +70,14 @@ class DatesTest extends TestCase
$this->assertFalse($date_in_future->gt(Carbon::parse($date_in_past)->addDays(14)));
}
/*Test time travelling behaves as expected */
public function testTimezoneShifts()
{
$this->travel(Carbon::parse('2022-12-20'));
$this->assertEquals('2022-12-20', now()->setTimeZone('Pacific/Midway')->format('Y-m-d'));
$this->travelBack();
}
}