1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-08 12:12:48 +01:00

Support WePay in UK

This commit is contained in:
Hillel Coren 2017-07-04 12:24:49 +03:00
parent c2d2c05c81
commit 3f1720a4d5
4 changed files with 22 additions and 32 deletions

View File

@ -87,7 +87,6 @@ WEPAY_CLIENT_ID=
WEPAY_CLIENT_SECRET= WEPAY_CLIENT_SECRET=
WEPAY_ENVIRONMENT=production # production or stage WEPAY_ENVIRONMENT=production # production or stage
WEPAY_AUTO_UPDATE=true # Requires permission from WePay WEPAY_AUTO_UPDATE=true # Requires permission from WePay
WEPAY_ENABLE_CANADA=true
WEPAY_FEE_PAYER=payee WEPAY_FEE_PAYER=payee
WEPAY_APP_FEE_CC_MULTIPLIER=0 WEPAY_APP_FEE_CC_MULTIPLIER=0
WEPAY_APP_FEE_ACH_MULTIPLIER=0 WEPAY_APP_FEE_ACH_MULTIPLIER=0

View File

@ -511,7 +511,6 @@ if (! defined('APP_NAME')) {
define('WEPAY_CLIENT_SECRET', env('WEPAY_CLIENT_SECRET')); define('WEPAY_CLIENT_SECRET', env('WEPAY_CLIENT_SECRET'));
define('WEPAY_AUTO_UPDATE', env('WEPAY_AUTO_UPDATE', false)); define('WEPAY_AUTO_UPDATE', env('WEPAY_AUTO_UPDATE', false));
define('WEPAY_ENVIRONMENT', env('WEPAY_ENVIRONMENT', WEPAY_PRODUCTION)); define('WEPAY_ENVIRONMENT', env('WEPAY_ENVIRONMENT', WEPAY_PRODUCTION));
define('WEPAY_ENABLE_CANADA', env('WEPAY_ENABLE_CANADA', false));
define('WEPAY_THEME', env('WEPAY_THEME', '{"name":"Invoice Ninja","primary_color":"0b4d78","secondary_color":"0b4d78","background_color":"f8f8f8","button_color":"33b753"}')); define('WEPAY_THEME', env('WEPAY_THEME', '{"name":"Invoice Ninja","primary_color":"0b4d78","secondary_color":"0b4d78","background_color":"f8f8f8","button_color":"33b753"}'));
define('SKYPE_CARD_RECEIPT', 'message/card.receipt'); define('SKYPE_CARD_RECEIPT', 'message/card.receipt');

View File

@ -378,12 +378,9 @@ class AccountGatewayController extends BaseController
'first_name' => 'required', 'first_name' => 'required',
'last_name' => 'required', 'last_name' => 'required',
'email' => 'required|email', 'email' => 'required|email',
'country' => 'required|in:US,CA,GB',
]; ];
if (WEPAY_ENABLE_CANADA) {
$rules['country'] = 'required|in:US,CA';
}
$validator = Validator::make(Input::all(), $rules); $validator = Validator::make(Input::all(), $rules);
if ($validator->fails()) { if ($validator->fails()) {
@ -428,15 +425,14 @@ class AccountGatewayController extends BaseController
'theme_object' => json_decode(WEPAY_THEME), 'theme_object' => json_decode(WEPAY_THEME),
'callback_uri' => $accountGateway->getWebhookUrl(), 'callback_uri' => $accountGateway->getWebhookUrl(),
'rbits' => $account->present()->rBits, 'rbits' => $account->present()->rBits,
'country' => Input::get('country'),
]; ];
if (WEPAY_ENABLE_CANADA) { if (Input::get('country') == 'CA') {
$accountDetails['country'] = Input::get('country'); $accountDetails['currencies'] = ['CAD'];
$accountDetails['country_options'] = ['debit_opt_in' => boolval(Input::get('debit_cards'))];
if (Input::get('country') == 'CA') { } elseif (Input::get('country') == 'GB') {
$accountDetails['currencies'] = ['CAD']; $accountDetails['currencies'] = ['GBP'];
$accountDetails['country_options'] = ['debit_opt_in' => boolval(Input::get('debit_cards'))];
}
} }
$wepayAccount = $wepay->request('account/create/', $accountDetails); $wepayAccount = $wepay->request('account/create/', $accountDetails);
@ -461,7 +457,7 @@ class AccountGatewayController extends BaseController
'accountId' => $wepayAccount->account_id, 'accountId' => $wepayAccount->account_id,
'state' => $wepayAccount->state, 'state' => $wepayAccount->state,
'testMode' => WEPAY_ENVIRONMENT == WEPAY_STAGE, 'testMode' => WEPAY_ENVIRONMENT == WEPAY_STAGE,
'country' => WEPAY_ENABLE_CANADA ? Input::get('country') : 'US', 'country' => Input::get('country'),
]); ]);
if ($confirmationRequired) { if ($confirmationRequired) {

View File

@ -25,10 +25,7 @@
{!! Former::populateField('email', $user->email) !!} {!! Former::populateField('email', $user->email) !!}
{!! Former::populateField('show_address', 1) !!} {!! Former::populateField('show_address', 1) !!}
{!! Former::populateField('update_address', 1) !!} {!! Former::populateField('update_address', 1) !!}
{!! Former::populateField('country', 'US') !!}
@if (WEPAY_ENABLE_CANADA)
{!! Former::populateField('country', 'US') !!}
@endif
<div class="panel panel-default"> <div class="panel panel-default">
<div class="panel-heading"> <div class="panel-heading">
@ -40,21 +37,20 @@
{!! Former::text('email') !!} {!! Former::text('email') !!}
{!! Former::text('company_name')->help('wepay_company_name_help')->maxlength(255) !!} {!! Former::text('company_name')->help('wepay_company_name_help')->maxlength(255) !!}
@if (WEPAY_ENABLE_CANADA) <div id="wepay-country">
<div id="wepay-country"> {!! Former::radios('country')
{!! Former::radios('country') ->radios([
->radios([ trans('texts.country_United States') => ['value' => 'US'],
trans('texts.united_states') => ['value' => 'US'], trans('texts.country_Canada') => ['value' => 'CA'],
trans('texts.canada') => ['value' => 'CA'], trans('texts.country_United Kingdom') => ['value' => 'GB'],
]) !!} ]) !!}
</div> </div>
<div id="wepay-accept-debit"> <div id="wepay-accept-debit" style="display:none">
{!! Former::checkbox('debit_cards') {!! Former::checkbox('debit_cards')
->text(trans('texts.accept_debit_cards')) ->text(trans('texts.accept_debit_cards'))
->value(1) !!} ->value(1) !!}
</div> </div>
@endif
{!! Former::checkbox('show_address') {!! Former::checkbox('show_address')
->label(trans('texts.billing_address')) ->label(trans('texts.billing_address'))