mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Added additional custom gateways #1858
This commit is contained in:
parent
3d9f000fd1
commit
4002b755d1
@ -299,9 +299,11 @@ if (! defined('APP_NAME')) {
|
|||||||
define('GATEWAY_PAYTRACE', 56);
|
define('GATEWAY_PAYTRACE', 56);
|
||||||
define('GATEWAY_WEPAY', 60);
|
define('GATEWAY_WEPAY', 60);
|
||||||
define('GATEWAY_BRAINTREE', 61);
|
define('GATEWAY_BRAINTREE', 61);
|
||||||
define('GATEWAY_CUSTOM', 62);
|
define('GATEWAY_CUSTOM1', 62);
|
||||||
define('GATEWAY_GOCARDLESS', 64);
|
define('GATEWAY_GOCARDLESS', 64);
|
||||||
define('GATEWAY_PAYMILL', 66);
|
define('GATEWAY_PAYMILL', 66);
|
||||||
|
define('GATEWAY_CUSTOM2', 67);
|
||||||
|
define('GATEWAY_CUSTOM3', 68);
|
||||||
|
|
||||||
// The customer exists, but only as a local concept
|
// The customer exists, but only as a local concept
|
||||||
// The remote gateway doesn't understand the concept of customers
|
// The remote gateway doesn't understand the concept of customers
|
||||||
@ -451,12 +453,14 @@ if (! defined('APP_NAME')) {
|
|||||||
define('GATEWAY_TYPE_PAYPAL', 3);
|
define('GATEWAY_TYPE_PAYPAL', 3);
|
||||||
define('GATEWAY_TYPE_BITCOIN', 4);
|
define('GATEWAY_TYPE_BITCOIN', 4);
|
||||||
define('GATEWAY_TYPE_DWOLLA', 5);
|
define('GATEWAY_TYPE_DWOLLA', 5);
|
||||||
define('GATEWAY_TYPE_CUSTOM', 6);
|
define('GATEWAY_TYPE_CUSTOM1', 6);
|
||||||
define('GATEWAY_TYPE_ALIPAY', 7);
|
define('GATEWAY_TYPE_ALIPAY', 7);
|
||||||
define('GATEWAY_TYPE_SOFORT', 8);
|
define('GATEWAY_TYPE_SOFORT', 8);
|
||||||
define('GATEWAY_TYPE_SEPA', 9);
|
define('GATEWAY_TYPE_SEPA', 9);
|
||||||
define('GATEWAY_TYPE_GOCARDLESS', 10);
|
define('GATEWAY_TYPE_GOCARDLESS', 10);
|
||||||
define('GATEWAY_TYPE_APPLE_PAY', 11);
|
define('GATEWAY_TYPE_APPLE_PAY', 11);
|
||||||
|
define('GATEWAY_TYPE_CUSTOM2', 12);
|
||||||
|
define('GATEWAY_TYPE_CUSTOM3', 13);
|
||||||
define('GATEWAY_TYPE_TOKEN', 'token');
|
define('GATEWAY_TYPE_TOKEN', 'token');
|
||||||
|
|
||||||
define('TEMPLATE_INVOICE', 'invoice');
|
define('TEMPLATE_INVOICE', 'invoice');
|
||||||
|
@ -52,7 +52,7 @@ class AccountGatewayController extends BaseController
|
|||||||
$accountGateway = AccountGateway::scope($publicId)->firstOrFail();
|
$accountGateway = AccountGateway::scope($publicId)->firstOrFail();
|
||||||
$config = $accountGateway->getConfig();
|
$config = $accountGateway->getConfig();
|
||||||
|
|
||||||
if ($accountGateway->gateway_id != GATEWAY_CUSTOM) {
|
if (! $accountGateway->isCustom()) {
|
||||||
foreach ($config as $field => $value) {
|
foreach ($config as $field => $value) {
|
||||||
$config->$field = str_repeat('*', strlen($value));
|
$config->$field = str_repeat('*', strlen($value));
|
||||||
}
|
}
|
||||||
@ -257,8 +257,6 @@ class AccountGatewayController extends BaseController
|
|||||||
}
|
}
|
||||||
if (! $value && in_array($field, ['testMode', 'developerMode', 'sandbox'])) {
|
if (! $value && in_array($field, ['testMode', 'developerMode', 'sandbox'])) {
|
||||||
// do nothing
|
// do nothing
|
||||||
} elseif ($gatewayId == GATEWAY_CUSTOM) {
|
|
||||||
$config->$field = Utils::isNinjaProd() ? strip_tags($value) : $value;
|
|
||||||
} else {
|
} else {
|
||||||
$config->$field = $value;
|
$config->$field = $value;
|
||||||
}
|
}
|
||||||
|
@ -128,7 +128,7 @@ class ClientPortalController extends BaseController
|
|||||||
$paymentURL = '';
|
$paymentURL = '';
|
||||||
if (count($paymentTypes) == 1) {
|
if (count($paymentTypes) == 1) {
|
||||||
$paymentURL = $paymentTypes[0]['url'];
|
$paymentURL = $paymentTypes[0]['url'];
|
||||||
if ($paymentTypes[0]['gatewayTypeId'] == GATEWAY_TYPE_CUSTOM) {
|
if (in_array($paymentTypes[0]['gatewayTypeId'], [GATEWAY_TYPE_CUSTOM1, GATEWAY_TYPE_CUSTOM2, GATEWAY_TYPE_CUSTOM3])) {
|
||||||
// do nothing
|
// do nothing
|
||||||
} elseif (! $account->isGatewayConfigured(GATEWAY_PAYPAL_EXPRESS)) {
|
} elseif (! $account->isGatewayConfigured(GATEWAY_PAYPAL_EXPRESS)) {
|
||||||
$paymentURL = URL::to($paymentURL);
|
$paymentURL = URL::to($paymentURL);
|
||||||
@ -170,13 +170,6 @@ class ClientPortalController extends BaseController
|
|||||||
'accountGateway' => $paymentDriver->accountGateway,
|
'accountGateway' => $paymentDriver->accountGateway,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($accountGateway = $account->getGatewayByType(GATEWAY_TYPE_CUSTOM)) {
|
|
||||||
$data += [
|
|
||||||
'customGatewayName' => $accountGateway->getConfigField('name'),
|
|
||||||
'customGatewayText' => $accountGateway->getConfigField('text'),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($account->hasFeature(FEATURE_DOCUMENTS) && $this->canCreateZip()) {
|
if ($account->hasFeature(FEATURE_DOCUMENTS) && $this->canCreateZip()) {
|
||||||
|
@ -891,8 +891,10 @@ class Account extends Eloquent
|
|||||||
|
|
||||||
$gatewayTypes = [];
|
$gatewayTypes = [];
|
||||||
$gatewayIds = [];
|
$gatewayIds = [];
|
||||||
|
$usedGatewayIds = [];
|
||||||
|
|
||||||
foreach ($this->account_gateways as $accountGateway) {
|
foreach ($this->account_gateways as $accountGateway) {
|
||||||
|
$usedGatewayIds[] = $accountGateway->gateway_id;
|
||||||
$paymentDriver = $accountGateway->paymentDriver();
|
$paymentDriver = $accountGateway->paymentDriver();
|
||||||
$gatewayTypes = array_unique(array_merge($gatewayTypes, $paymentDriver->gatewayTypes()));
|
$gatewayTypes = array_unique(array_merge($gatewayTypes, $paymentDriver->gatewayTypes()));
|
||||||
}
|
}
|
||||||
|
@ -107,6 +107,11 @@ class AccountGateway extends EntityModel
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function isCustom()
|
||||||
|
{
|
||||||
|
return in_array($this->gateway_id, [GATEWAY_CUSTOM1, GATEWAY_CUSTOM2, GATEWAY_CUSTOM3]);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $config
|
* @param $config
|
||||||
*/
|
*/
|
||||||
|
@ -48,7 +48,9 @@ class Gateway extends Eloquent
|
|||||||
GATEWAY_AUTHORIZE_NET,
|
GATEWAY_AUTHORIZE_NET,
|
||||||
GATEWAY_MOLLIE,
|
GATEWAY_MOLLIE,
|
||||||
GATEWAY_GOCARDLESS,
|
GATEWAY_GOCARDLESS,
|
||||||
GATEWAY_CUSTOM,
|
GATEWAY_CUSTOM1,
|
||||||
|
GATEWAY_CUSTOM2,
|
||||||
|
GATEWAY_CUSTOM3,
|
||||||
];
|
];
|
||||||
|
|
||||||
// allow adding these gateway if another gateway
|
// allow adding these gateway if another gateway
|
||||||
@ -61,7 +63,9 @@ class Gateway extends Eloquent
|
|||||||
GATEWAY_GOCARDLESS,
|
GATEWAY_GOCARDLESS,
|
||||||
GATEWAY_BITPAY,
|
GATEWAY_BITPAY,
|
||||||
GATEWAY_DWOLLA,
|
GATEWAY_DWOLLA,
|
||||||
GATEWAY_CUSTOM,
|
GATEWAY_CUSTOM1,
|
||||||
|
GATEWAY_CUSTOM2,
|
||||||
|
GATEWAY_CUSTOM3,
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -209,6 +213,6 @@ class Gateway extends Eloquent
|
|||||||
|
|
||||||
public function isCustom()
|
public function isCustom()
|
||||||
{
|
{
|
||||||
return $this->id === GATEWAY_CUSTOM;
|
return in_array($this->id, [GATEWAY_CUSTOM1, GATEWAY_CUSTOM2, GATEWAY_CUSTOM3]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,7 @@ class AccountGatewayDatatable extends EntityDatatable
|
|||||||
$accountGateway = $this->getAccountGateway($model->id);
|
$accountGateway = $this->getAccountGateway($model->id);
|
||||||
if ($model->deleted_at) {
|
if ($model->deleted_at) {
|
||||||
return $model->name;
|
return $model->name;
|
||||||
} elseif ($model->gateway_id == GATEWAY_CUSTOM) {
|
} elseif (in_array($model->gateway_id, [GATEWAY_CUSTOM1, GATEWAY_CUSTOM2, GATEWAY_CUSTOM3])) {
|
||||||
$name = $accountGateway->getConfigField('name') . ' [' . trans('texts.custom') . ']';
|
$name = $accountGateway->getConfigField('name') . ' [' . trans('texts.custom') . ']';
|
||||||
return link_to("gateways/{$model->public_id}/edit", $name)->toHtml();
|
return link_to("gateways/{$model->public_id}/edit", $name)->toHtml();
|
||||||
} elseif ($model->gateway_id != GATEWAY_WEPAY) {
|
} elseif ($model->gateway_id != GATEWAY_WEPAY) {
|
||||||
@ -191,8 +191,12 @@ class AccountGatewayDatatable extends EntityDatatable
|
|||||||
},
|
},
|
||||||
function ($model) use ($gatewayType) {
|
function ($model) use ($gatewayType) {
|
||||||
// Only show this action if the given gateway supports this gateway type
|
// Only show this action if the given gateway supports this gateway type
|
||||||
if ($model->gateway_id == GATEWAY_CUSTOM) {
|
if ($model->gateway_id == GATEWAY_CUSTOM1) {
|
||||||
return $gatewayType->id == GATEWAY_TYPE_CUSTOM;
|
return $gatewayType->id == GATEWAY_TYPE_CUSTOM1;
|
||||||
|
} elseif ($model->gateway_id == GATEWAY_CUSTOM2) {
|
||||||
|
return $gatewayType->id == GATEWAY_TYPE_CUSTOM2;
|
||||||
|
} elseif ($model->gateway_id == GATEWAY_CUSTOM3) {
|
||||||
|
return $gatewayType->id == GATEWAY_TYPE_CUSTOM3;
|
||||||
} else {
|
} else {
|
||||||
$accountGateway = $this->getAccountGateway($model->id);
|
$accountGateway = $this->getAccountGateway($model->id);
|
||||||
return $accountGateway->paymentDriver()->supportsGatewayType($gatewayType->id);
|
return $accountGateway->paymentDriver()->supportsGatewayType($gatewayType->id);
|
||||||
@ -229,8 +233,12 @@ class AccountGatewayDatatable extends EntityDatatable
|
|||||||
|
|
||||||
private function getGatewayTypes($id, $gatewayId)
|
private function getGatewayTypes($id, $gatewayId)
|
||||||
{
|
{
|
||||||
if ($gatewayId == GATEWAY_CUSTOM) {
|
if ($gatewayId == GATEWAY_CUSTOM1) {
|
||||||
$gatewayTypes = [GATEWAY_TYPE_CUSTOM];
|
$gatewayTypes = [GATEWAY_TYPE_CUSTOM1];
|
||||||
|
} elseif ($gatewayId == GATEWAY_CUSTOM2) {
|
||||||
|
$gatewayTypes = [GATEWAY_TYPE_CUSTOM2];
|
||||||
|
} elseif ($gatewayId == GATEWAY_CUSTOM3) {
|
||||||
|
$gatewayTypes = [GATEWAY_TYPE_CUSTOM3];
|
||||||
} else {
|
} else {
|
||||||
$accountGateway = $this->getAccountGateway($id);
|
$accountGateway = $this->getAccountGateway($id);
|
||||||
$paymentDriver = $accountGateway->paymentDriver();
|
$paymentDriver = $accountGateway->paymentDriver();
|
||||||
|
@ -977,8 +977,14 @@ class BasePaymentDriver
|
|||||||
|
|
||||||
$gatewayTypeAlias = GatewayType::getAliasFromId($gatewayTypeId);
|
$gatewayTypeAlias = GatewayType::getAliasFromId($gatewayTypeId);
|
||||||
|
|
||||||
if ($gatewayTypeId == GATEWAY_TYPE_CUSTOM) {
|
if ($gatewayTypeId == GATEWAY_TYPE_CUSTOM1) {
|
||||||
$url = 'javascript:showCustomModal();';
|
$url = 'javascript:showCustom1Modal();';
|
||||||
|
$label = e($this->accountGateway->getConfigField('name'));
|
||||||
|
} elseif ($gatewayTypeId == GATEWAY_TYPE_CUSTOM2) {
|
||||||
|
$url = 'javascript:showCustom2Modal();';
|
||||||
|
$label = e($this->accountGateway->getConfigField('name'));
|
||||||
|
} elseif ($gatewayTypeId == GATEWAY_TYPE_CUSTOM3) {
|
||||||
|
$url = 'javascript:showCustom3Modal();';
|
||||||
$label = e($this->accountGateway->getConfigField('name'));
|
$label = e($this->accountGateway->getConfigField('name'));
|
||||||
} else {
|
} else {
|
||||||
$url = $this->paymentUrl($gatewayTypeAlias);
|
$url = $this->paymentUrl($gatewayTypeAlias);
|
||||||
|
@ -1,13 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Ninja\PaymentDrivers;
|
|
||||||
|
|
||||||
class CustomPaymentDriver extends BasePaymentDriver
|
|
||||||
{
|
|
||||||
public function gatewayTypes()
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
GATEWAY_TYPE_CUSTOM,
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
@ -136,6 +136,8 @@ class AddMoreCustomFields extends Migration
|
|||||||
$table->string('ip')->nullable();
|
$table->string('ip')->nullable();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
DB::statement('UPDATE gateways SET provider = "Custom1" WHERE id = 62');
|
||||||
|
DB::statement('UPDATE gateway_types SET alias = "custom1", name = "Custom 1" WHERE id = 6');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -14,12 +14,14 @@ class GatewayTypesSeeder extends Seeder
|
|||||||
['alias' => 'paypal', 'name' => 'PayPal'],
|
['alias' => 'paypal', 'name' => 'PayPal'],
|
||||||
['alias' => 'bitcoin', 'name' => 'Bitcoin'],
|
['alias' => 'bitcoin', 'name' => 'Bitcoin'],
|
||||||
['alias' => 'dwolla', 'name' => 'Dwolla'],
|
['alias' => 'dwolla', 'name' => 'Dwolla'],
|
||||||
['alias' => 'custom', 'name' => 'Custom'],
|
['alias' => 'custom1', 'name' => 'Custom 1'],
|
||||||
['alias' => 'alipay', 'name' => 'Alipay'],
|
['alias' => 'alipay', 'name' => 'Alipay'],
|
||||||
['alias' => 'sofort', 'name' => 'Sofort'],
|
['alias' => 'sofort', 'name' => 'Sofort'],
|
||||||
['alias' => 'sepa', 'name' => 'SEPA'],
|
['alias' => 'sepa', 'name' => 'SEPA'],
|
||||||
['alias' => 'gocardless', 'name' => 'GoCardless'],
|
['alias' => 'gocardless', 'name' => 'GoCardless'],
|
||||||
['alias' => 'apple_pay', 'name' => 'Apple Pay'],
|
['alias' => 'apple_pay', 'name' => 'Apple Pay'],
|
||||||
|
['alias' => 'custom2', 'name' => 'Custom 2'],
|
||||||
|
['alias' => 'custom3', 'name' => 'Custom 3'],
|
||||||
];
|
];
|
||||||
|
|
||||||
foreach ($gateway_types as $gateway_type) {
|
foreach ($gateway_types as $gateway_type) {
|
||||||
|
@ -70,11 +70,13 @@ class PaymentLibrariesSeeder extends Seeder
|
|||||||
['name' => 'WeChat Express', 'provider' => 'WeChat_Express', 'payment_library_id' => 2],
|
['name' => 'WeChat Express', 'provider' => 'WeChat_Express', 'payment_library_id' => 2],
|
||||||
['name' => 'WePay', 'provider' => 'WePay', 'is_offsite' => false, 'sort_order' => 3],
|
['name' => 'WePay', 'provider' => 'WePay', 'is_offsite' => false, 'sort_order' => 3],
|
||||||
['name' => 'Braintree', 'provider' => 'Braintree', 'sort_order' => 3],
|
['name' => 'Braintree', 'provider' => 'Braintree', 'sort_order' => 3],
|
||||||
['name' => 'Custom', 'provider' => 'Custom', 'is_offsite' => true, 'sort_order' => 20],
|
['name' => 'Custom', 'provider' => 'Custom1', 'is_offsite' => true, 'sort_order' => 20],
|
||||||
['name' => 'FirstData Payeezy', 'provider' => 'FirstData_Payeezy'],
|
['name' => 'FirstData Payeezy', 'provider' => 'FirstData_Payeezy'],
|
||||||
['name' => 'GoCardless', 'provider' => 'GoCardlessV2\Redirect', 'sort_order' => 9, 'is_offsite' => true],
|
['name' => 'GoCardless', 'provider' => 'GoCardlessV2\Redirect', 'sort_order' => 9, 'is_offsite' => true],
|
||||||
['name' => 'PagSeguro', 'provider' => 'PagSeguro'],
|
['name' => 'PagSeguro', 'provider' => 'PagSeguro'],
|
||||||
['name' => 'PAYMILL', 'provider' => 'Paymill'],
|
['name' => 'PAYMILL', 'provider' => 'Paymill'],
|
||||||
|
['name' => 'Custom', 'provider' => 'Custom2', 'is_offsite' => true, 'sort_order' => 21],
|
||||||
|
['name' => 'Custom', 'provider' => 'Custom3', 'is_offsite' => true, 'sort_order' => 22],
|
||||||
];
|
];
|
||||||
|
|
||||||
foreach ($gateways as $gateway) {
|
foreach ($gateways as $gateway) {
|
||||||
|
File diff suppressed because one or more lines are too long
@ -263,7 +263,10 @@
|
|||||||
|
|
||||||
updateFeeSample();
|
updateFeeSample();
|
||||||
|
|
||||||
if (gateway_type_id == {{ GATEWAY_TYPE_CUSTOM }} || {{ $account->gateway_fee_enabled ? '0' : '1' }}) {
|
if (gateway_type_id == {{ GATEWAY_TYPE_CUSTOM1 }} ||
|
||||||
|
gateway_type_id == {{ GATEWAY_TYPE_CUSTOM2 }} ||
|
||||||
|
gateway_type_id == {{ GATEWAY_TYPE_CUSTOM3 }} ||
|
||||||
|
{{ $account->gateway_fee_enabled ? '0' : '1' }}) {
|
||||||
$('#feesEnabled').hide();
|
$('#feesEnabled').hide();
|
||||||
$('#feesDisabled').show();
|
$('#feesDisabled').show();
|
||||||
} else {
|
} else {
|
||||||
|
@ -332,8 +332,16 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function showCustomModal() {
|
function showCustom1Modal() {
|
||||||
$('#customGatewayModal').modal('show');
|
$('#custom1GatewayModal').modal('show');
|
||||||
|
}
|
||||||
|
|
||||||
|
function showCustom2Modal() {
|
||||||
|
$('#custom2GatewayModal').modal('show');
|
||||||
|
}
|
||||||
|
|
||||||
|
function showCustom3Modal() {
|
||||||
|
$('#custom3GatewayModal').modal('show');
|
||||||
}
|
}
|
||||||
|
|
||||||
function onModalPayNowClick() {
|
function onModalPayNowClick() {
|
||||||
@ -394,31 +402,19 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
@if (isset($customGatewayName))
|
@if ($customGateway = $account->getGatewayByType(GATEWAY_TYPE_CUSTOM1))
|
||||||
<div class="modal fade" id="customGatewayModal" tabindex="-1" role="dialog" aria-labelledby="customGatewayModalLabel" aria-hidden="true">
|
@include('invited.custom_gateway', ['customGateway' => $customGateway, 'number' => 1])
|
||||||
<div class="modal-dialog">
|
|
||||||
<div class="modal-content">
|
|
||||||
<div class="modal-header">
|
|
||||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
|
||||||
<h4 class="modal-title">{{ $customGatewayName }}</h4>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="panel-body">
|
|
||||||
@if (Utils::isNinjaProd())
|
|
||||||
{!! nl2br(e($customGatewayText)) !!}
|
|
||||||
@else
|
|
||||||
{!! $customGatewayText !!}
|
|
||||||
@endif
|
@endif
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="modal-footer">
|
@if ($customGateway = $account->getGatewayByType(GATEWAY_TYPE_CUSTOM2))
|
||||||
<button type="button" class="btn btn-default" data-dismiss="modal">{{ trans('texts.close') }}</button>
|
@include('invited.custom_gateway', ['customGateway' => $customGateway, 'number' => 2])
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
|
@if ($customGateway = $account->getGatewayByType(GATEWAY_TYPE_CUSTOM3))
|
||||||
|
@include('invited.custom_gateway', ['customGateway' => $customGateway, 'number' => 3])
|
||||||
|
@endif
|
||||||
|
|
||||||
|
|
||||||
@if ($account->requiresAuthorization($invoice))
|
@if ($account->requiresAuthorization($invoice))
|
||||||
<div class="modal fade" id="authorizationModal" tabindex="-1" role="dialog" aria-labelledby="authorizationModalLabel" aria-hidden="true">
|
<div class="modal fade" id="authorizationModal" tabindex="-1" role="dialog" aria-labelledby="authorizationModalLabel" aria-hidden="true">
|
||||||
<div class="modal-dialog">
|
<div class="modal-dialog">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user