diff --git a/app/PaymentDrivers/BasePaymentDriver.php b/app/PaymentDrivers/BasePaymentDriver.php index ec0cba1f51..8646fe3599 100644 --- a/app/PaymentDrivers/BasePaymentDriver.php +++ b/app/PaymentDrivers/BasePaymentDriver.php @@ -22,6 +22,20 @@ use Omnipay\Omnipay; /** * Class BasePaymentDriver * @package App\PaymentDrivers + * + * Minimum dataset required for payment gateways + * + * $data = [ + 'amount' => $invoice->getRequestedAmount(), + 'currency' => $invoice->getCurrencyCode(), + 'returnUrl' => $completeUrl, + 'cancelUrl' => $this->invitation->getLink(), + 'description' => trans('texts.' . $invoice->getEntityType()) . " {$invoice->invoice_number}", + 'transactionId' => $invoice->invoice_number, + 'transactionType' => 'Purchase', + 'clientIp' => Request::getClientIp(), + ]; + */ class BasePaymentDriver { @@ -146,6 +160,32 @@ class BasePaymentDriver acceptNotification() - convert an incoming request from an off-site gateway to a generic notification object for further processing */ + protected function paymentDetails($paymentMethod = false) + { + $gatewayTypeAlias = $this->gatewayType == GatewayType::TOKEN ? $this->gatewayType : GatewayType::getAliasFromId($this->gatewayType); + $completeUrl = $this->invitation->getLink('complete', true) . '/' . $gatewayTypeAlias; + + $data = [ + 'currency' => $this->client->getCurrencyCode(), + 'transactionId' => $invoice->invoice_number, + 'transactionType' => 'Purchase', + 'clientIp' => request()->getClientIp(), + ]; + + if ($paymentMethod) { + if ($this->customerReferenceParam) { + $data[$this->customerReferenceParam] = $paymentMethod->account_gateway_token->token; + } + $data[$this->sourceReferenceParam] = $paymentMethod->source_reference; + } elseif ($this->input) { + $data['card'] = new CreditCard($this->paymentDetailsFromInput($this->input)); + } else { + $data['card'] = new CreditCard($this->paymentDetailsFromClient()); + } + + return $data; + } + public function purchase($data, $items) { $response = $this->gateway diff --git a/app/PaymentDrivers/PayPalExpressPaymentDriver.php b/app/PaymentDrivers/PayPalExpressPaymentDriver.php new file mode 100644 index 0000000000..7903e9f0cc --- /dev/null +++ b/app/PaymentDrivers/PayPalExpressPaymentDriver.php @@ -0,0 +1,60 @@ +each(function ($invoice) use($payment) { $invoice->status_id = Payment::STATUS_COMPLETED; diff --git a/composer.json b/composer.json index 48938ffb5b..966a0c8f64 100644 --- a/composer.json +++ b/composer.json @@ -31,7 +31,7 @@ "laravel/tinker": "^1.0", "laravelcollective/html": "5.8.*", "league/fractal": "^0.17.0", - "league/omnipay": "^3", + "league/omnipay": "^3.0", "nwidart/laravel-modules": "^4.0", "omnipay/paypal": "^3.0", "omnipay/stripe": "^3.0", diff --git a/resources/views/portal/default/invoices/index.blade.php b/resources/views/portal/default/invoices/index.blade.php index eaeea9fa75..2d7b3e2774 100644 --- a/resources/views/portal/default/invoices/index.blade.php +++ b/resources/views/portal/default/invoices/index.blade.php @@ -51,18 +51,18 @@ - -
-
- - {!! $html->table(['class' => 'table table-hover table-striped', 'id' => 'datatable'], true) !!} - -
-
- + +
+
+ + {!! $html->table(['class' => 'table table-hover table-striped', 'id' => 'datatable'], true) !!} + +
+
+ diff --git a/resources/views/portal/default/payment_methods/index.blade.php b/resources/views/portal/default/payment_methods/index.blade.php index 585b14804a..c7826328cb 100644 --- a/resources/views/portal/default/payment_methods/index.blade.php +++ b/resources/views/portal/default/payment_methods/index.blade.php @@ -28,18 +28,17 @@
{{ ctrans('texts.add_payment_method') }}
+ + -
-
+
+
{!! $html->table(['class' => 'table table-hover table-striped', 'id' => 'datatable'], true) !!} - -
-
-
- +
+