diff --git a/app/Http/Controllers/ClientPortal/PaymentController.php b/app/Http/Controllers/ClientPortal/PaymentController.php index 61cdc83456be..b3bbf2a94bcb 100644 --- a/app/Http/Controllers/ClientPortal/PaymentController.php +++ b/app/Http/Controllers/ClientPortal/PaymentController.php @@ -232,6 +232,7 @@ class PaymentController extends Controller public function response(PaymentResponseRequest $request) { $gateway = CompanyGateway::find($request->input('company_gateway_id'))->firstOrFail(); + $payment_hash = PaymentHash::whereRaw('BINARY `hash`= ?', [$request->payment_hash])->first(); return $gateway diff --git a/app/Models/Client.php b/app/Models/Client.php index 922beefd2098..7c0d648756de 100644 --- a/app/Models/Client.php +++ b/app/Models/Client.php @@ -462,6 +462,7 @@ class Client extends BaseModel implements HasLocalePreference $payment_methods = []; foreach ($gateways as $gateway) { + foreach ($gateway->driver($this)->gatewayTypes() as $type) { if (isset($gateway->fees_and_limits) && property_exists($gateway->fees_and_limits, $type)) { if ($this->validGatewayForAmount($gateway->fees_and_limits->{$type}, $amount)) { diff --git a/app/PaymentDrivers/BaseDriver.php b/app/PaymentDrivers/BaseDriver.php index 7e097c704b53..4d4b017beecf 100644 --- a/app/PaymentDrivers/BaseDriver.php +++ b/app/PaymentDrivers/BaseDriver.php @@ -460,4 +460,9 @@ class BaseDriver extends AbstractPaymentDriver return $this; } + + public function getCompanyGatewayId(): int + { + return $this->company_gateway->id; + } } diff --git a/app/PaymentDrivers/CustomPaymentDriver.php b/app/PaymentDrivers/CustomPaymentDriver.php index 03c76eb7007f..492ecfe66e51 100644 --- a/app/PaymentDrivers/CustomPaymentDriver.php +++ b/app/PaymentDrivers/CustomPaymentDriver.php @@ -12,9 +12,12 @@ namespace App\PaymentDrivers; +use App\Jobs\Util\SystemLogger; use App\Models\ClientGatewayToken; use App\Models\GatewayType; use App\Models\Payment; +use App\Models\PaymentType; +use App\Models\SystemLog; /** * Class CustomPaymentDriver. @@ -28,7 +31,7 @@ class CustomPaymentDriver extends BaseDriver /** * Returns the gateway types. */ - public function gatewayTypes() :array + public function gatewayTypes(): array { $types = [ GatewayType::CREDIT_CARD, @@ -37,18 +40,6 @@ class CustomPaymentDriver extends BaseDriver return $types; } - public function authorize($payment_method) - { - } - - public function purchase($amount, $return_client_response = false) - { - } - - public function refund(Payment $payment, $amount, $return_client_response = false) - { - } - public function setPaymentMethod($payment_method_id) { $this->payment_method = $payment_method_id; @@ -58,11 +49,37 @@ class CustomPaymentDriver extends BaseDriver public function processPaymentView($data) { - return render('gateways.custom.landing_page', $data); + $data['title'] = $this->company_gateway->getConfigField('name'); + $data['instructions'] = $this->company_gateway->getConfigField('text'); + + $this->payment_hash->data = array_merge((array) $this->payment_hash->data, $data); + $this->payment_hash->save(); + + $data['gateway'] = $this; + + return render('gateways.custom.payment', $data); } public function processPaymentResponse($request) { + $data = [ + 'payment_method' => GatewayType::CREDIT_CARD, + 'payment_type' => PaymentType::CREDIT_CARD_OTHER, + 'amount' => $this->payment_hash->data->amount_with_fee, + 'transaction_reference' => \Illuminate\Support\Str::uuid(), + ]; + + $payment = $this->createPayment($data, Payment::STATUS_PENDING); + + SystemLogger::dispatch( + ['response' => $data, 'data' => $data], + SystemLog::CATEGORY_GATEWAY_RESPONSE, + SystemLog::EVENT_GATEWAY_SUCCESS, + SystemLog::TYPE_STRIPE, + $this->client, + ); + + return redirect()->route('client.payments.show', ['payment' => $this->encodePrimaryKey($payment->id)]); } /** diff --git a/resources/lang/en/texts.php b/resources/lang/en/texts.php index 6538ce145461..e0fbc8dfca9f 100644 --- a/resources/lang/en/texts.php +++ b/resources/lang/en/texts.php @@ -3314,4 +3314,6 @@ return [ 'service' => 'Service', 'pay' => 'Pay', + + 'instructions' => 'Instructions', ]; diff --git a/resources/views/portal/ninja2020/gateways/checkout/credit_card.blade.php.old b/resources/views/portal/ninja2020/gateways/checkout/credit_card.blade.php.old deleted file mode 100644 index 71f54319f938..000000000000 --- a/resources/views/portal/ninja2020/gateways/checkout/credit_card.blade.php.old +++ /dev/null @@ -1,128 +0,0 @@ -@extends('portal.ninja2020.layout.app') -@section('meta_title', ctrans('texts.checkout_com')) - -@push('head') - - - - - - - -@endpush - -@section('body') -
- -- {{ ctrans('texts.complete_your_payment') }} -
-