Changeset View
Changeset View
Standalone View
Standalone View
src/applications/phortune/query/PhortunePaymentMethodQuery.php
Show First 20 Lines • Show All 47 Lines • ▼ Show 20 Lines | $accounts = id(new PhortuneAccountQuery()) | ||||
->withPHIDs(mpull($methods, 'getAccountPHID')) | ->withPHIDs(mpull($methods, 'getAccountPHID')) | ||||
->execute(); | ->execute(); | ||||
$accounts = mpull($accounts, null, 'getPHID'); | $accounts = mpull($accounts, null, 'getPHID'); | ||||
foreach ($methods as $key => $method) { | foreach ($methods as $key => $method) { | ||||
$account = idx($accounts, $method->getAccountPHID()); | $account = idx($accounts, $method->getAccountPHID()); | ||||
if (!$account) { | if (!$account) { | ||||
unset($methods[$key]); | unset($methods[$key]); | ||||
$this->didRejectResult($method); | |||||
continue; | continue; | ||||
} | } | ||||
$method->attachAccount($account); | $method->attachAccount($account); | ||||
} | } | ||||
if (!$methods) { | if (!$methods) { | ||||
return $methods; | return $methods; | ||||
} | } | ||||
$merchants = id(new PhortuneMerchantQuery()) | $merchants = id(new PhortuneMerchantQuery()) | ||||
->setViewer($this->getViewer()) | ->setViewer($this->getViewer()) | ||||
->withPHIDs(mpull($methods, 'getMerchantPHID')) | ->withPHIDs(mpull($methods, 'getMerchantPHID')) | ||||
->execute(); | ->execute(); | ||||
$merchants = mpull($merchants, null, 'getPHID'); | $merchants = mpull($merchants, null, 'getPHID'); | ||||
foreach ($methods as $key => $method) { | foreach ($methods as $key => $method) { | ||||
$merchant = idx($merchants, $method->getMerchantPHID()); | $merchant = idx($merchants, $method->getMerchantPHID()); | ||||
if (!$merchant) { | if (!$merchant) { | ||||
unset($methods[$key]); | unset($methods[$key]); | ||||
$this->didRejectResult($method); | |||||
continue; | continue; | ||||
} | } | ||||
$method->attachMerchant($merchant); | $method->attachMerchant($merchant); | ||||
} | } | ||||
if (!$methods) { | if (!$methods) { | ||||
return $methods; | return $methods; | ||||
} | } | ||||
$provider_configs = id(new PhortunePaymentProviderConfigQuery()) | $provider_configs = id(new PhortunePaymentProviderConfigQuery()) | ||||
->setViewer($this->getViewer()) | ->setViewer($this->getViewer()) | ||||
->withPHIDs(mpull($methods, 'getProviderPHID')) | ->withPHIDs(mpull($methods, 'getProviderPHID')) | ||||
->execute(); | ->execute(); | ||||
$provider_configs = mpull($provider_configs, null, 'getPHID'); | $provider_configs = mpull($provider_configs, null, 'getPHID'); | ||||
foreach ($methods as $key => $method) { | foreach ($methods as $key => $method) { | ||||
$provider_config = idx($provider_configs, $method->getProviderPHID()); | $provider_config = idx($provider_configs, $method->getProviderPHID()); | ||||
if (!$provider_config) { | if (!$provider_config) { | ||||
unset($methods[$key]); | unset($methods[$key]); | ||||
$this->didRejectResult($method); | |||||
continue; | continue; | ||||
} | } | ||||
$method->attachProviderConfig($provider_config); | $method->attachProviderConfig($provider_config); | ||||
} | } | ||||
return $methods; | return $methods; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 46 Lines • Show Last 20 Lines |