forked from phacility/phabricator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPhortunePaymentMethodDisableController.php
57 lines (47 loc) · 1.55 KB
/
PhortunePaymentMethodDisableController.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<?php
final class PhortunePaymentMethodDisableController
extends PhortuneController {
public function handleRequest(AphrontRequest $request) {
$viewer = $request->getViewer();
$method_id = $request->getURIData('id');
$method = id(new PhortunePaymentMethodQuery())
->setViewer($viewer)
->withIDs(array($method_id))
->requireCapabilities(
array(
PhabricatorPolicyCapability::CAN_VIEW,
PhabricatorPolicyCapability::CAN_EDIT,
))
->executeOne();
if (!$method) {
return new Aphront404Response();
}
if ($method->getStatus() == PhortunePaymentMethod::STATUS_DISABLED) {
return new Aphront400Response();
}
$account = $method->getAccount();
$account_uri = $this->getApplicationURI($account->getID().'/');
if ($request->isFormPost()) {
// TODO: ApplicationTransactions!
$method
->setStatus(PhortunePaymentMethod::STATUS_DISABLED)
->save();
return id(new AphrontRedirectResponse())->setURI($account_uri);
}
return $this->newDialog()
->setTitle(pht('Remove Payment Method'))
->appendParagraph(
pht(
'Remove the payment method "%s" from your account?',
phutil_tag(
'strong',
array(),
$method->getFullDisplayName())))
->appendParagraph(
pht(
'You will no longer be able to make payments using this payment '.
'method.'))
->addCancelButton($account_uri)
->addSubmitButton(pht('Remove Payment Method'));
}
}