Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F114442476
PhortuneProviderDisableController.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sun, May 25, 22:28
Size
2 KB
Mime Type
text/x-php
Expires
Tue, May 27, 22:28 (2 d)
Engine
blob
Format
Raw Data
Handle
26401781
Attached To
rPH Phabricator
PhortuneProviderDisableController.php
View Options
<?php
final
class
PhortuneProviderDisableController
extends
PhortuneMerchantController
{
public
function
handleRequest
(
AphrontRequest
$request
)
{
$viewer
=
$request
->
getViewer
();
$id
=
$request
->
getURIData
(
'id'
);
$provider_config
=
id
(
new
PhortunePaymentProviderConfigQuery
())
->
setViewer
(
$viewer
)
->
withIDs
(
array
(
$id
))
->
requireCapabilities
(
array
(
PhabricatorPolicyCapability
::
CAN_VIEW
,
PhabricatorPolicyCapability
::
CAN_EDIT
,
))
->
executeOne
();
if
(!
$provider_config
)
{
return
new
Aphront404Response
();
}
$merchant
=
$provider_config
->
getMerchant
();
$merchant_id
=
$merchant
->
getID
();
$cancel_uri
=
$this
->
getApplicationURI
(
"merchant/{$merchant_id}/"
);
$provider
=
$provider_config
->
buildProvider
();
if
(
$request
->
isFormPost
())
{
$new_status
=
!
$provider_config
->
getIsEnabled
();
$xactions
=
array
();
$xactions
[]
=
id
(
new
PhortunePaymentProviderConfigTransaction
())
->
setTransactionType
(
PhortunePaymentProviderConfigTransaction
::
TYPE_ENABLE
)
->
setNewValue
(
$new_status
);
$editor
=
id
(
new
PhortunePaymentProviderConfigEditor
())
->
setActor
(
$viewer
)
->
setContentSourceFromRequest
(
$request
)
->
setContinueOnNoEffect
(
true
)
->
setContinueOnMissingFields
(
true
);
$editor
->
applyTransactions
(
$provider_config
,
$xactions
);
return
id
(
new
AphrontRedirectResponse
())->
setURI
(
$cancel_uri
);
}
if
(
$provider_config
->
getIsEnabled
())
{
$title
=
pht
(
'Disable Provider?'
);
$body
=
pht
(
'If you disable this payment provider, users will no longer be able '
.
'to use it to make new payments.'
);
$button
=
pht
(
'Disable Provider'
);
}
else
{
$title
=
pht
(
'Enable Provider?'
);
$body
=
pht
(
'If you enable this payment provider, users will be able to use it to '
.
'make new payments.'
);
$button
=
pht
(
'Enable Provider'
);
}
return
$this
->
newDialog
()
->
setTitle
(
$title
)
->
appendParagraph
(
$body
)
->
addSubmitButton
(
$button
)
->
addCancelButton
(
$cancel_uri
);
}
}
Event Timeline
Log In to Comment