diff --git a/app/PaymentDrivers/BasePaymentDriver.php b/app/PaymentDrivers/BasePaymentDriver.php index 10b9a3c6a2..c9beee5abc 100644 --- a/app/PaymentDrivers/BasePaymentDriver.php +++ b/app/PaymentDrivers/BasePaymentDriver.php @@ -21,11 +21,16 @@ use Omnipay\Omnipay; */ class BasePaymentDriver { - + /* The company gateway instance*/ protected $company_gateway; + /* The Omnipay payment driver instance*/ protected $gateway; + /* Member variables */ + protected $refundable = false; + protected $token_billing = false; + public function __construct(CompanyGateway $company_gateway) { $this->company_gateway = $company_gateway; @@ -33,37 +38,74 @@ class BasePaymentDriver //$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 * @return object Omnipay initialized object */ protected function gateway() { - if ($this->gateway) - return $this->gateway; - + $this->gateway = Omnipay::create($this->company_gateway->gateway->provider); $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 * @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 * @return boolean TRUE|FALSE */ - public function hasTokenBilling() :bool {} + public function getTokenBilling() + { + return $this->token_billing; + } /** * Refunds a given payment * @return void */ - public function refundPayment() {} + public function refundPayment() + { + + } } \ No newline at end of file