1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-01-18 02:31:10 +01:00

When a Phortune subscription has a removed payment method, be more explicit about it

Summary:
Currently, when a payment method is invalid we still render the full name and let you save the form without making changes. This can be confusing.

Instead:

  - Render "<Deleted Payment Method>", literally.
  - Render an error immediately.
  - Prevent the form from being saved without changing the method.

Test Plan: {F1955487}

Reviewers: chad

Reviewed By: chad

Differential Revision: https://secure.phabricator.com/D16935
This commit is contained in:
epriestley 2016-11-23 13:31:17 -08:00
parent f199243104
commit 8958d68ec6

View file

@ -50,6 +50,11 @@ final class PhortuneSubscriptionEditController extends PhortuneController {
$current_phid = $subscription->getDefaultPaymentMethodPHID(); $current_phid = $subscription->getDefaultPaymentMethodPHID();
$e_method = null;
if ($current_phid && empty($valid_methods[$current_phid])) {
$e_method = pht('Needs Update');
}
$errors = array(); $errors = array();
if ($request->isFormPost()) { if ($request->isFormPost()) {
@ -57,12 +62,14 @@ final class PhortuneSubscriptionEditController extends PhortuneController {
if (!$default_method_phid) { if (!$default_method_phid) {
$default_method_phid = null; $default_method_phid = null;
$e_method = null; $e_method = null;
} else if ($default_method_phid == $current_phid) { } else if (empty($valid_methods[$default_method_phid])) {
// If you have an invalid setting already, it's OK to retain it. $e_method = pht('Invalid');
$e_method = null; if ($default_method_phid == $current_phid) {
} else { $errors[] = pht(
if (empty($valid_methods[$default_method_phid])) { 'This subscription is configured to autopay with a payment method '.
$e_method = pht('Invalid'); 'that has been deleted. Choose a valid payment method or disable '.
'autopay.');
} else {
$errors[] = pht('You must select a valid default payment method.'); $errors[] = pht('You must select a valid default payment method.');
} }
} }
@ -86,11 +93,9 @@ final class PhortuneSubscriptionEditController extends PhortuneController {
// Don't require the user to make a valid selection if the current method // Don't require the user to make a valid selection if the current method
// has become invalid. // has become invalid.
// TODO: This should probably have a note about why this is bogus.
if ($current_phid && empty($valid_methods[$current_phid])) { if ($current_phid && empty($valid_methods[$current_phid])) {
$handles = $this->loadViewerHandles(array($current_phid));
$current_options = array( $current_options = array(
$current_phid => $handles[$current_phid]->getName(), $current_phid => pht('<Deleted Payment Method>'),
); );
} else { } else {
$current_options = array(); $current_options = array();
@ -129,6 +134,7 @@ final class PhortuneSubscriptionEditController extends PhortuneController {
->setName('defaultPaymentMethodPHID') ->setName('defaultPaymentMethodPHID')
->setLabel(pht('Autopay With')) ->setLabel(pht('Autopay With'))
->setValue($current_phid) ->setValue($current_phid)
->setError($e_method)
->setOptions($options)) ->setOptions($options))
->appendChild( ->appendChild(
id(new AphrontFormMarkupControl()) id(new AphrontFormMarkupControl())