2019-09-05 09:00:12 +02:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Invoice Ninja (https://invoiceninja.com)
|
|
|
|
*
|
|
|
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
|
|
|
*
|
|
|
|
* @copyright Copyright (c) 2019. Invoice Ninja LLC (https://invoiceninja.com)
|
|
|
|
*
|
|
|
|
* @license https://opensource.org/licenses/AAL
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace App\PaymentDrivers;
|
|
|
|
|
2019-09-05 14:42:26 +02:00
|
|
|
use App\Models\CompanyGateway;
|
|
|
|
use Omnipay\Omnipay;
|
|
|
|
|
2019-09-05 09:00:12 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Class BasePaymentDriver
|
|
|
|
* @package App\PaymentDrivers
|
|
|
|
*/
|
2019-09-05 14:42:26 +02:00
|
|
|
class BasePaymentDriver
|
2019-09-05 09:00:12 +02:00
|
|
|
{
|
2019-09-06 01:00:23 +02:00
|
|
|
/* The company gateway instance*/
|
2019-09-05 14:42:26 +02:00
|
|
|
protected $company_gateway;
|
|
|
|
|
2019-09-06 01:00:23 +02:00
|
|
|
/* The Omnipay payment driver instance*/
|
2019-09-05 14:42:26 +02:00
|
|
|
protected $gateway;
|
|
|
|
|
2019-09-06 01:00:23 +02:00
|
|
|
/* Member variables */
|
|
|
|
protected $refundable = false;
|
|
|
|
protected $token_billing = false;
|
|
|
|
|
2019-09-05 14:42:26 +02:00
|
|
|
public function __construct(CompanyGateway $company_gateway)
|
|
|
|
{
|
|
|
|
$this->company_gateway = $company_gateway;
|
|
|
|
//$this->invitation = $invitation;
|
|
|
|
//$this->gatewayType = $gatewayType ?: $this->gatewayTypes()[0];
|
|
|
|
}
|
|
|
|
|
2019-09-06 01:00:23 +02:00
|
|
|
/* Stubbed in parent, but should never be initialized
|
|
|
|
* The boot method should be used in the superclass
|
|
|
|
* to initialize all the member variables for the
|
|
|
|
* given driver / payment gateway
|
|
|
|
*
|
|
|
|
* ie.
|
|
|
|
*
|
|
|
|
* ->gateway()
|
|
|
|
* ->setRefundable(true)
|
|
|
|
* ->setTokenBilling(true)
|
|
|
|
*
|
|
|
|
* @return Instance
|
|
|
|
*/
|
|
|
|
public function boot(){}
|
|
|
|
|
2019-09-05 14:42:26 +02:00
|
|
|
/**
|
|
|
|
* Returns the Omnipay driver
|
|
|
|
* @return object Omnipay initialized object
|
|
|
|
*/
|
|
|
|
protected function gateway()
|
|
|
|
{
|
2019-09-06 01:00:23 +02:00
|
|
|
|
2019-09-05 14:42:26 +02:00
|
|
|
$this->gateway = Omnipay::create($this->company_gateway->gateway->provider);
|
|
|
|
$this->gateway->initialize((array) $this->company_gateway->getConfig());
|
|
|
|
|
2019-09-06 01:00:23 +02:00
|
|
|
return $this;
|
2019-09-05 14:42:26 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2019-09-06 01:00:23 +02:00
|
|
|
|
|
|
|
public function setRefundable($value)
|
|
|
|
{
|
|
|
|
$this->refundable = $value;
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2019-09-05 09:00:12 +02:00
|
|
|
/**
|
|
|
|
* Returns whether refunds are possible with the gateway
|
|
|
|
* @return boolean TRUE|FALSE
|
|
|
|
*/
|
2019-09-06 01:00:23 +02:00
|
|
|
public function getRefundable()
|
|
|
|
{
|
|
|
|
return $this->refundable;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setTokenBilling($value)
|
|
|
|
{
|
|
|
|
$this->token_billing = $value;
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
2019-09-05 09:00:12 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns whether token billing is possible with the gateway
|
|
|
|
* @return boolean TRUE|FALSE
|
|
|
|
*/
|
2019-09-06 01:00:23 +02:00
|
|
|
public function getTokenBilling()
|
|
|
|
{
|
|
|
|
return $this->token_billing;
|
|
|
|
}
|
2019-09-05 09:00:12 +02:00
|
|
|
|
|
|
|
/**
|
2019-09-05 14:42:26 +02:00
|
|
|
* Refunds a given payment
|
|
|
|
* @return void
|
2019-09-05 09:00:12 +02:00
|
|
|
*/
|
2019-09-06 01:00:23 +02:00
|
|
|
public function refundPayment()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
2019-09-05 09:00:12 +02:00
|
|
|
}
|