From 92c49c3772d856472f3b457f4f5d4e32f96c0e9b Mon Sep 17 00:00:00 2001 From: Chad Little Date: Wed, 9 Aug 2017 19:31:05 -0700 Subject: [PATCH] Minor UX tweaks to Phortune autopay Summary: Fixes T12958. Adds a success message when card is added, also switches to use radio buttons for clarity. Updated redirect uri for deleting methods as well. Test Plan: Add cards, remove cards. {F5091084} Reviewers: epriestley Reviewed By: epriestley Subscribers: Korvin Maniphest Tasks: T12958 Differential Revision: https://secure.phabricator.com/D18381 --- .../PhortunePaymentMethodCreateController.php | 3 ++- ...PhortunePaymentMethodDisableController.php | 5 ++-- .../PhortuneSubscriptionEditController.php | 27 ++++++++++++++----- 3 files changed, 25 insertions(+), 10 deletions(-) diff --git a/src/applications/phortune/controller/payment/PhortunePaymentMethodCreateController.php b/src/applications/phortune/controller/payment/PhortunePaymentMethodCreateController.php index 794f97aa8e..87bddd4d33 100644 --- a/src/applications/phortune/controller/payment/PhortunePaymentMethodCreateController.php +++ b/src/applications/phortune/controller/payment/PhortunePaymentMethodCreateController.php @@ -123,7 +123,8 @@ final class PhortunePaymentMethodCreateController $next_uri = $this->getApplicationURI( "cart/{$cart_id}/checkout/?paymentMethodID=".$method->getID()); } else if ($subscription_id) { - $next_uri = $cancel_uri; + $next_uri = new PhutilURI($cancel_uri); + $next_uri->setQueryParam('added', true); } else { $account_uri = $this->getApplicationURI($account->getID().'/'); $next_uri = new PhutilURI($account_uri); diff --git a/src/applications/phortune/controller/payment/PhortunePaymentMethodDisableController.php b/src/applications/phortune/controller/payment/PhortunePaymentMethodDisableController.php index d00db2725f..f5feec8a29 100644 --- a/src/applications/phortune/controller/payment/PhortunePaymentMethodDisableController.php +++ b/src/applications/phortune/controller/payment/PhortunePaymentMethodDisableController.php @@ -25,11 +25,12 @@ final class PhortunePaymentMethodDisableController } $account = $method->getAccount(); - $account_uri = $this->getApplicationURI($account->getID().'/'); + $account_id = $account->getID(); + $account_uri = $this->getApplicationURI("/account/billing/{$account_id}/"); if ($request->isFormPost()) { - // TODO: ApplicationTransactions! + // TODO: ApplicationTransactions!!!! $method ->setStatus(PhortunePaymentMethod::STATUS_DISABLED) ->save(); diff --git a/src/applications/phortune/controller/subscription/PhortuneSubscriptionEditController.php b/src/applications/phortune/controller/subscription/PhortuneSubscriptionEditController.php index 185bbdbcc6..e7287f3d29 100644 --- a/src/applications/phortune/controller/subscription/PhortuneSubscriptionEditController.php +++ b/src/applications/phortune/controller/subscription/PhortuneSubscriptionEditController.php @@ -4,6 +4,7 @@ final class PhortuneSubscriptionEditController extends PhortuneController { public function handleRequest(AphrontRequest $request) { $viewer = $this->getViewer(); + $added = $request->getBool('added'); $subscription = id(new PhortuneSubscriptionQuery()) ->setViewer($viewer) @@ -112,6 +113,7 @@ final class PhortuneSubscriptionEditController extends PhortuneController { pht('Subscription %d', $subscription->getID()), $view_uri); $crumbs->addTextCrumb(pht('Edit')); + $crumbs->setBorder(true); $uri = $this->getApplicationURI($account->getID().'/card/new/'); @@ -127,15 +129,19 @@ final class PhortuneSubscriptionEditController extends PhortuneController { ), pht('Add Payment Method...')); + $radio = id(new AphrontFormRadioButtonControl()) + ->setName('defaultPaymentMethodPHID') + ->setLabel(pht('Autopay With')) + ->setValue($current_phid) + ->setError($e_method); + + foreach ($options as $key => $value) { + $radio->addButton($key, $value, null); + } + $form = id(new AphrontFormView()) ->setUser($viewer) - ->appendChild( - id(new AphrontFormSelectControl()) - ->setName('defaultPaymentMethodPHID') - ->setLabel(pht('Autopay With')) - ->setValue($current_phid) - ->setError($e_method) - ->setOptions($options)) + ->appendChild($radio) ->appendChild( id(new AphrontFormMarkupControl()) ->setValue($add_method_button)) @@ -151,6 +157,13 @@ final class PhortuneSubscriptionEditController extends PhortuneController { ->setFormErrors($errors) ->appendChild($form); + if ($added) { + $info_view = id(new PHUIInfoView()) + ->setSeverity(PHUIInfoView::SEVERITY_SUCCESS) + ->appendChild(pht('Payment method has been successfully added.')); + $box->setInfoView($info_view); + } + $header = id(new PHUIHeaderView()) ->setHeader(pht('Edit %s', $subscription->getSubscriptionName())) ->setHeaderIcon('fa-pencil');