diff --git a/app/Http/Livewire/RequiredClientInfo.php b/app/Http/Livewire/RequiredClientInfo.php index 8b7b37eea251..8b646a39e0f2 100644 --- a/app/Http/Livewire/RequiredClientInfo.php +++ b/app/Http/Livewire/RequiredClientInfo.php @@ -36,6 +36,10 @@ class RequiredClientInfo extends Component */ public $invoice; + /** + * @var bool + */ + public $terms_accepted = true; /** * @var array @@ -82,6 +86,11 @@ class RequiredClientInfo extends Component 'client_shipping_postal_code' => 'shipping_postal_code', 'client_shipping_country_id' => 'shipping_country_id', + 'client_custom_value1' => 'custom_value1', + 'client_custom_value2' => 'custom_value2', + 'client_custom_value3' => 'custom_value3', + 'client_custom_value4' => 'custom_value4', + 'contact_first_name' => 'first_name', 'contact_last_name' => 'last_name', 'contact_email' => 'email', @@ -122,6 +131,10 @@ class RequiredClientInfo extends Component 'client.name' => '', 'client.website' => '', 'client.phone' => '', + 'client.custom_value1' => '', + 'client.custom_value2' => '', + 'client.custom_value3' => '', + 'client.custom_value4' => '', ]; public $show_form = false; @@ -136,13 +149,11 @@ class RequiredClientInfo extends Component $this->client = $this->contact->client; - count($this->fields) > 0 - ? $this->checkFields() - : $this->show_form = false; - - if($this->company->settings->show_accept_invoice_terms && request()->has('hash')) + if($this->company->settings->show_accept_invoice_terms && request()->query('hash')) { $this->show_terms = true; + $this->terms_accepted = false; + $this->show_form = true; $hash = Cache::get(request()->input('hash')); @@ -150,6 +161,15 @@ class RequiredClientInfo extends Component } + count($this->fields) > 0 || $this->show_terms + ? $this->checkFields() + : $this->show_form = false; + + } + + public function toggleTermsAccepted() + { + $this->terms_accepted = !$this->terms_accepted; } @@ -189,7 +209,7 @@ class RequiredClientInfo extends Component private function updateClientDetails(array $data): bool { - nlog($this->company->id); + $client = []; $contact = []; @@ -249,9 +269,6 @@ class RequiredClientInfo extends Component } } } - - if($this->show_terms) - $this->show_form = true; } diff --git a/app/Models/CompanyGateway.php b/app/Models/CompanyGateway.php index a31dc174602d..bdee65f7fe5f 100644 --- a/app/Models/CompanyGateway.php +++ b/app/Models/CompanyGateway.php @@ -43,6 +43,10 @@ class CompanyGateway extends BaseModel 'require_client_phone', 'require_contact_name', 'require_contact_email', + 'require_custom_value1', + 'require_custom_value2', + 'require_custom_value3', + 'require_custom_value4', 'update_details', 'config', 'fees_and_limits', diff --git a/app/PaymentDrivers/AuthorizePaymentDriver.php b/app/PaymentDrivers/AuthorizePaymentDriver.php index cc8ca48c99f8..ab6e98f05f24 100644 --- a/app/PaymentDrivers/AuthorizePaymentDriver.php +++ b/app/PaymentDrivers/AuthorizePaymentDriver.php @@ -67,17 +67,6 @@ class AuthorizePaymentDriver extends BaseDriver public function getClientRequiredFields(): array { - $fields = []; - - if ($this->company_gateway->require_shipping_address) { - $fields[] = ['name' => 'client_shipping_address_line_1', 'label' => ctrans('texts.shipping_address1'), 'type' => 'text', 'validation' => 'required']; - $fields[] = ['name' => 'client_shipping_city', 'label' => ctrans('texts.shipping_city'), 'type' => 'text', 'validation' => 'required']; - $fields[] = ['name' => 'client_shipping_state', 'label' => ctrans('texts.shipping_state'), 'type' => 'text', 'validation' => 'required']; - $fields[] = ['name' => 'client_shipping_postal_code', 'label' => ctrans('texts.shipping_postal_code'), 'type' => 'text', 'validation' => 'required']; - $fields[] = ['name' => 'client_shipping_country_id', 'label' => ctrans('texts.shipping_country'), 'type' => 'text', 'validation' => 'required']; - } - - $data = [ ['name' => 'client_name', 'label' => ctrans('texts.name'), 'type' => 'text', 'validation' => 'required|min:2'], ['name' => 'contact_email', 'label' => ctrans('texts.email'), 'type' => 'text', 'validation' => 'required|email:rfc'], @@ -88,7 +77,43 @@ class AuthorizePaymentDriver extends BaseDriver ['name' => 'client_country_id', 'label' => ctrans('texts.country'), 'type' => 'select', 'validation' => 'required'], ]; - return array_merge($fields, $data); + $fields = []; + + if ($this->company_gateway->require_shipping_address) { + $fields[] = ['name' => 'client_shipping_address_line_1', 'label' => ctrans('texts.shipping_address1'), 'type' => 'text', 'validation' => 'required']; + $fields[] = ['name' => 'client_shipping_city', 'label' => ctrans('texts.shipping_city'), 'type' => 'text', 'validation' => 'required']; + $fields[] = ['name' => 'client_shipping_state', 'label' => ctrans('texts.shipping_state'), 'type' => 'text', 'validation' => 'required']; + $fields[] = ['name' => 'client_shipping_postal_code', 'label' => ctrans('texts.shipping_postal_code'), 'type' => 'text', 'validation' => 'required']; + $fields[] = ['name' => 'client_shipping_country_id', 'label' => ctrans('texts.shipping_country'), 'type' => 'text', 'validation' => 'required']; + } + + if ($this->company_gateway->require_custom_value1) { + + $fields[] = ['name' => 'client_custom_value1', 'label' => $this->helpers->makeCustomField($this->client->company->custom_fields, 'client1'), 'type' => 'text', 'validation' => 'required']; + + } + + + if ($this->company_gateway->require_custom_value2) { + + $fields[] = ['name' => 'client_custom_value2', 'label' => $this->helpers->makeCustomField($this->client->company->custom_fields, 'client2'), 'type' => 'text', 'validation' => 'required']; + + } + + + if ($this->company_gateway->require_custom_value3) { + + $fields[] = ['name' => 'client_custom_value3', 'label' => $this->helpers->makeCustomField($this->client->company->custom_fields, 'client3'), 'type' => 'text', 'validation' => 'required']; + + } + + if ($this->company_gateway->require_custom_value4) { + + $fields[] = ['name' => 'client_custom_value4', 'label' => $this->helpers->makeCustomField($this->client->company->custom_fields, 'client4'), 'type' => 'text', 'validation' => 'required']; + + } + + return array_merge($data, $fields); } diff --git a/app/PaymentDrivers/BaseDriver.php b/app/PaymentDrivers/BaseDriver.php index aa31a96164b5..1af79af33999 100644 --- a/app/PaymentDrivers/BaseDriver.php +++ b/app/PaymentDrivers/BaseDriver.php @@ -35,6 +35,7 @@ use App\Models\PaymentType; use App\Models\SystemLog; use App\Models\TransactionEvent; use App\Services\Subscription\SubscriptionService; +use App\Utils\Helpers; use App\Utils\Ninja; use App\Utils\Traits\MakesHash; use App\Utils\Traits\SystemLogTrait; @@ -76,6 +77,8 @@ class BaseDriver extends AbstractPaymentDriver /* PaymentHash */ public $payment_hash; + public $helpers; + /* Array of payment methods */ public static $methods = []; @@ -87,6 +90,7 @@ class BaseDriver extends AbstractPaymentDriver $this->company_gateway = $company_gateway; $this->invitation = $invitation; $this->client = $client; + $this->helpers = new Helpers(); } /** @@ -94,9 +98,75 @@ class BaseDriver extends AbstractPaymentDriver * * @return array[] */ + public function getClientRequiredFields(): array { - return []; + $fields = []; + + if ($this->company_gateway->require_client_name) { + $fields[] = ['name' => 'client_name', 'label' => ctrans('texts.client_name'), 'type' => 'text', 'validation' => 'required']; + } + + if ($this->company_gateway->require_contact_name) { + $fields[] = ['name' => 'contact_first_name', 'label' => ctrans('texts.first_name'), 'type' => 'text', 'validation' => 'required']; + $fields[] = ['name' => 'contact_last_name', 'label' => ctrans('texts.last_name'), 'type' => 'text', 'validation' => 'required']; + } + + if ($this->company_gateway->require_contact_email) { + $fields[] = ['name' => 'contact_email', 'label' => ctrans('texts.email'), 'type' => 'text', 'validation' => 'required,email:rfc']; + } + + if ($this->company_gateway->require_client_phone) { + $fields[] = ['name' => 'client_phone', 'label' => ctrans('texts.client_phone'), 'type' => 'tel', 'validation' => 'required']; + } + + if ($this->company_gateway->require_billing_address) { + $fields[] = ['name' => 'client_address_line_1', 'label' => ctrans('texts.address1'), 'type' => 'text', 'validation' => 'required']; + $fields[] = ['name' => 'client_city', 'label' => ctrans('texts.city'), 'type' => 'text', 'validation' => 'required']; + $fields[] = ['name' => 'client_state', 'label' => ctrans('texts.state'), 'type' => 'text', 'validation' => 'required']; + $fields[] = ['name' => 'client_country_id', 'label' => ctrans('texts.country'), 'type' => 'text', 'validation' => 'required']; + } + + if ($this->company_gateway->require_postal_code) { + $fields[] = ['name' => 'client_postal_code', 'label' => ctrans('texts.postal_code'), 'type' => 'text', 'validation' => 'required']; + } + + if ($this->company_gateway->require_shipping_address) { + $fields[] = ['name' => 'client_shipping_address_line_1', 'label' => ctrans('texts.shipping_address1'), 'type' => 'text', 'validation' => 'required']; + $fields[] = ['name' => 'client_shipping_city', 'label' => ctrans('texts.shipping_city'), 'type' => 'text', 'validation' => 'required']; + $fields[] = ['name' => 'client_shipping_state', 'label' => ctrans('texts.shipping_state'), 'type' => 'text', 'validation' => 'required']; + $fields[] = ['name' => 'client_shipping_postal_code', 'label' => ctrans('texts.shipping_postal_code'), 'type' => 'text', 'validation' => 'required']; + $fields[] = ['name' => 'client_shipping_country_id', 'label' => ctrans('texts.shipping_country'), 'type' => 'text', 'validation' => 'required']; + } + + if ($this->company_gateway->require_custom_value1) { + + $fields[] = ['name' => 'client_custom_value1', 'label' => $this->helpers->makeCustomField($this->client->company->custom_fields, 'client1'), 'type' => 'text', 'validation' => 'required']; + + } + + if ($this->company_gateway->require_custom_value2) { + + $fields[] = ['name' => 'client_custom_value2', 'label' => $this->helpers->makeCustomField($this->client->company->custom_fields, 'client2'), 'type' => 'text', 'validation' => 'required']; + + } + + + if ($this->company_gateway->require_custom_value3) { + + $fields[] = ['name' => 'client_custom_value3', 'label' => $this->helpers->makeCustomField($this->client->company->custom_fields, 'client3'), 'type' => 'text', 'validation' => 'required']; + + } + + + if ($this->company_gateway->require_custom_value4) { + + $fields[] = ['name' => 'client_custom_value4', 'label' => $this->helpers->makeCustomField($this->client->company->custom_fields, 'client4'), 'type' => 'text', 'validation' => 'required']; + + } + + return $fields; + } /** @@ -592,22 +662,7 @@ class BaseDriver extends AbstractPaymentDriver $this->required_fields[] = 'phone'; } } - - // if ($this->company_gateway->require_contact_email) { - // if ($this->checkRequiredResource($this->email)) { - // $this->required_fields[] = 'contact_email'; - // } - // } - - // if ($this->company_gateway->require_contact_name) { - // if ($this->checkRequiredResource($this->first_name)) { - // $this->required_fields[] = 'contact_first_name'; - // } - - // if ($this->checkRequiredResource($this->last_name)) { - // $this->required_fields[] = 'contact_last_name'; - // } - // } + if ($this->company_gateway->require_postal_code) { // In case "require_postal_code" is true, we don't need billing address. diff --git a/app/PaymentDrivers/CheckoutComPaymentDriver.php b/app/PaymentDrivers/CheckoutComPaymentDriver.php index 13eb4532dca8..74a33e8fc751 100644 --- a/app/PaymentDrivers/CheckoutComPaymentDriver.php +++ b/app/PaymentDrivers/CheckoutComPaymentDriver.php @@ -155,49 +155,6 @@ class CheckoutComPaymentDriver extends BaseDriver return 'gateways.checkout.credit_card.pay'; } - public function getClientRequiredFields(): array - { - $fields = []; - - if ($this->company_gateway->require_client_name) { - $fields[] = ['name' => 'client_name', 'label' => ctrans('texts.client_name'), 'type' => 'text', 'validation' => 'required']; - } - - if ($this->company_gateway->require_contact_name) { - $fields[] = ['name' => 'contact_first_name', 'label' => ctrans('texts.first_name'), 'type' => 'text', 'validation' => 'required']; - $fields[] = ['name' => 'contact_last_name', 'label' => ctrans('texts.last_name'), 'type' => 'text', 'validation' => 'required']; - } - - if ($this->company_gateway->require_contact_email) { - $fields[] = ['name' => 'contact_email', 'label' => ctrans('texts.email'), 'type' => 'text', 'validation' => 'required,email:rfc']; - } - - if ($this->company_gateway->require_client_phone) { - $fields[] = ['name' => 'client_phone', 'label' => ctrans('texts.client_phone'), 'type' => 'tel', 'validation' => 'required']; - } - - if ($this->company_gateway->require_billing_address) { - $fields[] = ['name' => 'client_address_line_1', 'label' => ctrans('texts.address1'), 'type' => 'text', 'validation' => 'required']; - $fields[] = ['name' => 'client_city', 'label' => ctrans('texts.city'), 'type' => 'text', 'validation' => 'required']; - $fields[] = ['name' => 'client_state', 'label' => ctrans('texts.state'), 'type' => 'text', 'validation' => 'required']; - $fields[] = ['name' => 'client_country_id', 'label' => ctrans('texts.country'), 'type' => 'text', 'validation' => 'required']; - } - - if ($this->company_gateway->require_postal_code) { - $fields[] = ['name' => 'client_postal_code', 'label' => ctrans('texts.postal_code'), 'type' => 'text', 'validation' => 'required']; - } - - if ($this->company_gateway->require_shipping_address) { - $fields[] = ['name' => 'client_shipping_address_line_1', 'label' => ctrans('texts.shipping_address1'), 'type' => 'text', 'validation' => 'required']; - $fields[] = ['name' => 'client_shipping_city', 'label' => ctrans('texts.shipping_city'), 'type' => 'text', 'validation' => 'required']; - $fields[] = ['name' => 'client_shipping_state', 'label' => ctrans('texts.shipping_state'), 'type' => 'text', 'validation' => 'required']; - $fields[] = ['name' => 'client_shipping_postal_code', 'label' => ctrans('texts.shipping_postal_code'), 'type' => 'text', 'validation' => 'required']; - $fields[] = ['name' => 'client_shipping_country_id', 'label' => ctrans('texts.shipping_country'), 'type' => 'text', 'validation' => 'required']; - } - - return $fields; - } - public function authorizeView($data) { return $this->payment_method->authorizeView($data); diff --git a/app/PaymentDrivers/EwayPaymentDriver.php b/app/PaymentDrivers/EwayPaymentDriver.php index 39b24a29a726..1db813f41120 100644 --- a/app/PaymentDrivers/EwayPaymentDriver.php +++ b/app/PaymentDrivers/EwayPaymentDriver.php @@ -191,6 +191,32 @@ class EwayPaymentDriver extends BaseDriver $fields[] = ['name' => 'client_shipping_country_id', 'label' => ctrans('texts.shipping_country'), 'type' => 'text', 'validation' => 'required']; } + if ($this->company_gateway->require_custom_value1) { + + $fields[] = ['name' => 'client_custom_value1', 'label' => $this->helpers->makeCustomField($this->client->company->custom_fields, 'client1'), 'type' => 'text', 'validation' => 'required']; + + } + + if ($this->company_gateway->require_custom_value2) { + + $fields[] = ['name' => 'client_custom_value2', 'label' => $this->helpers->makeCustomField($this->client->company->custom_fields, 'client2'), 'type' => 'text', 'validation' => 'required']; + + } + + if ($this->company_gateway->require_custom_value3) { + + $fields[] = ['name' => 'client_custom_value3', 'label' => $this->helpers->makeCustomField($this->client->company->custom_fields, 'client3'), 'type' => 'text', 'validation' => 'required']; + + } + + + if ($this->company_gateway->require_custom_value4) { + + $fields[] = ['name' => 'client_custom_value4', 'label' => $this->helpers->makeCustomField($this->client->company->custom_fields, 'client4'), 'type' => 'text', 'validation' => 'required']; + + } + + return $fields; } } diff --git a/app/PaymentDrivers/PaytracePaymentDriver.php b/app/PaymentDrivers/PaytracePaymentDriver.php index 04f722b73864..2aeb6d8e3079 100644 --- a/app/PaymentDrivers/PaytracePaymentDriver.php +++ b/app/PaymentDrivers/PaytracePaymentDriver.php @@ -12,6 +12,7 @@ namespace App\PaymentDrivers; use App\Exceptions\SystemError; +use App\Http\Requests\Payments\PaymentWebhookRequest; use App\Jobs\Util\SystemLogger; use App\Models\ClientGatewayToken; use App\Models\GatewayType; @@ -166,51 +167,6 @@ class PaytracePaymentDriver extends BaseDriver $this->processUnsuccessfulTransaction($data, false); } - public function getClientRequiredFields(): array - { - $fields = []; - - if ($this->company_gateway->require_client_name) { - $fields[] = ['name' => 'client_name', 'label' => ctrans('texts.client_name'), 'type' => 'text', 'validation' => 'required']; - } - - if ($this->company_gateway->require_contact_name) { - $fields[] = ['name' => 'contact_first_name', 'label' => ctrans('texts.first_name'), 'type' => 'text', 'validation' => 'required']; - $fields[] = ['name' => 'contact_last_name', 'label' => ctrans('texts.last_name'), 'type' => 'text', 'validation' => 'required']; - } - - if ($this->company_gateway->require_contact_email) { - $fields[] = ['name' => 'contact_email', 'label' => ctrans('texts.email'), 'type' => 'text', 'validation' => 'required,email:rfc']; - } - - if ($this->company_gateway->require_client_phone) { - $fields[] = ['name' => 'client_phone', 'label' => ctrans('texts.client_phone'), 'type' => 'tel', 'validation' => 'required']; - } - - $fields[] = ['name' => 'client_address_line_1', 'label' => ctrans('texts.address1'), 'type' => 'text', 'validation' => 'required']; - - if ($this->company_gateway->require_billing_address) { - $fields[] = ['name' => 'client_city', 'label' => ctrans('texts.city'), 'type' => 'text', 'validation' => 'required']; - $fields[] = ['name' => 'client_state', 'label' => ctrans('texts.state'), 'type' => 'text', 'validation' => 'required']; - $fields[] = ['name' => 'client_country_id', 'label' => ctrans('texts.country'), 'type' => 'text', 'validation' => 'required']; - } - - // if ($this->company_gateway->require_postal_code) { - $fields[] = ['name' => 'client_postal_code', 'label' => ctrans('texts.postal_code'), 'type' => 'text', 'validation' => 'required']; - $fields[] = ['name' => 'client_shipping_city', 'label' => ctrans('texts.shipping_city'), 'type' => 'text', 'validation' => 'required']; - $fields[] = ['name' => 'client_shipping_state', 'label' => ctrans('texts.shipping_state'), 'type' => 'text', 'validation' => 'required']; - - // } - - if ($this->company_gateway->require_shipping_address) { - $fields[] = ['name' => 'client_shipping_address_line_1', 'label' => ctrans('texts.shipping_address1'), 'type' => 'text', 'validation' => 'required']; - $fields[] = ['name' => 'client_shipping_postal_code', 'label' => ctrans('texts.shipping_postal_code'), 'type' => 'text', 'validation' => 'required']; - $fields[] = ['name' => 'client_shipping_country_id', 'label' => ctrans('texts.shipping_country'), 'type' => 'text', 'validation' => 'required']; - } - - return $fields; - } - public function processWebhookRequest(PaymentWebhookRequest $request, Payment $payment = null) { } diff --git a/app/PaymentDrivers/SquarePaymentDriver.php b/app/PaymentDrivers/SquarePaymentDriver.php index 72b9ce9a8248..2a92d18321e7 100644 --- a/app/PaymentDrivers/SquarePaymentDriver.php +++ b/app/PaymentDrivers/SquarePaymentDriver.php @@ -182,48 +182,6 @@ class SquarePaymentDriver extends BaseDriver { } - public function getClientRequiredFields(): array - { - $fields = []; - - if ($this->company_gateway->require_client_name) { - $fields[] = ['name' => 'client_name', 'label' => ctrans('texts.client_name'), 'type' => 'text', 'validation' => 'required']; - } - - if ($this->company_gateway->require_contact_name) { - $fields[] = ['name' => 'contact_first_name', 'label' => ctrans('texts.first_name'), 'type' => 'text', 'validation' => 'required']; - $fields[] = ['name' => 'contact_last_name', 'label' => ctrans('texts.last_name'), 'type' => 'text', 'validation' => 'required']; - } - - if ($this->company_gateway->require_contact_email) { - $fields[] = ['name' => 'contact_email', 'label' => ctrans('texts.email'), 'type' => 'text', 'validation' => 'required,email:rfc']; - } - - if ($this->company_gateway->require_client_phone) { - $fields[] = ['name' => 'client_phone', 'label' => ctrans('texts.client_phone'), 'type' => 'tel', 'validation' => 'required']; - } - - if ($this->company_gateway->require_billing_address) { - $fields[] = ['name' => 'client_address_line_1', 'label' => ctrans('texts.address1'), 'type' => 'text', 'validation' => 'required']; -// $fields[] = ['name' => 'client_address_line_2', 'label' => ctrans('texts.address2'), 'type' => 'text', 'validation' => 'nullable']; - $fields[] = ['name' => 'client_postal_code', 'label' => ctrans('texts.postal_code'), 'type' => 'text', 'validation' => 'required']; - $fields[] = ['name' => 'client_city', 'label' => ctrans('texts.city'), 'type' => 'text', 'validation' => 'required']; - $fields[] = ['name' => 'client_state', 'label' => ctrans('texts.state'), 'type' => 'text', 'validation' => 'required']; - $fields[] = ['name' => 'client_country_id', 'label' => ctrans('texts.country'), 'type' => 'text', 'validation' => 'required']; - } - - if ($this->company_gateway->require_shipping_address) { - $fields[] = ['name' => 'client_shipping_address_line_1', 'label' => ctrans('texts.shipping_address1'), 'type' => 'text', 'validation' => 'required']; -// $fields[] = ['name' => 'client_shipping_address_line_2', 'label' => ctrans('texts.shipping_address2'), 'type' => 'text', 'validation' => 'sometimes']; - $fields[] = ['name' => 'client_shipping_city', 'label' => ctrans('texts.shipping_city'), 'type' => 'text', 'validation' => 'required']; - $fields[] = ['name' => 'client_shipping_state', 'label' => ctrans('texts.shipping_state'), 'type' => 'text', 'validation' => 'required']; - $fields[] = ['name' => 'client_shipping_postal_code', 'label' => ctrans('texts.shipping_postal_code'), 'type' => 'text', 'validation' => 'required']; - $fields[] = ['name' => 'client_shipping_country_id', 'label' => ctrans('texts.shipping_country'), 'type' => 'text', 'validation' => 'required']; - } - - return $fields; - } - public function convertAmount($amount) { $precision = $this->client->currency()->precision; diff --git a/app/PaymentDrivers/StripePaymentDriver.php b/app/PaymentDrivers/StripePaymentDriver.php index f7b064961845..71530b9c989b 100644 --- a/app/PaymentDrivers/StripePaymentDriver.php +++ b/app/PaymentDrivers/StripePaymentDriver.php @@ -354,6 +354,34 @@ class StripePaymentDriver extends BaseDriver $fields[] = ['name' => 'client_shipping_country_id', 'label' => ctrans('texts.shipping_country'), 'type' => 'text', 'validation' => 'required']; } + if ($this->company_gateway->require_custom_value1) { + + $fields[] = ['name' => 'client_custom_value1', 'label' => $this->helpers->makeCustomField($this->client->company->custom_fields, 'client1'), 'type' => 'text', 'validation' => 'required']; + + } + + + if ($this->company_gateway->require_custom_value2) { + + $fields[] = ['name' => 'client_custom_value2', 'label' => $this->helpers->makeCustomField($this->client->company->custom_fields, 'client2'), 'type' => 'text', 'validation' => 'required']; + + } + + + if ($this->company_gateway->require_custom_value3) { + + $fields[] = ['name' => 'client_custom_value3', 'label' => $this->helpers->makeCustomField($this->client->company->custom_fields, 'client3'), 'type' => 'text', 'validation' => 'required']; + + } + + + if ($this->company_gateway->require_custom_value4) { + + $fields[] = ['name' => 'client_custom_value4', 'label' => $this->helpers->makeCustomField($this->client->company->custom_fields, 'client4'), 'type' => 'text', 'validation' => 'required']; + + } + + return $fields; } diff --git a/app/PaymentDrivers/WePayPaymentDriver.php b/app/PaymentDrivers/WePayPaymentDriver.php index 7fe58d2cd8bb..862329adeea9 100644 --- a/app/PaymentDrivers/WePayPaymentDriver.php +++ b/app/PaymentDrivers/WePayPaymentDriver.php @@ -342,6 +342,36 @@ class WePayPaymentDriver extends BaseDriver $fields[] = ['name' => 'client_shipping_country_id', 'label' => ctrans('texts.shipping_country'), 'type' => 'text', 'validation' => 'required']; } + + + if ($this->company_gateway->require_custom_value1) { + + $fields[] = ['name' => 'client_custom_value1', 'label' => $this->helpers->makeCustomField($this->client->company->custom_fields, 'client1'), 'type' => 'text', 'validation' => 'required']; + + } + + if ($this->company_gateway->require_custom_value2) { + + $fields[] = ['name' => 'client_custom_value2', 'label' => $this->helpers->makeCustomField($this->client->company->custom_fields, 'client2'), 'type' => 'text', 'validation' => 'required']; + + } + + + if ($this->company_gateway->require_custom_value3) { + + $fields[] = ['name' => 'client_custom_value3', 'label' => $this->helpers->makeCustomField($this->client->company->custom_fields, 'client3'), 'type' => 'text', 'validation' => 'required']; + + } + + + if ($this->company_gateway->require_custom_value4) { + + $fields[] = ['name' => 'client_custom_value4', 'label' => $this->helpers->makeCustomField($this->client->company->custom_fields, 'client4'), 'type' => 'text', 'validation' => 'required']; + + } + + + return $fields; } } diff --git a/app/Transformers/CompanyGatewayTransformer.php b/app/Transformers/CompanyGatewayTransformer.php index 1edd7dc12e74..6ac1aed2aeab 100644 --- a/app/Transformers/CompanyGatewayTransformer.php +++ b/app/Transformers/CompanyGatewayTransformer.php @@ -60,6 +60,10 @@ class CompanyGatewayTransformer extends EntityTransformer 'require_client_phone' => (bool) $company_gateway->require_client_phone, 'require_contact_name' => (bool) $company_gateway->require_contact_name, 'require_contact_email' => (bool) $company_gateway->require_contact_email, + 'require_custom_value1' => (bool) $company_gateway->require_custom_value1, + 'require_custom_value2' => (bool) $company_gateway->require_custom_value2, + 'require_custom_value3' => (bool) $company_gateway->require_custom_value3, + 'require_custom_value4' => (bool) $company_gateway->require_custom_value4, 'show_billing_address' => (bool) $company_gateway->show_billing_address, //@deprecated 'show_shipping_address' => (bool) $company_gateway->show_shipping_address, //@deprecated 'update_details' => (bool) $company_gateway->update_details, diff --git a/database/migrations/2023_02_02_062938_add_additional_required_fields_gateways.php b/database/migrations/2023_02_02_062938_add_additional_required_fields_gateways.php new file mode 100644 index 000000000000..efbaf6eaf0ab --- /dev/null +++ b/database/migrations/2023_02_02_062938_add_additional_required_fields_gateways.php @@ -0,0 +1,37 @@ +boolean('require_custom_value1')->default(false); + $table->boolean('require_custom_value2')->default(false); + $table->boolean('require_custom_value3')->default(false); + $table->boolean('require_custom_value4')->default(false); + + }); + + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + // + } +}; diff --git a/resources/views/portal/ninja2020/components/livewire/required-client-info.blade.php b/resources/views/portal/ninja2020/components/livewire/required-client-info.blade.php index 2e9f895d392f..00f6e2311132 100644 --- a/resources/views/portal/ninja2020/components/livewire/required-client-info.blade.php +++ b/resources/views/portal/ninja2020/components/livewire/required-client-info.blade.php @@ -48,20 +48,70 @@ @if($show_terms) @component('portal.ninja2020.components.general.card-element', ['title' => ctrans('texts.terms_of_service') ]) - +
+ /> + {{ ctrans('texts.terms')}} + + + + + + + +
+ @endcomponent + @endif @component('portal.ninja2020.components.general.card-element-single')
- {{ ctrans('texts.required_client_info_save_label') }} @@ -79,4 +129,5 @@ }); @endif +
diff --git a/resources/views/portal/ninja2020/quotes/includes/actions.blade.php b/resources/views/portal/ninja2020/quotes/includes/actions.blade.php index 1a3266815ee4..07672a9e0f66 100644 --- a/resources/views/portal/ninja2020/quotes/includes/actions.blade.php +++ b/resources/views/portal/ninja2020/quotes/includes/actions.blade.php @@ -3,6 +3,7 @@ +