diff --git a/app/Http/Controllers/AccountGatewayController.php b/app/Http/Controllers/AccountGatewayController.php index d28e73850481..e28a1cc94917 100644 --- a/app/Http/Controllers/AccountGatewayController.php +++ b/app/Http/Controllers/AccountGatewayController.php @@ -294,6 +294,10 @@ class AccountGatewayController extends BaseController $config->plaidPublicKey = $oldConfig->plaidPublicKey; } + if ($gatewayId == GATEWAY_STRIPE) { + $config->enableAlipay = boolval(Input::get('enable_alipay')); + } + if ($gatewayId == GATEWAY_STRIPE || $gatewayId == GATEWAY_WEPAY) { $config->enableAch = boolval(Input::get('enable_ach')); } diff --git a/app/Models/AccountGateway.php b/app/Models/AccountGateway.php index e20069bd4e55..2b0acadf94f6 100644 --- a/app/Models/AccountGateway.php +++ b/app/Models/AccountGateway.php @@ -149,10 +149,6 @@ class AccountGateway extends EntityModel */ public function getAlipayEnabled() { - if (\Utils::isNinjaDev()) { - return true; - } - return ! empty($this->getConfigField('enableAlipay')); } diff --git a/resources/lang/en/texts.php b/resources/lang/en/texts.php index 2a8bdb6faa80..5b25e21bc9ae 100644 --- a/resources/lang/en/texts.php +++ b/resources/lang/en/texts.php @@ -1214,7 +1214,7 @@ $LANG = array( 'payment_type_stripe' => 'Stripe', 'ach' => '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 in :link.', 'ach_disabled' => 'Another gateway is already configured for direct debit.', 'plaid' => 'Plaid', @@ -2438,7 +2438,9 @@ $LANG = array( 'deleted_company_details' => 'Your company (:account) has been successfully deleted.', 'deleted_account_details' => 'Your account (:account) has been successfully deleted.', - + 'alipay' => 'Alipay', + 'enable_alipay' => 'Enable Alipay', + 'stripe_alipay_help' => 'ACH/Alipay support must also be enabled in :link.', ); diff --git a/resources/views/accounts/account_gateway.blade.php b/resources/views/accounts/account_gateway.blade.php index 42cd72d677d3..835b6e2f6bd1 100644 --- a/resources/views/accounts/account_gateway.blade.php +++ b/resources/views/accounts/account_gateway.blade.php @@ -19,6 +19,7 @@ {!! Former::populateField('update_address', intval($accountGateway->update_address)) !!} {!! Former::populateField('publishable_key', $accountGateway->getPublishableStripeKey() ? str_repeat('*', strlen($accountGateway->getPublishableStripeKey())) : '') !!} {!! Former::populateField('enable_ach', $accountGateway->getAchEnabled() ? 1 : 0) !!} + {!! Former::populateField('enable_alipay', $accountGateway->getAlipayEnabled() ? 1 : 0) !!} {!! Former::populateField('enable_paypal', $accountGateway->getPayPalEnabled() ? 1 : 0) !!} {!! Former::populateField('plaid_client_id', $accountGateway->getPlaidClientId() ? str_repeat('*', strlen($accountGateway->getPlaidClientId())) : '') !!} {!! Former::populateField('plaid_secret', $accountGateway->getPlaidSecret() ? str_repeat('*', strlen($accountGateway->getPlaidSecret())) : '') !!} @@ -149,7 +150,12 @@ {!! Former::checkbox('enable_ach') ->label(trans('texts.ach')) ->text(trans('texts.enable_ach')) - ->help(trans('texts.stripe_ach_help')) + ->value(1) !!} + + {!! Former::checkbox('enable_alipay') + ->label(trans('texts.alipay')) + ->text(trans('texts.enable_alipay')) + ->help(trans('texts.stripe_alipay_help', ['link' => link_to('https://dashboard.stripe.com/account/payments/settings', 'Stripe', ['target' => '_blank'])])) ->value(1) !!}
diff --git a/resources/views/invoices/edit.blade.php b/resources/views/invoices/edit.blade.php index baad843aae60..378962bb48d0 100644 --- a/resources/views/invoices/edit.blade.php +++ b/resources/views/invoices/edit.blade.php @@ -1164,19 +1164,22 @@ @endif var invoice = createInvoiceModel(); - if (! checkedInvoiceBalances) { - // check amounts are correct - checkedInvoiceBalances = true; - var phpBalance = invoice.balance; - var koBalance = model.invoice().totals.rawTotal(); - var jsBalance = calculateAmounts(invoice).total_amount; - if (phpBalance == koBalance && koBalance == jsBalance) { - // do nothing - } else { - var invitationKey = invoice.invitations[0].invitation_key; - window.onerror(invitationKey + ': Balances do not match | PHP: ' + phpBalance + ', JS: ' + jsBalance + ', KO: ' + koBalance); + + @if ($invoice->exists) + if (! checkedInvoiceBalances) { + // check amounts are correct + checkedInvoiceBalances = true; + var phpBalance = invoice.balance; + var koBalance = model.invoice().totals.rawTotal(); + var jsBalance = calculateAmounts(invoice).total_amount; + if (phpBalance == koBalance && koBalance == jsBalance) { + // do nothing + } else { + var invitationKey = invoice.invitations[0].invitation_key; + window.onerror(invitationKey + ': Balances do not match | PHP: ' + phpBalance + ', JS: ' + jsBalance + ', KO: ' + koBalance); + } } - } + @endif @if ( ! $account->live_preview) return;