mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Merge branch 'wepay-ach' into wepay-integration
This commit is contained in:
commit
7d55ab033b
@ -295,7 +295,7 @@ class AccountGatewayController extends BaseController
|
|||||||
$config->plaidPublicKey = $oldConfig->plaidPublicKey;
|
$config->plaidPublicKey = $oldConfig->plaidPublicKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($gatewayId == GATEWAY_STRIPE) {
|
if ($gatewayId == GATEWAY_STRIPE || $gatewayId == GATEWAY_WEPAY) {
|
||||||
$config->enableAch = boolval(Input::get('enable_ach'));
|
$config->enableAch = boolval(Input::get('enable_ach'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -669,6 +669,7 @@ if (!defined('CONTACT_EMAIL')) {
|
|||||||
define('PAYMENT_TYPE_STRIPE_CREDIT_CARD', 'PAYMENT_TYPE_STRIPE_CREDIT_CARD');
|
define('PAYMENT_TYPE_STRIPE_CREDIT_CARD', 'PAYMENT_TYPE_STRIPE_CREDIT_CARD');
|
||||||
define('PAYMENT_TYPE_STRIPE_ACH', 'PAYMENT_TYPE_STRIPE_ACH');
|
define('PAYMENT_TYPE_STRIPE_ACH', 'PAYMENT_TYPE_STRIPE_ACH');
|
||||||
define('PAYMENT_TYPE_BRAINTREE_PAYPAL', 'PAYMENT_TYPE_BRAINTREE_PAYPAL');
|
define('PAYMENT_TYPE_BRAINTREE_PAYPAL', 'PAYMENT_TYPE_BRAINTREE_PAYPAL');
|
||||||
|
define('PAYMENT_TYPE_WEPAY_ACH', 'PAYMENT_TYPE_WEPAY_ACH');
|
||||||
define('PAYMENT_TYPE_CREDIT_CARD', 'PAYMENT_TYPE_CREDIT_CARD');
|
define('PAYMENT_TYPE_CREDIT_CARD', 'PAYMENT_TYPE_CREDIT_CARD');
|
||||||
define('PAYMENT_TYPE_DIRECT_DEBIT', 'PAYMENT_TYPE_DIRECT_DEBIT');
|
define('PAYMENT_TYPE_DIRECT_DEBIT', 'PAYMENT_TYPE_DIRECT_DEBIT');
|
||||||
define('PAYMENT_TYPE_BITCOIN', 'PAYMENT_TYPE_BITCOIN');
|
define('PAYMENT_TYPE_BITCOIN', 'PAYMENT_TYPE_BITCOIN');
|
||||||
|
@ -379,26 +379,27 @@ class Account extends Eloquent
|
|||||||
return $format;
|
return $format;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getGatewayByType($type = PAYMENT_TYPE_ANY)
|
public function getGatewayByType($type = PAYMENT_TYPE_ANY, $exceptFor = null)
|
||||||
{
|
{
|
||||||
if ($type == PAYMENT_TYPE_STRIPE_ACH || $type == PAYMENT_TYPE_STRIPE_CREDIT_CARD) {
|
if ($type == PAYMENT_TYPE_STRIPE_ACH || $type == PAYMENT_TYPE_STRIPE_CREDIT_CARD) {
|
||||||
$type = PAYMENT_TYPE_STRIPE;
|
$type = PAYMENT_TYPE_STRIPE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($type == PAYMENT_TYPE_BRAINTREE_PAYPAL) {
|
|
||||||
$gateway = $this->getGatewayConfig(GATEWAY_BRAINTREE);
|
|
||||||
|
|
||||||
if (!$gateway || !$gateway->getPayPalEnabled()){
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return $gateway;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($this->account_gateways as $gateway) {
|
foreach ($this->account_gateways as $gateway) {
|
||||||
|
if ($exceptFor && ($gateway->id == $exceptFor->id)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (!$type || $type == PAYMENT_TYPE_ANY) {
|
if (!$type || $type == PAYMENT_TYPE_ANY) {
|
||||||
return $gateway;
|
return $gateway;
|
||||||
} elseif ($gateway->isPaymentType($type)) {
|
} elseif ($gateway->isPaymentType($type)) {
|
||||||
return $gateway;
|
return $gateway;
|
||||||
|
} elseif ($type == PAYMENT_TYPE_CREDIT_CARD && $gateway->isPaymentType(PAYMENT_TYPE_STRIPE)) {
|
||||||
|
return $gateway;
|
||||||
|
} elseif ($type == PAYMENT_TYPE_DIRECT_DEBIT && $gateway->getAchEnabled()) {
|
||||||
|
return $gateway;
|
||||||
|
} elseif ($type == PAYMENT_TYPE_PAYPAL && $gateway->getPayPalEnabled()) {
|
||||||
|
return $gateway;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1414,32 +1415,13 @@ class Account extends Eloquent
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function canAddGateway($type){
|
public function canAddGateway($type){
|
||||||
|
if ($type == PAYMENT_TYPE_STRIPE) {
|
||||||
|
$type == PAYMENT_TYPE_CREDIT_CARD;
|
||||||
|
}
|
||||||
|
|
||||||
if($this->getGatewayByType($type)) {
|
if($this->getGatewayByType($type)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if ($type == PAYMENT_TYPE_CREDIT_CARD && $this->getGatewayByType(PAYMENT_TYPE_STRIPE)) {
|
|
||||||
// Stripe is already handling credit card payments
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($type == PAYMENT_TYPE_STRIPE && $this->getGatewayByType(PAYMENT_TYPE_CREDIT_CARD)) {
|
|
||||||
// Another gateway is already handling credit card payments
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($type == PAYMENT_TYPE_DIRECT_DEBIT && $stripeGateway = $this->getGatewayByType(PAYMENT_TYPE_STRIPE)) {
|
|
||||||
if (!empty($stripeGateway->getAchEnabled())) {
|
|
||||||
// Stripe is already handling ACH payments
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($type == PAYMENT_TYPE_PAYPAL && $braintreeGateway = $this->getGatewayConfig(GATEWAY_BRAINTREE)) {
|
|
||||||
if (!empty($braintreeGateway->getPayPalEnabled())) {
|
|
||||||
// PayPal is already enabled
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1203,7 +1203,7 @@ $LANG = array(
|
|||||||
'ach' => 'ACH',
|
'ach' => 'ACH',
|
||||||
'enable_ach' => 'Enable ACH',
|
'enable_ach' => 'Enable ACH',
|
||||||
'stripe_ach_help' => 'ACH support must also be enabled at Stripe.',
|
'stripe_ach_help' => 'ACH support must also be enabled at Stripe.',
|
||||||
'stripe_ach_disabled' => 'Another gateway is already configured for direct debit.',
|
'ach_disabled' => 'Another gateway is already configured for direct debit.',
|
||||||
|
|
||||||
'plaid' => 'Plaid',
|
'plaid' => 'Plaid',
|
||||||
'client_id' => 'Client Id',
|
'client_id' => 'Client Id',
|
||||||
|
@ -111,7 +111,7 @@
|
|||||||
@endif
|
@endif
|
||||||
|
|
||||||
@if ($gateway->id == GATEWAY_BRAINTREE)
|
@if ($gateway->id == GATEWAY_BRAINTREE)
|
||||||
@if ($account->getGatewayByType(PAYMENT_TYPE_PAYPAL))
|
@if ($account->getGatewayByType(PAYMENT_TYPE_PAYPAL, isset($accountGateway)?$accountGateway:null))
|
||||||
{!! Former::checkbox('enable_paypal')
|
{!! Former::checkbox('enable_paypal')
|
||||||
->label(trans('texts.paypal'))
|
->label(trans('texts.paypal'))
|
||||||
->text(trans('texts.braintree_enable_paypal'))
|
->text(trans('texts.braintree_enable_paypal'))
|
||||||
@ -147,33 +147,49 @@
|
|||||||
->class('creditcard-types')
|
->class('creditcard-types')
|
||||||
->addGroupClass('gateway-option')
|
->addGroupClass('gateway-option')
|
||||||
!!}
|
!!}
|
||||||
<div class="stripe-ach">
|
@if(isset($accountGateway) && $accountGateway->gateway_id == GATEWAY_WEPAY)
|
||||||
@if ($account->getGatewayByType(PAYMENT_TYPE_DIRECT_DEBIT))
|
@if ($account->getGatewayByType(PAYMENT_TYPE_DIRECT_DEBIT, $accountGateway))
|
||||||
{!! Former::checkbox('enable_ach')
|
{!! Former::checkbox('enable_ach')
|
||||||
->label(trans('texts.ach'))
|
->label(trans('texts.ach'))
|
||||||
->text(trans('texts.enable_ach'))
|
->text(trans('texts.enable_ach'))
|
||||||
->value(null)
|
->value(null)
|
||||||
->disabled(true)
|
->disabled(true)
|
||||||
->help(trans('texts.stripe_ach_disabled')) !!}
|
->help(trans('texts.ach_disabled')) !!}
|
||||||
@else
|
@else
|
||||||
{!! Former::checkbox('enable_ach')
|
{!! Former::checkbox('enable_ach')
|
||||||
->label(trans('texts.ach'))
|
->label(trans('texts.ach'))
|
||||||
->text(trans('texts.enable_ach'))
|
->text(trans('texts.enable_ach')) !!}
|
||||||
->help(trans('texts.stripe_ach_help')) !!}
|
|
||||||
<div class="stripe-ach-options">
|
|
||||||
<div class="form-group">
|
|
||||||
<div class="col-sm-8 col-sm-offset-4">
|
|
||||||
<h4>{{trans('texts.plaid')}}</h4>
|
|
||||||
<div class="help-block">{{trans('texts.plaid_optional')}}</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{!! Former::text('plaid_client_id')->label(trans('texts.client_id')) !!}
|
|
||||||
{!! Former::text('plaid_secret')->label(trans('texts.secret')) !!}
|
|
||||||
{!! Former::text('plaid_public_key')->label(trans('texts.public_key'))
|
|
||||||
->help(trans('texts.plaid_environment_help')) !!}
|
|
||||||
</div>
|
|
||||||
@endif
|
@endif
|
||||||
</div>
|
|
||||||
|
@elseif(!isset($accountGateway) || $accountGateway->gateway_id == GATEWAY_STRIPE)
|
||||||
|
<div class="stripe-ach">
|
||||||
|
@if ($account->getGatewayByType(PAYMENT_TYPE_DIRECT_DEBIT, isset($accountGateway)?$accountGateway:null))
|
||||||
|
{!! Former::checkbox('enable_ach')
|
||||||
|
->label(trans('texts.ach'))
|
||||||
|
->text(trans('texts.enable_ach'))
|
||||||
|
->value(null)
|
||||||
|
->disabled(true)
|
||||||
|
->help(trans('texts.ach_disabled')) !!}
|
||||||
|
@else
|
||||||
|
{!! Former::checkbox('enable_ach')
|
||||||
|
->label(trans('texts.ach'))
|
||||||
|
->text(trans('texts.enable_ach'))
|
||||||
|
->help(trans('texts.stripe_ach_help')) !!}
|
||||||
|
<div class="stripe-ach-options">
|
||||||
|
<div class="form-group">
|
||||||
|
<div class="col-sm-8 col-sm-offset-4">
|
||||||
|
<h4>{{trans('texts.plaid')}}</h4>
|
||||||
|
<div class="help-block">{{trans('texts.plaid_optional')}}</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{!! Former::text('plaid_client_id')->label(trans('texts.client_id')) !!}
|
||||||
|
{!! Former::text('plaid_secret')->label(trans('texts.secret')) !!}
|
||||||
|
{!! Former::text('plaid_public_key')->label(trans('texts.public_key'))
|
||||||
|
->help(trans('texts.plaid_environment_help')) !!}
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -49,6 +49,18 @@
|
|||||||
->label('Accepted Credit Cards')
|
->label('Accepted Credit Cards')
|
||||||
->checkboxes($creditCardTypes)
|
->checkboxes($creditCardTypes)
|
||||||
->class('creditcard-types') !!}
|
->class('creditcard-types') !!}
|
||||||
|
@if ($account->getGatewayByType(PAYMENT_TYPE_DIRECT_DEBIT))
|
||||||
|
{!! Former::checkbox('enable_ach')
|
||||||
|
->label(trans('texts.ach'))
|
||||||
|
->text(trans('texts.enable_ach'))
|
||||||
|
->value(null)
|
||||||
|
->disabled(true)
|
||||||
|
->help(trans('texts.ach_disabled')) !!}
|
||||||
|
@else
|
||||||
|
{!! Former::checkbox('enable_ach')
|
||||||
|
->label(trans('texts.ach'))
|
||||||
|
->text(trans('texts.enable_ach')) !!}
|
||||||
|
@endif
|
||||||
{!! Former::checkbox('tos_agree')->label(' ')->text(trans('texts.wepay_tos_agree',
|
{!! Former::checkbox('tos_agree')->label(' ')->text(trans('texts.wepay_tos_agree',
|
||||||
['link'=>'<a id="wepay-tos-link" href="https://go.wepay.com/terms-of-service-us" target="_blank">'.trans('texts.wepay_tos_link_text').'</a>']
|
['link'=>'<a id="wepay-tos-link" href="https://go.wepay.com/terms-of-service-us" target="_blank">'.trans('texts.wepay_tos_link_text').'</a>']
|
||||||
))->value('true') !!}
|
))->value('true') !!}
|
||||||
|
@ -133,7 +133,7 @@
|
|||||||
<p> <br/> </p>
|
<p> <br/> </p>
|
||||||
<div>
|
<div>
|
||||||
<div id="paypal-container"></div>
|
<div id="paypal-container"></div>
|
||||||
@if($paymentType != PAYMENT_TYPE_STRIPE_ACH && $paymentType != PAYMENT_TYPE_BRAINTREE_PAYPAL)
|
@if($paymentType != PAYMENT_TYPE_STRIPE_ACH && $paymentType != PAYMENT_TYPE_BRAINTREE_PAYPAL && $paymentType != PAYMENT_TYPE_WEPAY_ACH)
|
||||||
<h3>{{ trans('texts.contact_information') }}</h3>
|
<h3>{{ trans('texts.contact_information') }}</h3>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
|
@ -48,6 +48,24 @@
|
|||||||
})
|
})
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
@elseif($gateway->gateway_id == GATEWAY_WEPAY && $gateway->getAchEnabled())
|
||||||
|
<script type="text/javascript" src="https://static.wepay.com/js/tokenization.v2.js"></script>
|
||||||
|
|
||||||
|
<script type="text/javascript">
|
||||||
|
$(function() {
|
||||||
|
WePay.set_endpoint('{{ WEPAY_ENVIRONMENT }}');
|
||||||
|
// Shortcuts
|
||||||
|
$('#add-ach').click(function(e) {
|
||||||
|
e.preventDefault();
|
||||||
|
WePay.bank_account.create({
|
||||||
|
'client_id': '{{ WEPAY_CLIENT_ID }}',
|
||||||
|
'email':{!! json_encode($contact->email) !!}
|
||||||
|
}, function(data){
|
||||||
|
window.location.href = $('#add-ach').attr('href') + '/' + encodeURIComponent(data.bank_account_id)
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
@endif
|
@endif
|
||||||
@if(!empty($paymentMethods))
|
@if(!empty($paymentMethods))
|
||||||
@foreach ($paymentMethods as $paymentMethod)
|
@foreach ($paymentMethods as $paymentMethod)
|
||||||
@ -88,8 +106,14 @@
|
|||||||
->asLinkTo(URL::to('/client/paymentmethods/add/'.($gateway->getPaymentType() == PAYMENT_TYPE_STRIPE ? 'stripe_credit_card' : 'credit_card'))) !!}
|
->asLinkTo(URL::to('/client/paymentmethods/add/'.($gateway->getPaymentType() == PAYMENT_TYPE_STRIPE ? 'stripe_credit_card' : 'credit_card'))) !!}
|
||||||
@if($gateway->getACHEnabled())
|
@if($gateway->getACHEnabled())
|
||||||
|
|
||||||
|
@if($gateway->gateway_id == GATEWAY_STRIPE)
|
||||||
{!! Button::success(strtoupper(trans('texts.add_bank_account')))
|
{!! Button::success(strtoupper(trans('texts.add_bank_account')))
|
||||||
->asLinkTo(URL::to('/client/paymentmethods/add/stripe_ach')) !!}
|
->asLinkTo(URL::to('/client/paymentmethods/add/stripe_ach')) !!}
|
||||||
|
@elseif($gateway->gateway_id == GATEWAY_WEPAY)
|
||||||
|
{!! Button::success(strtoupper(trans('texts.add_bank_account')))
|
||||||
|
->withAttributes(['id'=>'add-ach'])
|
||||||
|
->asLinkTo(URL::to('/client/paymentmethods/add/wepay_ach')) !!}
|
||||||
|
@endif
|
||||||
@endif
|
@endif
|
||||||
@if($gateway->getPayPalEnabled())
|
@if($gateway->getPayPalEnabled())
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user