Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F103311688
PhortuneCartUpdateController.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
Sat, Mar 1, 02:14
Size
1 KB
Mime Type
text/x-php
Expires
Mon, Mar 3, 02:14 (2 d)
Engine
blob
Format
Raw Data
Handle
24539700
Attached To
rPH Phabricator
PhortuneCartUpdateController.php
View Options
<?php
final
class
PhortuneCartUpdateController
extends
PhortuneCartController
{
private
$id
;
public
function
willProcessRequest
(
array
$data
)
{
$this
->
id
=
$data
[
'id'
];
}
public
function
processRequest
()
{
$request
=
$this
->
getRequest
();
$viewer
=
$request
->
getUser
();
$authority
=
$this
->
loadMerchantAuthority
();
$cart_query
=
id
(
new
PhortuneCartQuery
())
->
setViewer
(
$viewer
)
->
withIDs
(
array
(
$this
->
id
))
->
needPurchases
(
true
);
if
(
$authority
)
{
$cart_query
->
withMerchantPHIDs
(
array
(
$authority
->
getPHID
()));
}
$cart
=
$cart_query
->
executeOne
();
if
(!
$cart
)
{
return
new
Aphront404Response
();
}
$charges
=
id
(
new
PhortuneChargeQuery
())
->
setViewer
(
$viewer
)
->
withCartPHIDs
(
array
(
$cart
->
getPHID
()))
->
needCarts
(
true
)
->
withStatuses
(
array
(
PhortuneCharge
::
STATUS_HOLD
,
PhortuneCharge
::
STATUS_CHARGED
,
))
->
execute
();
if
(
$charges
)
{
$providers
=
id
(
new
PhortunePaymentProviderConfigQuery
())
->
setViewer
(
$viewer
)
->
withPHIDs
(
mpull
(
$charges
,
'getProviderPHID'
))
->
execute
();
$providers
=
mpull
(
$providers
,
null
,
'getPHID'
);
}
else
{
$providers
=
array
();
}
foreach
(
$charges
as
$charge
)
{
if
(
$charge
->
isRefund
())
{
// Don't update refunds.
continue
;
}
$provider_config
=
idx
(
$providers
,
$charge
->
getProviderPHID
());
if
(!
$provider_config
)
{
throw
new
Exception
(
pht
(
'Unable to load provider for charge!'
));
}
$provider
=
$provider_config
->
buildProvider
();
$provider
->
updateCharge
(
$charge
);
}
return
id
(
new
AphrontRedirectResponse
())
->
setURI
(
$cart
->
getDetailURI
(
$authority
));
}
}
Event Timeline
Log In to Comment