Merge pull request #6819 from turbo124/v5-develop

Prevent duplicate payment records on hosted Stripe checkouts
This commit is contained in:
David Bomba 2021-10-11 17:05:46 +11:00 committed by GitHub
commit 81674435ab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 41 additions and 9 deletions

View File

@ -380,11 +380,11 @@ class PreviewController extends BaseController
return $maker->getCompiledHTML(); return $maker->getCompiledHTML();
} }
if (config('ninja.phantomjs_pdf_generation')) { if (config('ninja.phantomjs_pdf_generation') || config('ninja.pdf_generator') == 'phantom') {
return (new Phantom)->convertHtmlToPdf($maker->getCompiledHTML(true)); return (new Phantom)->convertHtmlToPdf($maker->getCompiledHTML(true));
} }
if(config('ninja.invoiceninja_hosted_pdf_generation')){ if(config('ninja.invoiceninja_hosted_pdf_generation') || config('ninja.pdf_generator') == 'hosted_ninja'){
return (new NinjaPdf())->build($maker->getCompiledHTML(true)); return (new NinjaPdf())->build($maker->getCompiledHTML(true));
} }

View File

@ -87,6 +87,10 @@ class Bancontact
{ {
/* @todo: https://github.com/invoiceninja/invoiceninja/pull/3789/files#r436175798 */ /* @todo: https://github.com/invoiceninja/invoiceninja/pull/3789/files#r436175798 */
//catch duplicate submissions.
if(Payment::where('transaction_reference', $payment_intent)->exists())
return redirect()->route('client.payments.index');
$this->stripe->init(); $this->stripe->init();
$data = [ $data = [

View File

@ -89,6 +89,10 @@ class EPS
$this->stripe->init(); $this->stripe->init();
//catch duplicate submissions.
if(Payment::where('transaction_reference', $payment_intent)->exists())
return redirect()->route('client.payments.index');
$data = [ $data = [
'payment_method' => $payment_intent, 'payment_method' => $payment_intent,
'payment_type' => PaymentType::EPS, 'payment_type' => PaymentType::EPS,

View File

@ -89,6 +89,10 @@ class GIROPAY
$this->stripe->init(); $this->stripe->init();
//catch duplicate submissions.
if(Payment::where('transaction_reference', $payment_intent)->exists())
return redirect()->route('client.payments.index');
$data = [ $data = [
'payment_method' => $payment_intent, 'payment_method' => $payment_intent,
'payment_type' => PaymentType::GIROPAY, 'payment_type' => PaymentType::GIROPAY,

View File

@ -89,6 +89,10 @@ class PRZELEWY24
$this->stripe->init(); $this->stripe->init();
//catch duplicate submissions.
if(Payment::where('transaction_reference', $payment_intent)->exists())
return redirect()->route('client.payments.index');
$data = [ $data = [
'payment_method' => $payment_intent, 'payment_method' => $payment_intent,
'payment_type' => PaymentType::PRZELEWY24, 'payment_type' => PaymentType::PRZELEWY24,

View File

@ -89,6 +89,10 @@ class iDeal
$this->stripe->init(); $this->stripe->init();
//catch duplicate submissions.
if(Payment::where('transaction_reference', $payment_intent)->exists())
return redirect()->route('client.payments.index');
$data = [ $data = [
'payment_method' => $payment_intent, 'payment_method' => $payment_intent,
'payment_type' => PaymentType::IDEAL, 'payment_type' => PaymentType::IDEAL,

View File

@ -46,7 +46,7 @@ class ApplyPaymentAmount extends AbstractService
} }
/*Don't double pay*/ /*Don't double pay*/
if ($this->invoice->statud_id == Invoice::STATUS_PAID) { if ($this->invoice->status_id == Invoice::STATUS_PAID) {
return $this->invoice; return $this->invoice;
} }

View File

@ -43,7 +43,7 @@ class MarkPaid extends AbstractService
} }
/*Don't double pay*/ /*Don't double pay*/
if ($this->invoice->statud_id == Invoice::STATUS_PAID) { if ($this->invoice->status_id == Invoice::STATUS_PAID) {
return $this->invoice; return $this->invoice;
} }
@ -96,7 +96,6 @@ class MarkPaid extends AbstractService
->save(); ->save();
$this->invoice->service()->workFlow()->save(); $this->invoice->service()->workFlow()->save();
// InvoiceWorkflowSettings::dispatchNow($this->invoice);
return $this->invoice; return $this->invoice;
} }

View File

@ -89,9 +89,9 @@ class SystemHealth
public static function getPdfEngine() public static function getPdfEngine()
{ {
if(config('ninja.invoiceninja_hosted_pdf_generation')) if(config('ninja.invoiceninja_hosted_pdf_generation') || config('ninja.pdf_generator') == 'hosted_ninja')
return 'Invoice Ninja Hosted PDF Generator'; return 'Invoice Ninja Hosted PDF Generator';
elseif(config('ninja.phantomjs_pdf_generation')) elseif(config('ninja.phantomjs_pdf_generation') || config('ninja.pdf_generator') == 'phantom')
return 'Phantom JS Web Generator'; return 'Phantom JS Web Generator';
else else
return 'SnapPDF PDF Generator'; return 'SnapPDF PDF Generator';

View File

@ -713,6 +713,19 @@ trait GeneratesCounter
$replace[] = $client->id_number; $replace[] = $client->id_number;
} }
$search[] = '{$user_custom1}';
$replace[] = $entity->user->custom_value1;
$search[] = '{$user_custom2}';
$replace[] = $entity->user->custom_value2;
$search[] = '{$user_custom3}';
$replace[] = $entity->user->custom_value3;
$search[] = '{$client_custom4}';
$replace[] = $entity->user->custom_value4;
return str_replace($search, $replace, $pattern); return str_replace($search, $replace, $pattern);
} }
} }

View File

@ -33,7 +33,8 @@ return [
'enabled_modules' => 32767, 'enabled_modules' => 32767,
'phantomjs_key' => env('PHANTOMJS_KEY', 'a-demo-key-with-low-quota-per-ip-address'), 'phantomjs_key' => env('PHANTOMJS_KEY', 'a-demo-key-with-low-quota-per-ip-address'),
'phantomjs_secret' => env('PHANTOMJS_SECRET', false), 'phantomjs_secret' => env('PHANTOMJS_SECRET', false),
'phantomjs_pdf_generation' => env('PHANTOMJS_PDF_GENERATION', true), 'phantomjs_pdf_generation' => env('PHANTOMJS_PDF_GENERATION', false),
'pdf_generator' => env('PDF_GENERATOR', false),
'trusted_proxies' => env('TRUSTED_PROXIES', false), 'trusted_proxies' => env('TRUSTED_PROXIES', false),
'is_docker' => env('IS_DOCKER', false), 'is_docker' => env('IS_DOCKER', false),
'local_download' => env('LOCAL_DOWNLOAD', false), 'local_download' => env('LOCAL_DOWNLOAD', false),
@ -173,6 +174,5 @@ return [
'ninja_default_company_id' => env('NINJA_COMPANY_ID', null), 'ninja_default_company_id' => env('NINJA_COMPANY_ID', null),
'ninja_default_company_gateway_id' => env('NINJA_COMPANY_GATEWAY_ID', null), 'ninja_default_company_gateway_id' => env('NINJA_COMPANY_GATEWAY_ID', null),
'ninja_hosted_secret' => env('NINJA_HOSTED_SECRET', null), 'ninja_hosted_secret' => env('NINJA_HOSTED_SECRET', null),
'pdf_generator' => env('PDF_GENERATOR', false),
'internal_queue_enabled' => env('INTERNAL_QUEUE_ENABLED', true), 'internal_queue_enabled' => env('INTERNAL_QUEUE_ENABLED', true),
]; ];