mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-24 02:14:21 -04:00
Working on gateway payment flow
This commit is contained in:
parent
0b0f0759f1
commit
0856fc2dfd
@ -90,6 +90,8 @@ class ClientSettings extends BaseSettings
|
||||
public $size_id;
|
||||
|
||||
public $design;
|
||||
|
||||
public $default_company_gateway_id;
|
||||
/**
|
||||
* Cast object values and return entire class
|
||||
* prevents missing properties from not being returned
|
||||
|
@ -112,6 +112,8 @@ class CompanySettings extends BaseSettings
|
||||
public $counter_padding;
|
||||
|
||||
public $design;
|
||||
|
||||
public $default_company_gateway_id;
|
||||
/**
|
||||
* Cast object values and return entire class
|
||||
* prevents missing properties from not being returned
|
||||
@ -166,7 +168,7 @@ class CompanySettings extends BaseSettings
|
||||
'client_number_prefix' => '',
|
||||
'auto_archive_invoice' => 'FALSE',
|
||||
'design' => 'views/pdf/design1.blade.php',
|
||||
|
||||
|
||||
'translations' => (object) [],
|
||||
];
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ class PaymentMethodController extends Controller
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
//
|
||||
echo 'hello';
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -104,5 +104,6 @@ class Kernel extends HttpKernel
|
||||
'contact_token_auth' => \App\Http\Middleware\ContactTokenAuth::class,
|
||||
'contact_db' => \App\Http\Middleware\ContactSetDb::class,
|
||||
'domain_db' => \App\Http\Middleware\SetDomainNameDb::class,
|
||||
'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class,
|
||||
];
|
||||
}
|
||||
|
@ -154,7 +154,15 @@ class Client extends BaseModel
|
||||
|
||||
public function getPaymentMethods()
|
||||
{
|
||||
|
||||
$settings = $this->getMergedSettings();
|
||||
|
||||
/* If we have a single default gateway - pass this back now.*/
|
||||
if($settings->default_company_gateway_id);
|
||||
return $settings->default_company_gateway_id;
|
||||
|
||||
/* If there is no default, then we pass back the Collection of gateways */
|
||||
|
||||
$gateways = $this->company->company_gateways;
|
||||
}
|
||||
|
||||
|
||||
|
@ -16,12 +16,29 @@ use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class GatewayType extends Model
|
||||
{
|
||||
|
||||
public $timestamps = false;
|
||||
|
||||
const CREDIT_CARD = 1;
|
||||
const BANK_TRANSFER = 2;
|
||||
const PAYPAL = 3;
|
||||
const BITCOIN = 4;
|
||||
const DWOLLA = 5;
|
||||
const CUSTOM1 = 6;
|
||||
const ALIPAY = 7;
|
||||
const SOFORT = 8;
|
||||
const SEPA = 9;
|
||||
const GOCARDLESS = 10;
|
||||
const APPLE_PAY = 11;
|
||||
const CUSTOM2 = 12;
|
||||
const CUSTOM3 = 13;
|
||||
const TOKEN = 'token');
|
||||
|
||||
public function gateway()
|
||||
{
|
||||
return $this->belongsTo(Gateway::class);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -15,5 +15,4 @@ use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class PaymentType extends Model
|
||||
{
|
||||
//
|
||||
}
|
||||
|
@ -12,6 +12,7 @@
|
||||
namespace App\PaymentDrivers;
|
||||
|
||||
use App\Models\CompanyGateway;
|
||||
use App\Models\GatewayType;
|
||||
use Omnipay\Omnipay;
|
||||
|
||||
|
||||
@ -27,14 +28,17 @@ class BasePaymentDriver
|
||||
/* The Omnipay payment driver instance*/
|
||||
protected $gateway;
|
||||
|
||||
/* The Invitation */
|
||||
protected $invitation;
|
||||
|
||||
/* Member variables */
|
||||
protected $refundable = false;
|
||||
protected $token_billing = false;
|
||||
|
||||
public function __construct(CompanyGateway $company_gateway)
|
||||
public function __construct(CompanyGateway $company_gateway, $invitation = false)
|
||||
{
|
||||
$this->company_gateway = $company_gateway;
|
||||
//$this->invitation = $invitation;
|
||||
$this->invitation = $invitation;
|
||||
//$this->gatewayType = $gatewayType ?: $this->gatewayTypes()[0];
|
||||
}
|
||||
|
||||
@ -67,6 +71,35 @@ class BasePaymentDriver
|
||||
|
||||
}
|
||||
|
||||
public function invoice()
|
||||
{
|
||||
return $this->invitation->invoice;
|
||||
}
|
||||
|
||||
public function contact()
|
||||
{
|
||||
return $this->invitation->contact;
|
||||
}
|
||||
|
||||
public function client()
|
||||
{
|
||||
return $this->contact()->client;
|
||||
}
|
||||
|
||||
public function company()
|
||||
{
|
||||
return $this->invitation->company;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the default gateway type
|
||||
*/
|
||||
public function gatewayTypes()
|
||||
{
|
||||
return [
|
||||
GatewayType::CREDIT_CARD,
|
||||
];
|
||||
}
|
||||
|
||||
public function setRefundable($value)
|
||||
{
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
namespace App\PaymentDrivers;
|
||||
|
||||
use App\Models\GatewayType;
|
||||
use Stripe\Stripe;
|
||||
|
||||
class StripePaymentDriver extends BasePaymentDriver
|
||||
@ -21,6 +22,7 @@ class StripePaymentDriver extends BasePaymentDriver
|
||||
|
||||
protected $customer_reference = 'customerReferenceParam';
|
||||
|
||||
|
||||
public function boot()
|
||||
{
|
||||
$this->setRefundable($this->refundable);
|
||||
@ -37,9 +39,44 @@ class StripePaymentDriver extends BasePaymentDriver
|
||||
* other gateways and therefore
|
||||
* relies on direct calls to the API
|
||||
*/
|
||||
/************************************** Stripe API methods **********************************************************/
|
||||
|
||||
public function init($api_key)
|
||||
{
|
||||
Stripe::setApiKey($api_key);
|
||||
}
|
||||
/**
|
||||
* Returns the gateway types
|
||||
*/
|
||||
public function gatewayTypes() :array
|
||||
{
|
||||
$types = [
|
||||
GatewayType::CREDIT_CARD,
|
||||
GatewayType::TOKEN,
|
||||
];
|
||||
|
||||
if($this->company_gateway->getSofortEnabled() && $this->invitation && $this->client() && isset($this->client()->country) && in_array($this->client()->country, ['AUT', 'BEL', 'DEU', 'ITA', 'NLD', 'ESP']))
|
||||
$types[] = GatewayType::SOFORT;
|
||||
|
||||
if($this->company_gateway->getAchEnabled())
|
||||
$types[] = GatewayType::BANK_TRANSFER;
|
||||
|
||||
if ($this->company_gateway->getSepaEnabled())
|
||||
$types[] = GatewayType::SEPA;
|
||||
|
||||
if ($this->company_gateway->getBitcoinEnabled())
|
||||
$types[] = GatewayType::BITCOIN;
|
||||
|
||||
if ($this->company_gateway->getAlipayEnabled())
|
||||
$types[] = GatewayType::ALIPAY;
|
||||
|
||||
if ($this->company_gateway->getApplePayEnabled())
|
||||
$types[] = GatewayType::APPLE_PAY;
|
||||
|
||||
|
||||
return $types;
|
||||
|
||||
}
|
||||
/************************************** Omnipay API methods **********************************************************/
|
||||
|
||||
|
||||
@ -48,11 +85,4 @@ class StripePaymentDriver extends BasePaymentDriver
|
||||
|
||||
|
||||
|
||||
/************************************** Stripe API methods **********************************************************/
|
||||
|
||||
public function init($api_key)
|
||||
{
|
||||
Stripe::setApiKey($api_key);
|
||||
}
|
||||
|
||||
}
|
@ -95,7 +95,7 @@
|
||||
<div class="col-sm-6 col-lg-3">
|
||||
<div class="card text-white bg-secondary h-100">
|
||||
<div class="card-body align-items-center d-flex justify-content-center">
|
||||
<button class="btn btn-primary btn-lg"><i class="fa fa-plus" style="" aria-hidden="true"></i> {{ ctrans('texts.add_payment_method')}}</button>
|
||||
<a class="btn btn-primary btn-lg" href="{{ route('client.payment_methods.create') }}"><i class="fa fa-plus" style="" aria-hidden="true"></i> {{ ctrans('texts.add_payment_method')}}</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
Loading…
x
Reference in New Issue
Block a user