diff --git a/app/Http/Controllers/ClientPortal/PaymentMethodController.php b/app/Http/Controllers/ClientPortal/PaymentMethodController.php index 14b4221497..5e554d2783 100644 --- a/app/Http/Controllers/ClientPortal/PaymentMethodController.php +++ b/app/Http/Controllers/ClientPortal/PaymentMethodController.php @@ -51,7 +51,8 @@ class PaymentMethodController extends Controller $gateway = $this->getClientGateway(); $data['gateway'] = $gateway; - + $data['client'] = auth()->user()->client; + return $gateway ->driver(auth()->user()->client) ->setPaymentMethod($request->query('method')) diff --git a/app/PaymentDrivers/WePay/CreditCard.php b/app/PaymentDrivers/WePay/CreditCard.php index 10f9a02082..bd2ae07b64 100644 --- a/app/PaymentDrivers/WePay/CreditCard.php +++ b/app/PaymentDrivers/WePay/CreditCard.php @@ -31,15 +31,17 @@ class CreditCard } - public function authorizeResponse($data) + public function authorizeResponse($request) { //https://developer.wepay.com/api/api-calls/credit_card#authorize + $data = $request->all(); // authorize the credit card $response = $this->wepay->request('credit_card/authorize', array( - 'client_id' => $account_id, - 'client_secret' => 'A vacation home rental', - 'credit_card_id' => 'goods', + 'account_id' => $this->wepay->company_gateway->getConfigField('accountId'), + 'client_id' => config('ninja.wepay.client_id'), + 'client_secret' => config('ninja.wepay.client_secret'), + 'credit_card_id' => $data['source_token'], )); // display the response diff --git a/app/PaymentDrivers/WePayPaymentDriver.php b/app/PaymentDrivers/WePayPaymentDriver.php index b561e419d0..172607bc4d 100644 --- a/app/PaymentDrivers/WePayPaymentDriver.php +++ b/app/PaymentDrivers/WePayPaymentDriver.php @@ -115,6 +115,10 @@ class WePayPaymentDriver extends BaseDriver public function authorizeView(array $data) { $data['gateway'] = $this->wepay; + $client = $data['client']; + $contact = $client->primary_contact()->first() ? $client->primary_contact()->first() : $lient->contacts->first(); + $data['contact'] = $contact; + // $data['contact'] = $this->company_gateway // $data['public_client_id'] = $this->authorize->init()->getPublicClientKey(); // $data['api_login_id'] = $this->authorize->company_gateway->getConfigField('apiLoginId'); @@ -145,4 +149,59 @@ class WePayPaymentDriver extends BaseDriver { return $this->payment_method->yourTokenBillingImplmentation(); //this is your custom implementation from here } + + + + + public function getClientRequiredFields(): array + { + $fields = [ + ['name' => 'client_postal_code', 'label' => ctrans('texts.postal_code'), 'type' => 'text', 'validation' => 'required'], + ['name' => 'contact_email', 'label' => ctrans('texts.email'), 'type' => 'text', 'validation' => 'required'], + ]; + + 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_client_phone) { + $fields[] = ['name' => 'client_phone', 'label' => ctrans('texts.client_phone'), 'type' => 'tel', '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_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_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; + } + + + + + + + + } diff --git a/resources/views/portal/ninja2020/gateways/wepay/authorize/authorize.blade.php b/resources/views/portal/ninja2020/gateways/wepay/authorize/authorize.blade.php index 13b3fa7a71..bc6a688ed9 100644 --- a/resources/views/portal/ninja2020/gateways/wepay/authorize/authorize.blade.php +++ b/resources/views/portal/ninja2020/gateways/wepay/authorize/authorize.blade.php @@ -44,8 +44,11 @@