Correct Aphlict websocket URI construction after PHP8 compatibility changes
[phabricator.git] / src / applications / phortune / controller / cart / PhortuneCartUpdateController.php
blob64b2ab3cfa56ef02134b0b2e49f7740e2a056711
1 <?php
3 final class PhortuneCartUpdateController
4 extends PhortuneCartController {
6 protected function shouldRequireAccountAuthority() {
7 return false;
10 protected function shouldRequireMerchantAuthority() {
11 return false;
14 protected function handleCartRequest(AphrontRequest $request) {
15 $viewer = $request->getViewer();
16 $id = $request->getURIData('id');
18 $cart = $this->getCart();
19 $authority = $this->getMerchantAuthority();
21 $charges = id(new PhortuneChargeQuery())
22 ->setViewer($viewer)
23 ->withCartPHIDs(array($cart->getPHID()))
24 ->needCarts(true)
25 ->withStatuses(
26 array(
27 PhortuneCharge::STATUS_HOLD,
28 PhortuneCharge::STATUS_CHARGED,
30 ->execute();
32 if ($charges) {
33 $providers = id(new PhortunePaymentProviderConfigQuery())
34 ->setViewer($viewer)
35 ->withPHIDs(mpull($charges, 'getProviderPHID'))
36 ->execute();
37 $providers = mpull($providers, null, 'getPHID');
38 } else {
39 $providers = array();
42 foreach ($charges as $charge) {
43 if ($charge->isRefund()) {
44 // Don't update refunds.
45 continue;
48 $provider_config = idx($providers, $charge->getProviderPHID());
49 if (!$provider_config) {
50 throw new Exception(pht('Unable to load provider for charge!'));
53 $provider = $provider_config->buildProvider();
54 $provider->updateCharge($charge);
57 return id(new AphrontRedirectResponse())
58 ->setURI($cart->getDetailURI());