2020-08-20 00:11:46 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
2020-09-06 11:38:10 +02:00
|
|
|
* Invoice Ninja (https://invoiceninja.com).
|
2020-08-20 00:11:46 +02:00
|
|
|
*
|
|
|
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
|
|
|
*
|
|
|
|
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
|
|
|
|
*
|
|
|
|
* @license https://opensource.org/licenses/AAL
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace App\PaymentDrivers;
|
|
|
|
|
|
|
|
use App\Models\ClientGatewayToken;
|
|
|
|
use App\Models\GatewayType;
|
|
|
|
use App\Models\Payment;
|
|
|
|
|
|
|
|
/**
|
2020-09-06 11:38:10 +02:00
|
|
|
* Class CustomPaymentDriver.
|
2020-08-20 00:11:46 +02:00
|
|
|
*/
|
|
|
|
class CustomPaymentDriver extends BaseDriver
|
|
|
|
{
|
|
|
|
public $token_billing = false;
|
|
|
|
|
|
|
|
public $can_authorise_credit_card = false;
|
2020-09-06 11:38:10 +02:00
|
|
|
|
2020-08-20 00:11:46 +02:00
|
|
|
/**
|
2020-09-06 11:38:10 +02:00
|
|
|
* Returns the gateway types.
|
2020-08-20 00:11:46 +02:00
|
|
|
*/
|
2020-12-09 15:17:48 +01:00
|
|
|
public function gatewayTypes(): array
|
2020-08-20 00:11:46 +02:00
|
|
|
{
|
|
|
|
$types = [
|
2020-12-10 12:38:23 +01:00
|
|
|
GatewayType::CUSTOM,
|
2020-08-20 00:11:46 +02:00
|
|
|
];
|
|
|
|
|
|
|
|
return $types;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setPaymentMethod($payment_method_id)
|
|
|
|
{
|
|
|
|
$this->payment_method = $payment_method_id;
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2020-12-10 12:38:23 +01:00
|
|
|
/**
|
|
|
|
* View for displaying custom content of the driver.
|
2020-12-10 12:38:46 +01:00
|
|
|
*
|
|
|
|
* @param array $data
|
|
|
|
* @return mixed
|
2020-12-10 12:38:23 +01:00
|
|
|
*/
|
2020-08-20 00:11:46 +02:00
|
|
|
public function processPaymentView($data)
|
|
|
|
{
|
2020-12-09 15:17:48 +01:00
|
|
|
$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);
|
2020-08-20 00:11:46 +02:00
|
|
|
}
|
|
|
|
|
2020-12-10 12:38:23 +01:00
|
|
|
/**
|
|
|
|
* Processing method for payment. Should never be reached with this driver.
|
2020-12-10 12:38:46 +01:00
|
|
|
*
|
|
|
|
* @return mixed
|
2020-12-10 12:38:23 +01:00
|
|
|
*/
|
2020-08-20 00:11:46 +02:00
|
|
|
public function processPaymentResponse($request)
|
|
|
|
{
|
2020-12-10 12:38:23 +01:00
|
|
|
return redirect()->route('client.invoices');
|
2020-08-20 00:11:46 +02:00
|
|
|
}
|
2020-09-18 10:01:19 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Detach payment method from custom payment driver.
|
2020-10-28 11:10:49 +01:00
|
|
|
*
|
|
|
|
* @param ClientGatewayToken $token
|
|
|
|
* @return void
|
2020-09-18 10:01:19 +02:00
|
|
|
*/
|
|
|
|
public function detach(ClientGatewayToken $token)
|
|
|
|
{
|
|
|
|
// Driver doesn't support this feature.
|
|
|
|
}
|
2020-08-20 00:11:46 +02:00
|
|
|
}
|