diff --git a/app/Http/Controllers/ClientPortal/PaymentController.php b/app/Http/Controllers/ClientPortal/PaymentController.php index 6a72e7417c37..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() + ->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..439a88adf8c1 --- /dev/null +++ b/app/PaymentDrivers/Authorize/AuthorizeCreditCard.php @@ -0,0 +1,53 @@ +authorize = $authorize; + } + + public function processPaymentView($data) + { + $tokens = ClientGatewayToken::where('client_id', $this->authorize->client->id) + ->where('company_gateway_id', $this->authorize->company_gateway->id) + ->where('gateway_type_id', $this->authorize->payment_method_id) + ->get(); + + $data['tokens'] = $tokens; + $data['gateway'] = $this->authorize->company_gateway; + $data['public_client_id'] = $this->authorize->init()->getPublicClientKey(); + $data['api_login_id'] = $this->authorize->company_gateway->getConfigField('apiLoginId'); + + return render('gateways.authorize.credit_card_payment', $data); + + } + + public function processPaymentResponse($response) + { + + } + +} \ No newline at end of file diff --git a/app/PaymentDrivers/Authorize/AuthorizeTransactions.php b/app/PaymentDrivers/Authorize/AuthorizeTransactions.php new file mode 100644 index 000000000000..fe2d169b77f8 --- /dev/null +++ b/app/PaymentDrivers/Authorize/AuthorizeTransactions.php @@ -0,0 +1,66 @@ +authorize = $authorize; + } + + function getTransactionDetails($transactionId) + { + /* Create a merchantAuthenticationType object with authentication details + retrieved from the constants file */ + $this->authorize->init(); + + // Set the transaction's refId + $refId = 'ref' . time(); + + $request = new GetTransactionDetailsRequest(); + $request->setMerchantAuthentication($this->authorize->merchant_authentication); + $request->setTransId($transactionId); + + $controller = new GetTransactionDetailsController($request); + + $response = $controller->executeWithApiResponse($this->authorize->mode()); + + if (($response != null) && ($response->getMessages()->getResultCode() == "Ok")) + { + echo "SUCCESS: Transaction Status:" . $response->getTransaction()->getTransactionStatus() . "\n"; + echo " Auth Amount:" . $response->getTransaction()->getAuthAmount() . "\n"; + echo " Trans ID:" . $response->getTransaction()->getTransId() . "\n"; + } + else + { + echo "ERROR : Invalid response\n"; + $errorMessages = $response->getMessages()->getMessage(); + echo "Response : " . $errorMessages[0]->getCode() . " " .$errorMessages[0]->getText() . "\n"; + } + + return $response; + } +} \ No newline at end of file diff --git a/app/PaymentDrivers/AuthorizePaymentDriver.php b/app/PaymentDrivers/AuthorizePaymentDriver.php index 62560e07804d..0d05573d7167 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() + {info(print_r($this->getPaymentMethod(),1)); + + $class = self::$methods[$this->getPaymentMethod()]; + + $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..e928eabb2fe3 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 static $methods = []; + public function __construct(CompanyGateway $company_gateway, Client $client = null, $invitation = false) { $this->company_gateway = $company_gateway; @@ -85,6 +90,12 @@ 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. * @@ -92,7 +103,10 @@ class BaseDriver extends AbstractPaymentDriver */ public function setPaymentMethod($payment_method_id) { - $this->payment_method = $payment_method_id; + info("setting payment method {$payment_method_id}"); + + $this->payment_method_id = $payment_method_id; + return $this; } @@ -103,6 +117,6 @@ class BaseDriver extends AbstractPaymentDriver */ public function getPaymentMethod() { - return $this->payment_method; + return $this->payment_method_id; } } 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') }} +
+
+ +
+
diff --git a/resources/views/portal/ninja2020/gateways/authorize/credit_card_payment.blade.php b/resources/views/portal/ninja2020/gateways/authorize/credit_card_payment.blade.php new file mode 100644 index 000000000000..220880a104c0 --- /dev/null +++ b/resources/views/portal/ninja2020/gateways/authorize/credit_card_payment.blade.php @@ -0,0 +1,73 @@ +@extends('portal.ninja2020.layout.app') +@section('meta_title', ctrans('texts.add_credit_card')) + +@push('head') + + +@endpush + +@section('body') +
+ @csrf + + + + + + + + +
+
+
+
+ +
+
+
+
+ @if($tokens->count() == 0) +
+ @include('portal.ninja2020.gateways.authorize.credit_card') + +
+
+ {{ ctrans('texts.save_as_default') }} +
+
+ +
+
+
+ +
+
+ @else + +
    + @foreach($tokens as $token) +
  • + $token->meta->brand : $token->meta->last4 : +
  • + @endforeach +
+ @endif +
+
+
+
+
+@endsection + +@push('footer') + + @if($gateway->getConfigField('testMode')) + + @else + + @endif + + +@endpush \ No newline at end of file