diff --git a/app/Http/Controllers/ClientPortal/PaymentController.php b/app/Http/Controllers/ClientPortal/PaymentController.php index 315157b8c1b9..3fb86c5be156 100644 --- a/app/Http/Controllers/ClientPortal/PaymentController.php +++ b/app/Http/Controllers/ClientPortal/PaymentController.php @@ -130,7 +130,7 @@ class PaymentController extends Controller return $gateway ->driver(auth()->user()->client) - ->setPaymentMethod('App\\PaymentDrivers\\Stripe\\Alipay') + ->setPaymentMethod($request->input('payment_method_id')) ->processPaymentResponse($request); } } diff --git a/app/Http/Requests/Invoice/StoreInvoiceRequest.php b/app/Http/Requests/Invoice/StoreInvoiceRequest.php index 2667ee259ce0..10f6d72a7c2e 100644 --- a/app/Http/Requests/Invoice/StoreInvoiceRequest.php +++ b/app/Http/Requests/Invoice/StoreInvoiceRequest.php @@ -67,6 +67,10 @@ class StoreInvoiceRequest extends Request $input['client_id'] = $this->decodePrimaryKey($input['client_id']); } + if (array_key_exists('assigned_user_id', $input) && is_string($input['assigned_user_id'])) { + $input['assigned_user_id'] = $this->decodePrimaryKey($input['assigned_user_id']); + } + if (isset($input['client_contacts'])) { foreach ($input['client_contacts'] as $key => $contact) { if (!array_key_exists('send_email', $contact) || !array_key_exists('id', $contact)) { diff --git a/app/Http/Requests/Invoice/UpdateInvoiceRequest.php b/app/Http/Requests/Invoice/UpdateInvoiceRequest.php index 41959bdc20f9..ba993f001f9d 100644 --- a/app/Http/Requests/Invoice/UpdateInvoiceRequest.php +++ b/app/Http/Requests/Invoice/UpdateInvoiceRequest.php @@ -65,6 +65,10 @@ class UpdateInvoiceRequest extends Request $input['client_id'] = $this->decodePrimaryKey($input['client_id']); } + if (array_key_exists('assigned_user_id', $input) && is_string($input['assigned_user_id'])) { + $input['assigned_user_id'] = $this->decodePrimaryKey($input['assigned_user_id']); + } + if (isset($input['invitations'])) { foreach ($input['invitations'] as $key => $value) { if (is_numeric($input['invitations'][$key]['id'])) { diff --git a/app/Models/Invoice.php b/app/Models/Invoice.php index edf9766bb51f..5db78dba1812 100644 --- a/app/Models/Invoice.php +++ b/app/Models/Invoice.php @@ -99,6 +99,7 @@ class Invoice extends BaseModel 'custom_surcharge_tax3', 'custom_surcharge_tax4', 'design_id', + 'assigned_user_id', ]; protected $casts = [ diff --git a/app/PaymentDrivers/AbstractPaymentDriver.php b/app/PaymentDrivers/AbstractPaymentDriver.php index fa9393843ae1..b6ec4ca28f5c 100644 --- a/app/PaymentDrivers/AbstractPaymentDriver.php +++ b/app/PaymentDrivers/AbstractPaymentDriver.php @@ -20,4 +20,6 @@ abstract class AbstractPaymentDriver abstract public function refund($amount, $transaction_reference, $return_client_response = false); + abstract public function bootPaymentMethod(); + } \ No newline at end of file diff --git a/app/PaymentDrivers/Authorize/AuthorizeCreditCard.php b/app/PaymentDrivers/Authorize/AuthorizeCreditCard.php new file mode 100644 index 000000000000..913673f9592a --- /dev/null +++ b/app/PaymentDrivers/Authorize/AuthorizeCreditCard.php @@ -0,0 +1,36 @@ +authorize = $authorize; + } + + public function processPaymentView($data) + { + + } + +} \ No newline at end of file diff --git a/app/PaymentDrivers/AuthorizePaymentDriver.php b/app/PaymentDrivers/AuthorizePaymentDriver.php index 62560e07804d..a99fdf6958a2 100644 --- a/app/PaymentDrivers/AuthorizePaymentDriver.php +++ b/app/PaymentDrivers/AuthorizePaymentDriver.php @@ -33,6 +33,19 @@ class AuthorizePaymentDriver extends BaseDriver public $merchant_authentication; + public static $methods = [ + GatewayType::CREDIT_CARD => AuthorizeCreditCard::class, + ]; + + public function bootPaymentMethod() + { + + $class = self::$methods[$this->getPaymentMethodId()]; + + $this->payment_method = new $class($this); + + return $this; + } /** * Returns the gateway types */ @@ -97,6 +110,8 @@ class AuthorizePaymentDriver extends BaseDriver public function processPaymentView($data) { + return $this->bootPaymentMethod()->payment_method->processPaymentView($data); + } public function processPaymentResponse($request) diff --git a/app/PaymentDrivers/BaseDriver.php b/app/PaymentDrivers/BaseDriver.php index 4c003978742b..ea9338c339b5 100644 --- a/app/PaymentDrivers/BaseDriver.php +++ b/app/PaymentDrivers/BaseDriver.php @@ -46,8 +46,13 @@ class BaseDriver extends AbstractPaymentDriver /* The client */ public $client; + /* The payment method id*/ + public $payment_method_id; + public $payment_method; + public $methods = []; + public function __construct(CompanyGateway $company_gateway, Client $client = null, $invitation = false) { $this->company_gateway = $company_gateway; @@ -85,14 +90,21 @@ class BaseDriver extends AbstractPaymentDriver */ public function refund($amount, $transaction_reference, $return_client_response = false) {} + /** + * Initializes an instance of the payment method + * @return object The payment method instance + */ + public function bootPaymentMethod() {} + /** * Set the inbound request payment method type for access. * * @param int $payment_method_id The Payment Method ID */ - public function setPaymentMethod($payment_method_id) + public function setPaymentMethod($method_id) { - $this->payment_method = $payment_method_id; + $this->payment_method_id = $payment_method_id; + return $this; } diff --git a/resources/views/portal/ninja2020/gateways/authorize/add_credit_card.blade.php b/resources/views/portal/ninja2020/gateways/authorize/add_credit_card.blade.php index aaeba35c1aaf..acc9b015a41a 100644 --- a/resources/views/portal/ninja2020/gateways/authorize/add_credit_card.blade.php +++ b/resources/views/portal/ninja2020/gateways/authorize/add_credit_card.blade.php @@ -31,46 +31,9 @@
-
-
- {{ ctrans('texts.name') }} -
-
- -
-
-
-
- {{ ctrans('texts.credit_card') }} -
-
- -
-
-
-
- {{ ctrans('texts.expiration_month') }} -
-
- -
-
-
-
- {{ ctrans('texts.expiration_year') }} -
-
- -
-
-
-
- {{ ctrans('texts.cvv') }} -
-
- -
-
+ + @include('portal.ninja2020.gateways.authorize.credit_card') +
{{ ctrans('texts.save_as_default') }} diff --git a/resources/views/portal/ninja2020/gateways/authorize/credit_card.blade.php b/resources/views/portal/ninja2020/gateways/authorize/credit_card.blade.php new file mode 100644 index 000000000000..178347e433c2 --- /dev/null +++ b/resources/views/portal/ninja2020/gateways/authorize/credit_card.blade.php @@ -0,0 +1,40 @@ +
+
+ {{ ctrans('texts.name') }} +
+
+ +
+
+
+
+ {{ ctrans('texts.credit_card') }} +
+
+ +
+
+
+
+ {{ ctrans('texts.expiration_month') }} +
+
+ +
+
+
+
+ {{ ctrans('texts.expiration_year') }} +
+
+ +
+
+
+
+ {{ ctrans('texts.cvv') }} +
+
+ +
+