mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Fleshing out payment drivers
This commit is contained in:
parent
f8734db1b6
commit
f72bd34483
@ -21,11 +21,16 @@ use Omnipay\Omnipay;
|
|||||||
*/
|
*/
|
||||||
class BasePaymentDriver
|
class BasePaymentDriver
|
||||||
{
|
{
|
||||||
|
/* The company gateway instance*/
|
||||||
protected $company_gateway;
|
protected $company_gateway;
|
||||||
|
|
||||||
|
/* The Omnipay payment driver instance*/
|
||||||
protected $gateway;
|
protected $gateway;
|
||||||
|
|
||||||
|
/* Member variables */
|
||||||
|
protected $refundable = false;
|
||||||
|
protected $token_billing = false;
|
||||||
|
|
||||||
public function __construct(CompanyGateway $company_gateway)
|
public function __construct(CompanyGateway $company_gateway)
|
||||||
{
|
{
|
||||||
$this->company_gateway = $company_gateway;
|
$this->company_gateway = $company_gateway;
|
||||||
@ -33,37 +38,74 @@ class BasePaymentDriver
|
|||||||
//$this->gatewayType = $gatewayType ?: $this->gatewayTypes()[0];
|
//$this->gatewayType = $gatewayType ?: $this->gatewayTypes()[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* 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(){}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the Omnipay driver
|
* Returns the Omnipay driver
|
||||||
* @return object Omnipay initialized object
|
* @return object Omnipay initialized object
|
||||||
*/
|
*/
|
||||||
protected function gateway()
|
protected function gateway()
|
||||||
{
|
{
|
||||||
if ($this->gateway)
|
|
||||||
return $this->gateway;
|
|
||||||
|
|
||||||
$this->gateway = Omnipay::create($this->company_gateway->gateway->provider);
|
$this->gateway = Omnipay::create($this->company_gateway->gateway->provider);
|
||||||
$this->gateway->initialize((array) $this->company_gateway->getConfig());
|
$this->gateway->initialize((array) $this->company_gateway->getConfig());
|
||||||
|
|
||||||
return $this->gateway;
|
return $this;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function setRefundable($value)
|
||||||
|
{
|
||||||
|
$this->refundable = $value;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns whether refunds are possible with the gateway
|
* Returns whether refunds are possible with the gateway
|
||||||
* @return boolean TRUE|FALSE
|
* @return boolean TRUE|FALSE
|
||||||
*/
|
*/
|
||||||
public function isRefundable() :bool {}
|
public function getRefundable()
|
||||||
|
{
|
||||||
|
return $this->refundable;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setTokenBilling($value)
|
||||||
|
{
|
||||||
|
$this->token_billing = $value;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns whether token billing is possible with the gateway
|
* Returns whether token billing is possible with the gateway
|
||||||
* @return boolean TRUE|FALSE
|
* @return boolean TRUE|FALSE
|
||||||
*/
|
*/
|
||||||
public function hasTokenBilling() :bool {}
|
public function getTokenBilling()
|
||||||
|
{
|
||||||
|
return $this->token_billing;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Refunds a given payment
|
* Refunds a given payment
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function refundPayment() {}
|
public function refundPayment()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user