1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 21:22:58 +01:00
invoiceninja/app/PaymentDrivers/BaseDriver.php

123 lines
3.3 KiB
PHP
Raw Normal View History

2020-06-09 13:17:26 +02:00
<?php
/**
* Invoice Ninja (https://invoiceninja.com)
*
* @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\Client;
use App\Models\CompanyGateway;
use App\PaymentDrivers\AbstractPaymentDriver;
use App\Utils\Traits\MakesHash;
use App\Utils\Traits\SystemLogTrait;
/**
* Class BaseDriver
* @package App\PaymentDrivers
*
*/
2020-06-09 14:54:22 +02:00
class BaseDriver extends AbstractPaymentDriver
2020-06-09 13:17:26 +02:00
{
use SystemLogTrait;
use MakesHash;
/* The company gateway instance*/
public $company_gateway;
/* The Invitation */
2020-06-15 13:42:46 +02:00
public $invitation;
2020-06-09 13:17:26 +02:00
/* Gateway capabilities */
2020-06-15 13:42:46 +02:00
public $refundable = false;
2020-06-09 13:17:26 +02:00
/* Token billing */
2020-06-15 13:42:46 +02:00
public $token_billing = false;
2020-06-09 13:17:26 +02:00
/* Authorise payment methods */
2020-06-15 13:42:46 +02:00
public $can_authorise_credit_card = false;
2020-06-09 13:17:26 +02:00
2020-06-12 02:19:26 +02:00
/* The client */
2020-06-15 13:42:46 +02:00
public $client;
2020-06-16 02:21:40 +02:00
/* The payment method id*/
public $payment_method_id;
2020-06-15 13:42:46 +02:00
public $payment_method;
2020-06-09 13:17:26 +02:00
2020-06-16 05:49:45 +02:00
public static $methods = [];
2020-06-16 02:21:40 +02:00
2020-06-10 14:42:10 +02:00
public function __construct(CompanyGateway $company_gateway, Client $client = null, $invitation = false)
2020-06-09 13:17:26 +02:00
{
$this->company_gateway = $company_gateway;
$this->invitation = $invitation;
$this->client = $client;
}
2020-06-12 02:19:26 +02:00
/**
* Authorize a payment method.
*
* Returns a reusable token for storage for future payments
* @param const $payment_method the GatewayType::constant
* @return view Return a view for collecting payment method information
*/
2020-06-10 10:05:30 +02:00
public function authorize($payment_method) {}
2020-06-09 13:17:26 +02:00
2020-06-12 02:19:26 +02:00
/**
* Executes purchase attempt for a given amount
*
* @param float $amount The amount to be collected
* @param boolean $return_client_response Whether the method needs to return a response (otherwise we assume an unattended payment)
* @return mixed
*/
public function purchase($amount, $return_client_response = false) {}
/**
* Executes a refund attempt for a given amount with a transaction_reference
*
* @param float $amount The amount to be refunded
* @param string $transaction_reference The transaction reference
* @param boolean $return_client_response Whether the method needs to return a response (otherwise we assume an unattended payment)
* @return mixed
*/
public function refund($amount, $transaction_reference, $return_client_response = false) {}
2020-06-09 13:17:26 +02:00
2020-06-16 02:21:40 +02:00
/**
* Initializes an instance of the payment method
* @return object The payment method instance
*/
public function bootPaymentMethod() {}
2020-06-15 13:42:46 +02:00
/**
* Set the inbound request payment method type for access.
*
* @param int $payment_method_id The Payment Method ID
*/
2020-06-16 05:49:45 +02:00
public function setPaymentMethod($payment_method_id)
2020-06-15 13:42:46 +02:00
{
2020-06-16 05:49:45 +02:00
info("setting payment method {$payment_method_id}");
2020-06-16 02:21:40 +02:00
$this->payment_method_id = $payment_method_id;
2020-06-15 13:42:46 +02:00
return $this;
}
/**
* Get the payment method ID
*
* @return int The payment method ID
*/
public function getPaymentMethod()
{
2020-06-16 05:49:45 +02:00
return $this->payment_method_id;
2020-06-15 13:42:46 +02:00
}
2020-06-09 13:17:26 +02:00
}