diff --git a/app/Http/Controllers/ClientPortalController.php b/app/Http/Controllers/ClientPortalController.php
index 2bb550759b1c..23137b95a349 100644
--- a/app/Http/Controllers/ClientPortalController.php
+++ b/app/Http/Controllers/ClientPortalController.php
@@ -111,6 +111,8 @@ class ClientPortalController extends BaseController
if($braintreeGateway->getPayPalEnabled()) {
$data['braintreeClientToken'] = $this->paymentService->getBraintreeClientToken($account);
}
+ } elseif ($wepayGateway = $account->getGatewayConfig(GATEWAY_WEPAY)){
+ $data['enableWePayACH'] = $wepayGateway->getAchEnabled();
}
$showApprove = $invoice->quote_invoice_id ? false : true;
@@ -224,43 +226,39 @@ class ClientPortalController extends BaseController
foreach(Gateway::$paymentTypes as $type) {
if ($gateway = $account->getGatewayByType($type)) {
- $types = array($type);
-
- if ($type == PAYMENT_TYPE_STRIPE) {
- $types = array(PAYMENT_TYPE_STRIPE_CREDIT_CARD);
- if ($gateway->getAchEnabled()) {
- $types[] = PAYMENT_TYPE_STRIPE_ACH;
+ if ($type == PAYMENT_TYPE_DIRECT_DEBIT) {
+ if ($gateway->gateway_id == GATEWAY_STRIPE) {
+ $type = PAYMENT_TYPE_STRIPE_ACH;
+ } elseif ($gateway->gateway_id == GATEWAY_WEPAY) {
+ $type = PAYMENT_TYPE_WEPAY_ACH;
}
+ } elseif ($type == PAYMENT_TYPE_PAYPAL && $gateway->gateway_id == GATEWAY_BRAINTREE) {
+ $type = PAYMENT_TYPE_BRAINTREE_PAYPAL;
+ } elseif ($type == PAYMENT_TYPE_CREDIT_CARD && $gateway->gateway_id == GATEWAY_STRIPE) {
+ $type = PAYMENT_TYPE_STRIPE_CREDIT_CARD;
}
- foreach($types as $type) {
- $typeLink = strtolower(str_replace('PAYMENT_TYPE_', '', $type));
- $url = URL::to("/payment/{$invitation->invitation_key}/{$typeLink}");
+ $typeLink = strtolower(str_replace('PAYMENT_TYPE_', '', $type));
+ $url = URL::to("/payment/{$invitation->invitation_key}/{$typeLink}");
- // PayPal doesn't allow being run in an iframe so we need to open in new tab
- if ($type === PAYMENT_TYPE_PAYPAL && $account->iframe_url) {
- $url = 'javascript:window.open("' . $url . '", "_blank")';
- }
-
- if ($type == PAYMENT_TYPE_STRIPE_CREDIT_CARD) {
- $label = trans('texts.' . strtolower(PAYMENT_TYPE_CREDIT_CARD));
- } elseif ($type == PAYMENT_TYPE_STRIPE_ACH) {
- $label = trans('texts.' . strtolower(PAYMENT_TYPE_DIRECT_DEBIT));
- } else {
- $label = trans('texts.' . strtolower($type));
- }
-
- $paymentTypes[] = [
- 'url' => $url, 'label' => $label
- ];
-
- if($gateway->getPayPalEnabled()) {
- $paymentTypes[] = [
- 'label' => trans('texts.paypal'),
- 'url' => $url = URL::to("/payment/{$invitation->invitation_key}/braintree_paypal"),
- ];
- }
+ // PayPal doesn't allow being run in an iframe so we need to open in new tab
+ if ($type === PAYMENT_TYPE_PAYPAL && $account->iframe_url) {
+ $url = 'javascript:window.open("' . $url . '", "_blank")';
}
+
+ if ($type == PAYMENT_TYPE_STRIPE_CREDIT_CARD) {
+ $label = trans('texts.' . strtolower(PAYMENT_TYPE_CREDIT_CARD));
+ } elseif ($type == PAYMENT_TYPE_STRIPE_ACH || $type == PAYMENT_TYPE_WEPAY_ACH) {
+ $label = trans('texts.' . strtolower(PAYMENT_TYPE_DIRECT_DEBIT));
+ } elseif ($type == PAYMENT_TYPE_BRAINTREE_PAYPAL) {
+ $label = trans('texts.' . strtolower(PAYMENT_TYPE_PAYPAL));
+ } else {
+ $label = trans('texts.' . strtolower($type));
+ }
+
+ $paymentTypes[] = [
+ 'url' => $url, 'label' => $label
+ ];
}
}
diff --git a/app/Http/Controllers/PaymentController.php b/app/Http/Controllers/PaymentController.php
index f62f24f51348..0eaeb2f7fede 100644
--- a/app/Http/Controllers/PaymentController.php
+++ b/app/Http/Controllers/PaymentController.php
@@ -156,7 +156,23 @@ class PaymentController extends BaseController
$details = json_decode(Input::get('details'));
$data['details'] = $details;
- if ($paymentType != PAYMENT_TYPE_BRAINTREE_PAYPAL) {
+
+ if ($paymentType == PAYMENT_TYPE_BRAINTREE_PAYPAL) {
+ if ($deviceData = Input::get('device_data')) {
+ Session::put($invitation->id . 'device_data', $deviceData);
+ }
+
+ Session::put($invitation->id . 'payment_type', PAYMENT_TYPE_BRAINTREE_PAYPAL);
+ if (!$sourceId || !$details) {
+ return Redirect::to('view/'.$invitationKey);
+ }
+ } elseif ($paymentType == PAYMENT_TYPE_WEPAY_ACH) {
+ Session::put($invitation->id . 'payment_type', PAYMENT_TYPE_WEPAY_ACH);
+
+ if (!$sourceId) {
+ return Redirect::to('view/'.$invitationKey);
+ }
+ } else {
if ($paymentType == PAYMENT_TYPE_TOKEN) {
$useToken = true;
$accountGateway = $invoice->client->account->getTokenGateway();
@@ -206,15 +222,6 @@ class PaymentController extends BaseController
$data['tokenize'] = true;
}
- } else {
- if ($deviceData = Input::get('device_data')) {
- Session::put($invitation->id . 'device_data', $deviceData);
- }
-
- Session::put($invitation->id . 'payment_type', PAYMENT_TYPE_BRAINTREE_PAYPAL);
- if (!$sourceId || !$details) {
- return Redirect::to('view/'.$invitationKey);
- }
}
$data += [
@@ -497,7 +504,6 @@ class PaymentController extends BaseController
->withInput(Request::except('cvv'));
}
-
try {
// For offsite payments send the client's details on file
// If we're using a token then we don't need to send any other data
@@ -511,17 +517,22 @@ class PaymentController extends BaseController
$details = $this->paymentService->getPaymentDetails($invitation, $accountGateway, $data);
$details['paymentType'] = $paymentType;
+ // Check for authorization
+ if (($paymentType == PAYMENT_TYPE_STRIPE_ACH || $paymentType == PAYMENT_TYPE_WEPAY_ACH) && !Input::get('authorize_ach')) {
+ Session::flash('error', trans('texts.ach_authorization_required'));
+ return Redirect::to('client/paymentmethods/add/' . $typeLink.'/'.$sourceToken)->withInput(Request::except('cvv'));
+ }
+ if ($paymentType == PAYMENT_TYPE_WEPAY_ACH && !Input::get('tos_agree')) {
+ Session::flash('error', trans('texts.wepay_payment_tos_agree_required'));
+ return Redirect::to('client/paymentmethods/add/' . $typeLink.'/'.$sourceToken)->withInput(Request::except('cvv'));
+ }
+
// check if we're creating/using a billing token
$tokenBillingSupported = false;
$sourceReferenceParam = 'token';
if ($accountGateway->gateway_id == GATEWAY_STRIPE) {
$tokenBillingSupported = true;
$customerReferenceParam = 'customerReference';
-
- if ($paymentType == PAYMENT_TYPE_STRIPE_ACH && !Input::get('authorize_ach')) {
- Session::flash('error', trans('texts.ach_authorization_required'));
- return Redirect::to('payment/'.$invitationKey)->withInput(Request::except('cvv'));
- }
} elseif ($accountGateway->gateway_id == GATEWAY_BRAINTREE) {
$tokenBillingSupported = true;
$sourceReferenceParam = 'paymentMethodToken';
@@ -547,8 +558,8 @@ class PaymentController extends BaseController
}
$details[$sourceReferenceParam] = $sourceReference;
unset($details['card']);
- } elseif ($account->token_billing_type_id == TOKEN_BILLING_ALWAYS || Input::get('token_billing') || $paymentType == PAYMENT_TYPE_STRIPE_ACH) {
- $token = $this->paymentService->createToken($gateway, $details, $accountGateway, $client, $invitation->contact_id, $customerReference/* return parameter */, $paymentMethod/* return parameter */);
+ } elseif ($account->token_billing_type_id == TOKEN_BILLING_ALWAYS || Input::get('token_billing') || $paymentType == PAYMENT_TYPE_STRIPE_ACH || $paymentType == PAYMENT_TYPE_WEPAY_ACH) {
+ $token = $this->paymentService->createToken($paymentType, $gateway, $details, $accountGateway, $client, $invitation->contact_id, $customerReference/* return parameter */, $paymentMethod/* return parameter */);
if ($token) {
$details[$sourceReferenceParam] = $token;
if ($customerReferenceParam) {
@@ -586,7 +597,7 @@ class PaymentController extends BaseController
if (!$ref) {
$this->error('No-Ref', $response->getMessage(), $accountGateway);
- if ($onSite && $paymentType != PAYMENT_TYPE_BRAINTREE_PAYPAL) {
+ if ($onSite && $paymentType != PAYMENT_TYPE_BRAINTREE_PAYPAL && $paymentType != PAYMENT_TYPE_WEPAY_ACH) {
return Redirect::to('payment/'.$invitationKey)
->withInput(Request::except('cvv'));
} else {
@@ -614,7 +625,7 @@ class PaymentController extends BaseController
$response->redirect();
} else {
$this->error('Unknown', $response->getMessage(), $accountGateway);
- if ($onSite && $paymentType != PAYMENT_TYPE_BRAINTREE_PAYPAL) {
+ if ($onSite && $paymentType != PAYMENT_TYPE_BRAINTREE_PAYPAL && $paymentType != PAYMENT_TYPE_WEPAY_ACH) {
return Redirect::to('payment/'.$invitationKey)->withInput(Request::except('cvv'));
} else {
return Redirect::to('view/'.$invitationKey);
@@ -622,7 +633,7 @@ class PaymentController extends BaseController
}
} catch (\Exception $e) {
$this->error('Uncaught', false, $accountGateway, $e);
- if ($onSite && $paymentType != PAYMENT_TYPE_BRAINTREE_PAYPAL) {
+ if ($onSite && $paymentType != PAYMENT_TYPE_BRAINTREE_PAYPAL && $paymentType != PAYMENT_TYPE_WEPAY_ACH) {
return Redirect::to('payment/'.$invitationKey)->withInput(Request::except('cvv'));
} else {
return Redirect::to('view/'.$invitationKey);
diff --git a/resources/lang/en/texts.php b/resources/lang/en/texts.php
index 7f6f5305bc3a..fea3663d3312 100644
--- a/resources/lang/en/texts.php
+++ b/resources/lang/en/texts.php
@@ -1334,7 +1334,9 @@ $LANG = array(
'wepay_payment_tos_agree' => 'I agree to the WePay :terms and :privacy_policy.',
'privacy_policy' => 'Privacy Policy',
'wepay_payment_tos_agree_required' => 'You must agree to the WePay Terms of Service and Privacy Policy.',
- 'payment_settings_supported_gateways' => 'These options are supported by the WePay, Stripe, and Braintree gateways.'
+ 'payment_settings_supported_gateways' => 'These options are supported by the WePay, Stripe, and Braintree gateways.',
+ 'ach_email_prompt' => 'Please enter your email address:',
+ 'verification_pending' => 'Verification Pending',
);
return $LANG;
diff --git a/resources/views/invoices/view.blade.php b/resources/views/invoices/view.blade.php
index 5c32210f0c80..5575cb28862b 100644
--- a/resources/views/invoices/view.blade.php
+++ b/resources/views/invoices/view.blade.php
@@ -59,6 +59,35 @@
})
});
+ @elseif(!empty($enableWePayACH))
+
+
@endif
@stop
diff --git a/resources/views/payments/paymentmethods_list.blade.php b/resources/views/payments/paymentmethods_list.blade.php
index 3a6e96715897..153a9847bffa 100644
--- a/resources/views/payments/paymentmethods_list.blade.php
+++ b/resources/views/payments/paymentmethods_list.blade.php
@@ -50,20 +50,25 @@
@elseif($gateway->gateway_id == GATEWAY_WEPAY && $gateway->getAchEnabled())
-