From e678d2be626fb8c1fec5bdb8f5c1a0a2716911e2 Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Wed, 1 Jul 2015 22:01:12 +0300 Subject: [PATCH] Fix for when user cancels Dwolla payment --- app/Http/Controllers/AccountGatewayController.php | 2 +- app/Http/Controllers/PaymentController.php | 8 ++++++++ app/Models/AccountGateway.php | 4 ++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/AccountGatewayController.php b/app/Http/Controllers/AccountGatewayController.php index c1d570c6534f..b6f3c5df22d5 100644 --- a/app/Http/Controllers/AccountGatewayController.php +++ b/app/Http/Controllers/AccountGatewayController.php @@ -200,7 +200,7 @@ class AccountGatewayController extends BaseController $fields = $gateway->getFields(); $optional = array_merge(Gateway::$hiddenFields, Gateway::$optionalFields); - if (Utils::isNinja() && $gatewayId == GATEWAY_DWOLLA) { + if ($gatewayId == GATEWAY_DWOLLA) { $optional = array_merge($optional, ['key', 'secret']); } diff --git a/app/Http/Controllers/PaymentController.php b/app/Http/Controllers/PaymentController.php index 4196e1d1661f..ff84d3b97e5b 100644 --- a/app/Http/Controllers/PaymentController.php +++ b/app/Http/Controllers/PaymentController.php @@ -685,6 +685,14 @@ class PaymentController extends BaseController $accountGateway = $invoice->client->account->getGatewayByType(Session::get('payment_type')); $gateway = self::createGateway($accountGateway); + // Check for Dwolla payment error + if ($accountGateway->isGateway(GATEWAY_DWOLLA) && Input::get('error')) { + $errorMessage = trans('texts.payment_error')."\n\n".Input::get('error_description'); + Session::flash('error', $errorMessage); + Utils::logError($errorMessage); + return Redirect::to('view/'.$invitation->invitation_key); + } + try { if (method_exists($gateway, 'completePurchase')) { $details = self::getPaymentDetails($invitation); diff --git a/app/Models/AccountGateway.php b/app/Models/AccountGateway.php index 62c3456473ce..16d72076c394 100644 --- a/app/Models/AccountGateway.php +++ b/app/Models/AccountGateway.php @@ -34,5 +34,9 @@ class AccountGateway extends EntityModel public function isPaymentType($type) { return $this->getPaymentType() == $type; } + + public function isGateway($gatewayId) { + return $this->gateway_id == $gatewayId; + } }