mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-29 02:02:41 +01:00
aa67a5ffc8
Summary: Ref T2787. Shows somewhat-useful information, allows payment methods to be disabled and renamed. Test Plan: Created, renamed, disabled payment methods. Reviewers: btrahan Reviewed By: btrahan Subscribers: epriestley Maniphest Tasks: T2787 Differential Revision: https://secure.phabricator.com/D10203
64 lines
1.7 KiB
PHP
64 lines
1.7 KiB
PHP
<?php
|
|
|
|
final class PhortunePaymentMethodDisableController
|
|
extends PhortuneController {
|
|
|
|
private $methodID;
|
|
|
|
public function willProcessRequest(array $data) {
|
|
$this->methodID = $data['id'];
|
|
}
|
|
|
|
public function processRequest() {
|
|
$request = $this->getRequest();
|
|
$viewer = $request->getUser();
|
|
|
|
$method = id(new PhortunePaymentMethodQuery())
|
|
->setViewer($viewer)
|
|
->withIDs(array($this->methodID))
|
|
->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('Disable Payment Method?'))
|
|
->setShortTitle(pht('Disable Payment Method'))
|
|
->appendParagraph(
|
|
pht(
|
|
'Disable the payment method "%s"?',
|
|
phutil_tag(
|
|
'strong',
|
|
array(),
|
|
$method->getFullDisplayName())))
|
|
->appendParagraph(
|
|
pht(
|
|
'You will no longer be able to make payments using this payment '.
|
|
'method. Disabled payment methods can not be reactivated.'))
|
|
->addCancelButton($account_uri)
|
|
->addSubmitButton(pht('Disable Payment Method'));
|
|
}
|
|
|
|
}
|