@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.

Provide a purchase detail view in Phortune

Summary: Ref T2787. This provides a purchase detail screen (which has nothing useful on it yet) and converts a bunch of PHIDs into slightly more useful links.

Test Plan: Browsed around my account.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T2787

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

+162 -10
+2
src/__phutil_library_map__.php
··· 2507 2507 'PhortuneProviderController' => 'applications/phortune/controller/PhortuneProviderController.php', 2508 2508 'PhortunePurchase' => 'applications/phortune/storage/PhortunePurchase.php', 2509 2509 'PhortunePurchaseQuery' => 'applications/phortune/query/PhortunePurchaseQuery.php', 2510 + 'PhortunePurchaseViewController' => 'applications/phortune/controller/PhortunePurchaseViewController.php', 2510 2511 'PhortuneStripePaymentProvider' => 'applications/phortune/provider/PhortuneStripePaymentProvider.php', 2511 2512 'PhortuneTestExtraPaymentProvider' => 'applications/phortune/provider/__tests__/PhortuneTestExtraPaymentProvider.php', 2512 2513 'PhortuneTestPaymentProvider' => 'applications/phortune/provider/PhortuneTestPaymentProvider.php', ··· 5433 5434 'PhabricatorPolicyInterface', 5434 5435 ), 5435 5436 'PhortunePurchaseQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 5437 + 'PhortunePurchaseViewController' => 'PhortuneController', 5436 5438 'PhortuneStripePaymentProvider' => 'PhortunePaymentProvider', 5437 5439 'PhortuneTestExtraPaymentProvider' => 'PhortunePaymentProvider', 5438 5440 'PhortuneTestPaymentProvider' => 'PhortunePaymentProvider',
+3
src/applications/phortune/application/PhabricatorPhortuneApplication.php
··· 58 58 'view/(?P<id>\d+)/' => 'PhortuneProductViewController', 59 59 'edit/(?:(?P<id>\d+)/)?' => 'PhortuneProductEditController', 60 60 ), 61 + 'purchase/(?P<id>\d+)/' => array( 62 + '' => 'PhortunePurchaseViewController', 63 + ), 61 64 'provider/(?P<digest>[^/]+)/(?P<action>[^/]+)/' 62 65 => 'PhortuneProviderController', 63 66 ),
+19 -2
src/applications/phortune/controller/PhortuneAccountViewController.php
··· 173 173 $rows = array(); 174 174 $rowc = array(); 175 175 foreach ($carts as $cart) { 176 + $cart_link = phutil_tag( 177 + 'a', 178 + array( 179 + 'href' => $this->getApplicationURI('cart/'.$cart->getID().'/'), 180 + ), 181 + pht('Cart %d', $cart->getID())); 182 + 176 183 $rowc[] = 'highlighted'; 177 184 $rows[] = array( 178 - $cart->getPHID(), 185 + phutil_tag('strong', array(), $cart_link), 179 186 '', 180 187 '', 181 188 ); 182 189 foreach ($cart->getPurchases() as $purchase) { 190 + $id = $purchase->getID(); 191 + 183 192 $price = $purchase->getTotalPriceInCents(); 184 193 $price = PhortuneCurrency::newFromUSDCents($price)->formatForDisplay(); 185 194 195 + $purchase_link = phutil_tag( 196 + 'a', 197 + array( 198 + 'href' => $this->getApplicationURI('purchase/'.$id.'/'), 199 + ), 200 + $purchase->getFullDisplayName()); 201 + 186 202 $rowc[] = ''; 187 203 $rows[] = array( 188 204 '', 189 - $purchase->getPHID(), 205 + $purchase_link, 190 206 $price, 191 207 ); 192 208 } ··· 222 238 $charges = id(new PhortuneChargeQuery()) 223 239 ->setViewer($viewer) 224 240 ->withAccountPHIDs(array($account->getPHID())) 241 + ->needCarts(true) 225 242 ->execute(); 226 243 227 244 return $this->buildChargesTable($charges);
+1 -1
src/applications/phortune/controller/PhortuneCartCheckoutController.php
··· 98 98 foreach ($methods as $method) { 99 99 $method_control->addButton( 100 100 $method->getID(), 101 - $method->getBrand().' / '.$method->getLastFourDigits(), 101 + $method->getFullDisplayName(), 102 102 $method->getDescription()); 103 103 } 104 104 }
+1 -1
src/applications/phortune/controller/PhortuneCartController.php
··· 9 9 $total = 0; 10 10 foreach ($cart->getPurchases() as $purchase) { 11 11 $rows[] = array( 12 - pht('A Purchase'), 12 + $purchase->getFullDisplayName(), 13 13 PhortuneCurrency::newFromUSDCents($purchase->getBasePriceInCents()) 14 14 ->formatForDisplay(), 15 15 $purchase->getQuantity(),
+4 -2
src/applications/phortune/controller/PhortuneCartViewController.php
··· 27 27 $charges = id(new PhortuneChargeQuery()) 28 28 ->setViewer($viewer) 29 29 ->withCartPHIDs(array($cart->getPHID())) 30 + ->needCarts(true) 30 31 ->execute(); 31 32 32 - $charges_table = $this->buildChargesTable($charges); 33 + $charges_table = $this->buildChargesTable($charges, false); 33 34 34 35 $account = $cart->getAccount(); 35 36 36 37 $crumbs = $this->buildApplicationCrumbs(); 37 - $crumbs->addTextCrumb(pht('Cart')); 38 + $this->addAccountCrumb($crumbs, $cart->getAccount()); 39 + $crumbs->addTextCrumb(pht('Cart %d', $cart->getID())); 38 40 39 41 return $this->buildApplicationPage( 40 42 array(
+35 -4
src/applications/phortune/controller/PhortuneController.php
··· 52 52 return $account; 53 53 } 54 54 55 - protected function buildChargesTable(array $charges) { 55 + protected function buildChargesTable(array $charges, $show_cart = true) { 56 56 $request = $this->getRequest(); 57 57 $viewer = $request->getUser(); 58 58 59 59 $rows = array(); 60 60 foreach ($charges as $charge) { 61 + $cart = $charge->getCart(); 62 + $cart_id = $cart->getID(); 63 + $cart_uri = $this->getApplicationURI("cart/{$cart_id}/"); 64 + $cart_href = phutil_tag( 65 + 'a', 66 + array( 67 + 'href' => $cart_uri, 68 + ), 69 + pht('Cart %d', $cart_id)); 70 + 61 71 $rows[] = array( 62 72 $charge->getID(), 63 - $charge->getCartPHID(), 73 + $cart_href, 64 74 $charge->getPaymentProviderKey(), 65 75 $charge->getPaymentMethodPHID(), 66 76 PhortuneCurrency::newFromUSDCents($charge->getAmountInCents()) ··· 73 83 $charge_table = id(new AphrontTableView($rows)) 74 84 ->setHeaders( 75 85 array( 76 - pht('Charge ID'), 86 + pht('ID'), 77 87 pht('Cart'), 78 88 pht('Provider'), 79 89 pht('Method'), ··· 84 94 ->setColumnClasses( 85 95 array( 86 96 '', 87 - '', 97 + 'strong', 88 98 '', 89 99 '', 90 100 'wide right', 91 101 '', 92 102 '', 103 + )) 104 + ->setColumnVisibility( 105 + array( 106 + true, 107 + $show_cart, 93 108 )); 94 109 95 110 $header = id(new PHUIHeaderView()) ··· 98 113 return id(new PHUIObjectBoxView()) 99 114 ->setHeader($header) 100 115 ->appendChild($charge_table); 116 + } 117 + 118 + protected function addAccountCrumb( 119 + $crumbs, 120 + PhortuneAccount $account, 121 + $link = true) { 122 + 123 + $name = pht('Account'); 124 + $href = null; 125 + 126 + if ($link) { 127 + $href = $this->getApplicationURI($account->getID().'/'); 128 + $crumbs->addTextCrumb($name, $href); 129 + } else { 130 + $crumbs->addTextCrumb($name); 131 + } 101 132 } 102 133 103 134 }
+58
src/applications/phortune/controller/PhortunePurchaseViewController.php
··· 1 + <?php 2 + 3 + final class PhortunePurchaseViewController extends PhortuneController { 4 + 5 + private $purchaseID; 6 + 7 + public function willProcessRequest(array $data) { 8 + $this->purchaseID = $data['id']; 9 + } 10 + 11 + public function processRequest() { 12 + $request = $this->getRequest(); 13 + $viewer = $request->getUser(); 14 + 15 + $account = $this->loadActiveAccount($viewer); 16 + 17 + $purchase = id(new PhortunePurchaseQuery()) 18 + ->setViewer($viewer) 19 + ->withIDs(array($this->purchaseID)) 20 + ->executeOne(); 21 + if (!$purchase) { 22 + return new Aphront404Response(); 23 + } 24 + $cart = $purchase->getCart(); 25 + 26 + $title = pht('Purchase: %s', $purchase->getFullDisplayName()); 27 + 28 + $header = id(new PHUIHeaderView()) 29 + ->setHeader($purchase->getFullDisplayName()); 30 + 31 + $crumbs = $this->buildApplicationCrumbs(); 32 + $this->addAccountCrumb($crumbs, $account); 33 + $crumbs->addTextCrumb( 34 + pht('Cart %d', $cart->getID()), 35 + $this->getApplicationURI('cart/'.$cart->getID().'/')); 36 + $crumbs->addTextCrumb( 37 + pht('Purchase %d', $purchase->getID()), 38 + $this->getApplicationURI('purchase/'.$purchase->getID().'/')); 39 + 40 + $properties = id(new PHUIPropertyListView()) 41 + ->setUser($viewer) 42 + ->addProperty(pht('Status'), $purchase->getStatus()); 43 + 44 + $object_box = id(new PHUIObjectBoxView()) 45 + ->setHeader($header) 46 + ->addPropertyList($properties); 47 + 48 + return $this->buildApplicationPage( 49 + array( 50 + $crumbs, 51 + $object_box, 52 + ), 53 + array( 54 + 'title' => $title, 55 + )); 56 + } 57 + 58 + }
+25
src/applications/phortune/query/PhortuneChargeQuery.php
··· 8 8 private $accountPHIDs; 9 9 private $cartPHIDs; 10 10 11 + private $needCarts; 12 + 11 13 public function withIDs(array $ids) { 12 14 $this->ids = $ids; 13 15 return $this; ··· 25 27 26 28 public function withCartPHIDs(array $cart_phids) { 27 29 $this->cartPHIDs = $cart_phids; 30 + return $this; 31 + } 32 + 33 + public function needCarts($need_carts) { 34 + $this->needCarts = $need_carts; 28 35 return $this; 29 36 } 30 37 ··· 58 65 continue; 59 66 } 60 67 $charge->attachAccount($account); 68 + } 69 + 70 + return $charges; 71 + } 72 + 73 + protected function didFilterPage(array $charges) { 74 + if ($this->needCarts) { 75 + $carts = id(new PhortuneCartQuery()) 76 + ->setViewer($this->getViewer()) 77 + ->setParentQuery($this) 78 + ->withPHIDs(mpull($charges, 'getCartPHID')) 79 + ->execute(); 80 + $carts = mpull($carts, null, 'getPHID'); 81 + 82 + foreach ($charges as $charge) { 83 + $cart = idx($carts, $charge->getCartPHID()); 84 + $charge->attachCart($cart); 85 + } 61 86 } 62 87 63 88 return $charges;
+10
src/applications/phortune/storage/PhortuneCharge.php
··· 25 25 protected $metadata = array(); 26 26 27 27 private $account = self::ATTACHABLE; 28 + private $cart = self::ATTACHABLE; 28 29 29 30 public function getConfiguration() { 30 31 return array( ··· 60 61 61 62 public function attachAccount(PhortuneAccount $account) { 62 63 $this->account = $account; 64 + return $this; 65 + } 66 + 67 + public function getCart() { 68 + return $this->assertAttached($this->cart); 69 + } 70 + 71 + public function attachCart(PhortuneCart $cart = null) { 72 + $this->cart = $cart; 63 73 return $this; 64 74 } 65 75
+4
src/applications/phortune/storage/PhortunePurchase.php
··· 54 54 $this->totalPriceInCents = (int)$this->totalPriceInCents; 55 55 } 56 56 57 + public function getFullDisplayName() { 58 + return pht('Goods and/or Services'); 59 + } 60 + 57 61 58 62 /* -( PhabricatorPolicyInterface )----------------------------------------- */ 59 63