3 final class PhortuneAccountPaymentMethodController
4 extends PhortuneAccountProfileController
{
6 protected function shouldRequireAccountEditCapability() {
10 protected function handleAccountRequest(AphrontRequest
$request) {
11 $account = $this->getAccount();
12 $title = $account->getName();
14 $crumbs = $this->buildApplicationCrumbs()
15 ->addTextCrumb(pht('Payment Methods'))
18 $authority = $this->newAccountAuthorityView();
19 $header = $this->buildHeaderView();
20 $methods = $this->buildPaymentMethodsSection($account);
22 $view = id(new PHUITwoColumnView())
30 $navigation = $this->buildSideNavView('methods');
32 return $this->newPage()
35 ->setNavigation($navigation)
39 private function buildPaymentMethodsSection(PhortuneAccount
$account) {
40 $viewer = $this->getViewer();
42 $can_edit = PhabricatorPolicyFilter
::hasCapability(
45 PhabricatorPolicyCapability
::CAN_EDIT
);
47 $id = $account->getID();
49 $add = id(new PHUIButtonView())
51 ->setText(pht('Add Payment Method'))
53 ->setHref($this->getApplicationURI("account/{$id}/methods/new/"))
54 ->setDisabled(!$can_edit)
55 ->setWorkflow(!$can_edit);
57 $header = id(new PHUIHeaderView())
58 ->setHeader(pht('Payment Methods'))
59 ->addActionLink($add);
61 $list = id(new PHUIObjectItemListView())
65 pht('There are no payment methods associated with this account.'));
67 $methods = id(new PhortunePaymentMethodQuery())
69 ->withAccountPHIDs(array($account->getPHID()))
72 PhortunePaymentMethod
::STATUS_ACTIVE
,
76 foreach ($methods as $method) {
77 $id = $method->getID();
79 $item = id(new PHUIObjectItemView())
80 ->setObjectName($method->getObjectName())
81 ->setHeader($method->getFullDisplayName())
82 ->setHref($method->getURI());
84 $provider = $method->buildPaymentProvider();
85 $item->addAttribute($provider->getPaymentMethodProviderDescription());
87 $list->addItem($item);
90 return id(new PHUIObjectBoxView())
92 ->setBackground(PHUIObjectBoxView
::BLUE_PROPERTY
)
93 ->setObjectList($list);