@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Allow merchants to disable payment providers and show more UI info

Summary:
Ref T2787.

- Allow merchants to disable payment providers.
- Show more useful information about providers on the payments page.
- Make test vs live more clear.
- Show merchant status.
- Add a description to merchants to flesh them out a bit -- the merchant areas of responsibilities seem to be fitting well with accounts, etc.

Test Plan: {F215109}

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T2787

Differential Revision: https://secure.phabricator.com/D10662

+338 -36
+2
resources/sql/autopatches/20141008.phortunemerchdesc.sql
··· 1 + ALTER TABLE {$NAMESPACE}_phortune.phortune_merchant 2 + ADD description LONGTEXT NOT NULL COLLATE utf8_bin;
+5
resources/sql/autopatches/20141008.phortuneprovdis.sql
··· 1 + ALTER TABLE {$NAMESPACE}_phortune.phortune_paymentproviderconfig 2 + ADD isEnabled BOOL NOT NULL; 3 + 4 + UPDATE {$NAMESPACE}_phortune.phortune_paymentproviderconfig 5 + SET isEnabled = 1;
+2
src/__phutil_library_map__.php
··· 2609 2609 'PhortuneProductQuery' => 'applications/phortune/query/PhortuneProductQuery.php', 2610 2610 'PhortuneProductViewController' => 'applications/phortune/controller/PhortuneProductViewController.php', 2611 2611 'PhortuneProviderActionController' => 'applications/phortune/controller/PhortuneProviderActionController.php', 2612 + 'PhortuneProviderDisableController' => 'applications/phortune/controller/PhortuneProviderDisableController.php', 2612 2613 'PhortuneProviderEditController' => 'applications/phortune/controller/PhortuneProviderEditController.php', 2613 2614 'PhortunePurchase' => 'applications/phortune/storage/PhortunePurchase.php', 2614 2615 'PhortunePurchasePHIDType' => 'applications/phortune/phid/PhortunePurchasePHIDType.php', ··· 5670 5671 'PhortuneProductQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 5671 5672 'PhortuneProductViewController' => 'PhortuneController', 5672 5673 'PhortuneProviderActionController' => 'PhortuneController', 5674 + 'PhortuneProviderDisableController' => 'PhortuneMerchantController', 5673 5675 'PhortuneProviderEditController' => 'PhortuneMerchantController', 5674 5676 'PhortunePurchase' => array( 5675 5677 'PhortuneDAO',
+1
src/applications/phortune/application/PhabricatorPhortuneApplication.php
··· 60 60 ), 61 61 'provider/' => array( 62 62 'edit/(?:(?P<id>\d+)/)?' => 'PhortuneProviderEditController', 63 + 'disable/(?P<id>\d+)/' => 'PhortuneProviderDisableController', 63 64 '(?P<id>\d+)/(?P<action>[^/]+)/' 64 65 => 'PhortuneProviderActionController', 65 66 ),
+12
src/applications/phortune/controller/PhortuneMerchantEditController.php
··· 51 51 52 52 $e_name = true; 53 53 $v_name = $merchant->getName(); 54 + $v_desc = $merchant->getDescription(); 54 55 55 56 $validation_exception = null; 56 57 if ($request->isFormPost()) { 57 58 $v_name = $request->getStr('name'); 59 + $v_desc = $request->getStr('desc'); 58 60 $v_view = $request->getStr('viewPolicy'); 59 61 $v_edit = $request->getStr('editPolicy'); 60 62 61 63 $type_name = PhortuneMerchantTransaction::TYPE_NAME; 64 + $type_desc = PhortuneMerchantTransaction::TYPE_DESCRIPTION; 62 65 $type_view = PhabricatorTransactions::TYPE_VIEW_POLICY; 63 66 $type_edit = PhabricatorTransactions::TYPE_EDIT_POLICY; 64 67 ··· 67 70 $xactions[] = id(new PhortuneMerchantTransaction()) 68 71 ->setTransactionType($type_name) 69 72 ->setNewValue($v_name); 73 + 74 + $xactions[] = id(new PhortuneMerchantTransaction()) 75 + ->setTransactionType($type_desc) 76 + ->setNewValue($v_desc); 70 77 71 78 $xactions[] = id(new PhortuneMerchantTransaction()) 72 79 ->setTransactionType($type_view) ··· 110 117 ->setLabel(pht('Name')) 111 118 ->setValue($v_name) 112 119 ->setError($e_name)) 120 + ->appendChild( 121 + id(new PhabricatorRemarkupControl()) 122 + ->setName('desc') 123 + ->setLabel(pht('Description')) 124 + ->setValue($v_desc)) 113 125 ->appendChild( 114 126 id(new AphrontFormPolicyControl()) 115 127 ->setName('viewPolicy')
+135 -16
src/applications/phortune/controller/PhortuneMerchantViewController.php
··· 35 35 ->setUser($viewer) 36 36 ->setPolicyObject($merchant); 37 37 38 - $properties = $this->buildPropertyListView($merchant); 38 + $providers = id(new PhortunePaymentProviderConfigQuery()) 39 + ->setViewer($viewer) 40 + ->withMerchantPHIDs(array($merchant->getPHID())) 41 + ->execute(); 42 + 43 + $properties = $this->buildPropertyListView($merchant, $providers); 39 44 $actions = $this->buildActionListView($merchant); 40 45 $properties->setActionList($actions); 41 46 42 - $providers = $this->buildProviderList($merchant); 47 + $provider_list = $this->buildProviderList( 48 + $merchant, 49 + $providers); 43 50 44 51 $box = id(new PHUIObjectBoxView()) 45 52 ->setHeader($header) ··· 59 66 array( 60 67 $crumbs, 61 68 $box, 62 - $providers, 69 + $provider_list, 63 70 $timeline, 64 71 ), 65 72 array( ··· 67 74 )); 68 75 } 69 76 70 - private function buildPropertyListView(PhortuneMerchant $merchant) { 77 + private function buildPropertyListView( 78 + PhortuneMerchant $merchant, 79 + array $providers) { 80 + 71 81 $viewer = $this->getRequest()->getUser(); 72 82 73 83 $view = id(new PHUIPropertyListView()) 74 84 ->setUser($viewer) 75 85 ->setObject($merchant); 76 86 87 + $status_view = new PHUIStatusListView(); 88 + 89 + $have_any = false; 90 + $any_test = false; 91 + foreach ($providers as $provider_config) { 92 + $provider = $provider_config->buildProvider(); 93 + if ($provider->isEnabled()) { 94 + $have_any = true; 95 + } 96 + if (!$provider->isAcceptingLivePayments()) { 97 + $any_test = true; 98 + } 99 + } 100 + 101 + if ($have_any) { 102 + $status_view->addItem( 103 + id(new PHUIStatusItemView()) 104 + ->setIcon(PHUIStatusItemView::ICON_ACCEPT, 'green') 105 + ->setTarget(pht('Accepts Payments')) 106 + ->setNote(pht('This merchant can accept payments.'))); 107 + 108 + if ($any_test) { 109 + $status_view->addItem( 110 + id(new PHUIStatusItemView()) 111 + ->setIcon(PHUIStatusItemView::ICON_WARNING, 'yellow') 112 + ->setTarget(pht('Test Mode')) 113 + ->setNote(pht('This merchant is accepting test payments.'))); 114 + } else { 115 + $status_view->addItem( 116 + id(new PHUIStatusItemView()) 117 + ->setIcon(PHUIStatusItemView::ICON_ACCEPT, 'green') 118 + ->setTarget(pht('Live Mode')) 119 + ->setNote(pht('This merchant is accepting live payments.'))); 120 + } 121 + } else if ($providers) { 122 + $status_view->addItem( 123 + id(new PHUIStatusItemView()) 124 + ->setIcon(PHUIStatusItemView::ICON_REJECT, 'red') 125 + ->setTarget(pht('No Enabled Providers')) 126 + ->setNote( 127 + pht( 128 + 'All of the payment providers for this merchant are '. 129 + 'disabled.'))); 130 + } else { 131 + $status_view->addItem( 132 + id(new PHUIStatusItemView()) 133 + ->setIcon(PHUIStatusItemView::ICON_WARNING, 'yellow') 134 + ->setTarget(pht('No Providers')) 135 + ->setNote( 136 + pht( 137 + 'This merchant does not have any payment providers configured '. 138 + 'yet, so it can not accept payments. Add a provider.'))); 139 + } 140 + 141 + $view->addProperty(pht('Status'), $status_view); 142 + 143 + $view->invokeWillRenderEvent(); 144 + 145 + $description = $merchant->getDescription(); 146 + if (strlen($description)) { 147 + $description = PhabricatorMarkupEngine::renderOneObject( 148 + id(new PhabricatorMarkupOneOff())->setContent($description), 149 + 'default', 150 + $viewer); 151 + 152 + $view->addSectionHeader(pht('Description')); 153 + $view->addTextContent($description); 154 + } 155 + 77 156 return $view; 78 157 } 79 158 ··· 101 180 return $view; 102 181 } 103 182 104 - private function buildProviderList(PhortuneMerchant $merchant) { 183 + private function buildProviderList( 184 + PhortuneMerchant $merchant, 185 + array $providers) { 186 + 105 187 $viewer = $this->getRequest()->getUser(); 106 188 $id = $merchant->getID(); 107 189 ··· 113 195 $provider_list = id(new PHUIObjectItemListView()) 114 196 ->setNoDataString(pht('This merchant has no payment providers.')); 115 197 116 - $providers = id(new PhortunePaymentProviderConfigQuery()) 117 - ->setViewer($viewer) 118 - ->withMerchantPHIDs(array($merchant->getPHID())) 119 - ->execute(); 120 198 foreach ($providers as $provider_config) { 121 199 $provider = $provider_config->buildProvider(); 122 200 $provider_id = $provider_config->getID(); 123 201 124 202 $item = id(new PHUIObjectItemView()) 125 - ->setObjectName(pht('Provider %d', $provider_id)) 126 203 ->setHeader($provider->getName()); 127 204 128 - $item->addAction( 129 - id(new PHUIListItemView()) 130 - ->setIcon('fa-pencil') 131 - ->setHref($this->getApplicationURI("/provider/edit/{$provider_id}")) 132 - ->setWorkflow(!$can_edit) 133 - ->setDisabled(!$can_edit)); 205 + if ($provider->isEnabled()) { 206 + if ($provider->isAcceptingLivePayments()) { 207 + $item->setBarColor('green'); 208 + } else { 209 + $item->setBarColor('yellow'); 210 + $item->addIcon('fa-exclamation-triangle', pht('Test Mode')); 211 + } 212 + 213 + $item->addAttribute($provider->getConfigureProvidesDescription()); 214 + } else { 215 + // Don't show disabled providers to users who can't manage the merchant 216 + // account. 217 + if (!$can_edit) { 218 + continue; 219 + } 220 + $item->setDisabled(true); 221 + $item->addAttribute( 222 + phutil_tag('em', array(), pht('This payment provider is disabled.'))); 223 + } 224 + 225 + 226 + if ($can_edit) { 227 + $edit_uri = $this->getApplicationURI( 228 + "/provider/edit/{$provider_id}/"); 229 + $disable_uri = $this->getApplicationURI( 230 + "/provider/disable/{$provider_id}/"); 231 + 232 + if ($provider->isEnabled()) { 233 + $disable_icon = 'fa-times'; 234 + $disable_name = pht('Disable'); 235 + } else { 236 + $disable_icon = 'fa-check'; 237 + $disable_name = pht('Enable'); 238 + } 239 + 240 + $item->addAction( 241 + id(new PHUIListItemView()) 242 + ->setIcon($disable_icon) 243 + ->setHref($disable_uri) 244 + ->setName($disable_name) 245 + ->setWorkflow(true)); 246 + 247 + $item->addAction( 248 + id(new PHUIListItemView()) 249 + ->setIcon('fa-pencil') 250 + ->setHref($edit_uri) 251 + ->setName(pht('Edit'))); 252 + } 134 253 135 254 $provider_list->addItem($item); 136 255 }
+76
src/applications/phortune/controller/PhortuneProviderDisableController.php
··· 1 + <?php 2 + 3 + final class PhortuneProviderDisableController 4 + extends PhortuneMerchantController { 5 + 6 + private $id; 7 + 8 + public function willProcessRequest(array $data) { 9 + $this->id = $data['id']; 10 + } 11 + 12 + public function processRequest() { 13 + $request = $this->getRequest(); 14 + $viewer = $request->getUser(); 15 + 16 + $provider_config = id(new PhortunePaymentProviderConfigQuery()) 17 + ->setViewer($viewer) 18 + ->withIDs(array($this->id)) 19 + ->requireCapabilities( 20 + array( 21 + PhabricatorPolicyCapability::CAN_VIEW, 22 + PhabricatorPolicyCapability::CAN_EDIT, 23 + )) 24 + ->executeOne(); 25 + if (!$provider_config) { 26 + return new Aphront404Response(); 27 + } 28 + 29 + $merchant = $provider_config->getMerchant(); 30 + $merchant_id = $merchant->getID(); 31 + $cancel_uri = $this->getApplicationURI("merchant/{$merchant_id}/"); 32 + 33 + $provider = $provider_config->buildProvider(); 34 + 35 + if ($request->isFormPost()) { 36 + $new_status = !$provider_config->getIsEnabled(); 37 + 38 + $xactions = array(); 39 + $xactions[] = id(new PhortunePaymentProviderConfigTransaction()) 40 + ->setTransactionType( 41 + PhortunePaymentProviderConfigTransaction::TYPE_ENABLE) 42 + ->setNewValue($new_status); 43 + 44 + $editor = id(new PhortunePaymentProviderConfigEditor()) 45 + ->setActor($viewer) 46 + ->setContentSourceFromRequest($request) 47 + ->setContinueOnNoEffect(true) 48 + ->setContinueOnMissingFields(true); 49 + 50 + $editor->applyTransactions($provider_config, $xactions); 51 + 52 + return id(new AphrontRedirectResponse())->setURI($cancel_uri); 53 + } 54 + 55 + if ($provider_config->getIsEnabled()) { 56 + $title = pht('Disable Provider?'); 57 + $body = pht( 58 + 'If you disable this payment provider, users will no longer be able '. 59 + 'to use it to make new payments.'); 60 + $button = pht('Disable Provider'); 61 + } else { 62 + $title = pht('Enable Provider?'); 63 + $body = pht( 64 + 'If you enable this payment provider, users will be able to use it to '. 65 + 'make new payments.'); 66 + $button = pht('Enable Provider'); 67 + } 68 + 69 + return $this->newDialog() 70 + ->setTitle($title) 71 + ->appendParagraph($body) 72 + ->addSubmitButton($button) 73 + ->addCancelButton($cancel_uri); 74 + } 75 + 76 + }
+8
src/applications/phortune/editor/PhortuneMerchantEditor.php
··· 15 15 $types = parent::getTransactionTypes(); 16 16 17 17 $types[] = PhortuneMerchantTransaction::TYPE_NAME; 18 + $types[] = PhortuneMerchantTransaction::TYPE_DESCRIPTION; 18 19 $types[] = PhabricatorTransactions::TYPE_VIEW_POLICY; 19 20 $types[] = PhabricatorTransactions::TYPE_EDIT_POLICY; 20 21 ··· 27 28 switch ($xaction->getTransactionType()) { 28 29 case PhortuneMerchantTransaction::TYPE_NAME: 29 30 return $object->getName(); 31 + case PhortuneMerchantTransaction::TYPE_DESCRIPTION: 32 + return $object->getDescription(); 30 33 } 31 34 32 35 return parent::getCustomTransactionOldValue($object, $xaction); ··· 38 41 39 42 switch ($xaction->getTransactionType()) { 40 43 case PhortuneMerchantTransaction::TYPE_NAME: 44 + case PhortuneMerchantTransaction::TYPE_DESCRIPTION: 41 45 return $xaction->getNewValue(); 42 46 } 43 47 ··· 52 56 case PhortuneMerchantTransaction::TYPE_NAME: 53 57 $object->setName($xaction->getNewValue()); 54 58 return; 59 + case PhortuneMerchantTransaction::TYPE_DESCRIPTION: 60 + $object->setDescription($xaction->getNewValue()); 61 + return; 55 62 } 56 63 57 64 return parent::applyCustomInternalTransaction($object, $xaction); ··· 63 70 64 71 switch ($xaction->getTransactionType()) { 65 72 case PhortuneMerchantTransaction::TYPE_NAME: 73 + case PhortuneMerchantTransaction::TYPE_DESCRIPTION: 66 74 return; 67 75 } 68 76
+8
src/applications/phortune/editor/PhortunePaymentProviderConfigEditor.php
··· 16 16 17 17 $types[] = PhortunePaymentProviderConfigTransaction::TYPE_CREATE; 18 18 $types[] = PhortunePaymentProviderConfigTransaction::TYPE_PROPERTY; 19 + $types[] = PhortunePaymentProviderConfigTransaction::TYPE_ENABLE; 19 20 20 21 return $types; 21 22 } ··· 26 27 switch ($xaction->getTransactionType()) { 27 28 case PhortunePaymentProviderConfigTransaction::TYPE_CREATE: 28 29 return null; 30 + case PhortunePaymentProviderConfigTransaction::TYPE_ENABLE: 31 + return (int)$object->getIsEnabled(); 29 32 case PhortunePaymentProviderConfigTransaction::TYPE_PROPERTY: 30 33 $property_key = $xaction->getMetadataValue( 31 34 PhortunePaymentProviderConfigTransaction::PROPERTY_KEY); ··· 43 46 case PhortunePaymentProviderConfigTransaction::TYPE_CREATE: 44 47 case PhortunePaymentProviderConfigTransaction::TYPE_PROPERTY: 45 48 return $xaction->getNewValue(); 49 + case PhortunePaymentProviderConfigTransaction::TYPE_ENABLE: 50 + return (int)$xaction->getNewValue(); 46 51 } 47 52 48 53 return parent::getCustomTransactionNewValue($object, $xaction); ··· 60 65 PhortunePaymentProviderConfigTransaction::PROPERTY_KEY); 61 66 $object->setMetadataValue($property_key, $xaction->getNewValue()); 62 67 return; 68 + case PhortunePaymentProviderConfigTransaction::TYPE_ENABLE: 69 + return $object->setIsEnabled((int)$xaction->getNewValue()); 63 70 } 64 71 65 72 return parent::applyCustomInternalTransaction($object, $xaction); ··· 72 79 switch ($xaction->getTransactionType()) { 73 80 case PhortunePaymentProviderConfigTransaction::TYPE_CREATE: 74 81 case PhortunePaymentProviderConfigTransaction::TYPE_PROPERTY: 82 + case PhortunePaymentProviderConfigTransaction::TYPE_ENABLE: 75 83 return; 76 84 } 77 85
+7 -3
src/applications/phortune/provider/PhortuneBalancedPaymentProvider.php
··· 5 5 const BALANCED_MARKETPLACE_ID = 'balanced.marketplace-id'; 6 6 const BALANCED_SECRET_KEY = 'balanced.secret-key'; 7 7 8 - public function isEnabled() { 9 - return $this->getMarketplaceURI() && 10 - $this->getSecretKey(); 8 + public function isAcceptingLivePayments() { 9 + return !preg_match('/-test-/', $this->getSecretKey()); 11 10 } 12 11 13 12 public function getName() { ··· 22 21 return pht( 23 22 'Allows you to accept credit or debit card payments with a '. 24 23 'balancedpayments.com account.'); 24 + } 25 + 26 + public function getConfigureProvidesDescription() { 27 + return pht( 28 + 'This merchant accepts credit and debit cards via Balanced Payments.'); 25 29 } 26 30 27 31 public function getConfigureInstructions() {
+10 -5
src/applications/phortune/provider/PhortunePayPalPaymentProvider.php
··· 10 10 public function isEnabled() { 11 11 // TODO: See note in processControllerRequest(). 12 12 return false; 13 + } 13 14 14 - return $this->getPaypalAPIUsername() && 15 - $this->getPaypalAPIPassword() && 16 - $this->getPaypalAPISignature(); 15 + public function isAcceptingLivePayments() { 16 + $mode = $this->getProviderConfig()->getMetadataValue(self::PAYPAL_MODE); 17 + return ($mode === 'live'); 17 18 } 18 19 19 20 public function getName() { ··· 28 29 return pht( 29 30 'Allows you to accept various payment instruments with a paypal.com '. 30 31 'account.'); 32 + } 33 + 34 + public function getConfigureProvidesDescription() { 35 + return pht( 36 + 'This merchant accepts payments via PayPal.'); 31 37 } 32 38 33 39 public function getConfigureInstructions() { ··· 339 345 } 340 346 341 347 private function newPaypalAPICall() { 342 - $mode = $this->getProviderConfig()->getMetadataValue(self::PAYPAL_MODE); 343 - if ($mode == 'live') { 348 + if ($this->isAcceptingLivePayments()) { 344 349 $host = 'https://api-3t.paypal.com/nvp'; 345 350 } else { 346 351 $host = 'https://api-3t.sandbox.paypal.com/nvp';
+6 -1
src/applications/phortune/provider/PhortunePaymentProvider.php
··· 41 41 42 42 abstract public function getConfigureInstructions(); 43 43 44 + abstract public function getConfigureProvidesDescription(); 45 + 44 46 abstract public function getAllConfigurableProperties(); 45 47 46 48 abstract public function getAllConfigurableSecretProperties(); ··· 120 122 ->loadObjects(); 121 123 } 122 124 123 - abstract public function isEnabled(); 125 + public function isEnabled() { 126 + return $this->getProviderConfig()->getIsEnabled(); 127 + } 124 128 129 + abstract public function isAcceptingLivePayments(); 125 130 abstract public function getPaymentMethodDescription(); 126 131 abstract public function getPaymentMethodIcon(); 127 132 abstract public function getPaymentMethodProviderDescription();
+7 -3
src/applications/phortune/provider/PhortuneStripePaymentProvider.php
··· 5 5 const STRIPE_PUBLISHABLE_KEY = 'stripe.publishable-key'; 6 6 const STRIPE_SECRET_KEY = 'stripe.secret-key'; 7 7 8 - public function isEnabled() { 9 - return $this->getPublishableKey() && 10 - $this->getSecretKey(); 8 + public function isAcceptingLivePayments() { 9 + return preg_match('/_live_/', $this->getPublishableKey()); 11 10 } 12 11 13 12 public function getName() { ··· 22 21 return pht( 23 22 'Allows you to accept credit or debit card payments with a '. 24 23 'stripe.com account.'); 24 + } 25 + 26 + public function getConfigureProvidesDescription() { 27 + return pht( 28 + 'This merchant accepts credit and debit cards via Stripe.'); 25 29 } 26 30 27 31 public function getPaymentMethodDescription() {
+6 -2
src/applications/phortune/provider/PhortuneTestPaymentProvider.php
··· 2 2 3 3 final class PhortuneTestPaymentProvider extends PhortunePaymentProvider { 4 4 5 - public function isEnabled() { 6 - return PhabricatorEnv::getEnvConfig('phortune.test.enabled'); 5 + public function isAcceptingLivePayments() { 6 + return false; 7 7 } 8 8 9 9 public function getName() { ··· 19 19 'Adds a test provider to allow you to test payments. This allows '. 20 20 'users to make purchases by clicking a button without actually paying '. 21 21 'any money.'); 22 + } 23 + 24 + public function getConfigureProvidesDescription() { 25 + return pht('This merchant accepts test payments.'); 22 26 } 23 27 24 28 public function getConfigureInstructions() {
+6 -5
src/applications/phortune/provider/PhortuneWePayPaymentProvider.php
··· 7 7 const WEPAY_ACCESS_TOKEN = 'wepay.access-token'; 8 8 const WEPAY_ACCOUNT_ID = 'wepay.account-id'; 9 9 10 - public function isEnabled() { 11 - return $this->getWePayClientID() && 12 - $this->getWePayClientSecret() && 13 - $this->getWePayAccessToken() && 14 - $this->getWePayAccountID(); 10 + public function isAcceptingLivePayments() { 11 + return preg_match('/^PRODUCTION_/', $this->getWePayAccessToken()); 15 12 } 16 13 17 14 public function getName() { ··· 26 23 return pht( 27 24 'Allows you to accept credit or debit card payments with a '. 28 25 'wepay.com account.'); 26 + } 27 + 28 + public function getConfigureProvidesDescription() { 29 + return pht('This merchant accepts credit and debit cards via WePay.'); 29 30 } 30 31 31 32 public function getConfigureInstructions() {
+2
src/applications/phortune/storage/PhortuneMerchant.php
··· 6 6 protected $name; 7 7 protected $viewPolicy; 8 8 protected $editPolicy; 9 + protected $description; 9 10 10 11 public static function initializeNewMerchant(PhabricatorUser $actor) { 11 12 return id(new PhortuneMerchant()) ··· 18 19 self::CONFIG_AUX_PHID => true, 19 20 self::CONFIG_COLUMN_SCHEMA => array( 20 21 'name' => 'text255', 22 + 'description' => 'text', 21 23 ), 22 24 ) + parent::getConfiguration(); 23 25 }
+30
src/applications/phortune/storage/PhortuneMerchantTransaction.php
··· 4 4 extends PhabricatorApplicationTransaction { 5 5 6 6 const TYPE_NAME = 'merchant:name'; 7 + const TYPE_DESCRIPTION = 'merchant:description'; 7 8 8 9 public function getApplicationName() { 9 10 return 'phortune'; ··· 37 38 $new); 38 39 } 39 40 break; 41 + case self::TYPE_DESCRIPTION: 42 + return pht( 43 + '%s updated the description for this merchant.', 44 + $this->renderHandleLink($author_phid)); 40 45 } 41 46 42 47 return parent::getTitle(); 48 + } 49 + 50 + public function shouldHide() { 51 + $old = $this->getOldValue(); 52 + switch ($this->getTransactionType()) { 53 + case self::TYPE_DESCRIPTION: 54 + return ($old === null); 55 + } 56 + return parent::shouldHide(); 57 + } 58 + 59 + public function hasChangeDetails() { 60 + switch ($this->getTransactionType()) { 61 + case self::TYPE_DESCRIPTION: 62 + return ($this->getOldValue() !== null); 63 + } 64 + 65 + return parent::hasChangeDetails(); 66 + } 67 + 68 + public function renderChangeDetails(PhabricatorUser $viewer) { 69 + return $this->renderTextCorpusChangeDetails( 70 + $viewer, 71 + $this->getOldValue(), 72 + $this->getNewValue()); 43 73 } 44 74 45 75 }
+4 -1
src/applications/phortune/storage/PhortunePaymentProviderConfig.php
··· 6 6 protected $merchantPHID; 7 7 protected $providerClassKey; 8 8 protected $providerClass; 9 + protected $isEnabled; 9 10 protected $metadata = array(); 10 11 11 12 private $merchant = self::ATTACHABLE; ··· 13 14 public static function initializeNewProvider( 14 15 PhortuneMerchant $merchant) { 15 16 return id(new PhortunePaymentProviderConfig()) 16 - ->setMerchantPHID($merchant->getPHID()); 17 + ->setMerchantPHID($merchant->getPHID()) 18 + ->setIsEnabled(1); 17 19 } 18 20 19 21 public function getConfiguration() { ··· 25 27 self::CONFIG_COLUMN_SCHEMA => array( 26 28 'providerClassKey' => 'bytes12', 27 29 'providerClass' => 'text128', 30 + 'isEnabled' => 'bool', 28 31 ), 29 32 self::CONFIG_KEY_SCHEMA => array( 30 33 'key_merchant' => array(
+11
src/applications/phortune/storage/PhortunePaymentProviderConfigTransaction.php
··· 5 5 6 6 const TYPE_CREATE = 'paymentprovider:create'; 7 7 const TYPE_PROPERTY = 'paymentprovider:property'; 8 + const TYPE_ENABLE = 'paymentprovider:enable'; 8 9 9 10 const PROPERTY_KEY = 'provider-property'; 10 11 ··· 31 32 return pht( 32 33 '%s created this payment provider.', 33 34 $this->renderHandleLink($author_phid)); 35 + case self::TYPE_ENABLE: 36 + if ($new) { 37 + return pht( 38 + '%s enabled this payment provider.', 39 + $this->renderHandleLink($author_phid)); 40 + } else { 41 + return pht( 42 + '%s disabled this payment provider.', 43 + $this->renderHandleLink($author_phid)); 44 + } 34 45 case self::TYPE_PROPERTY: 35 46 // TODO: Allow providers to improve this. 36 47