public function didRefundProduct(PhortuneProduct $product, PhortunePurchase $purchase, PhortuneCurrency $amount) { $viewer = $this->getViewer(); $backer = id(new FundBackerQuery())->setViewer($viewer)->withPHIDs(array($purchase->getMetadataValue('backerPHID')))->executeOne(); if (!$backer) { throw new Exception(pht('Unable to load %s!', 'FundBacker')); } $xactions = array(); $xactions[] = id(new FundInitiativeTransaction())->setTransactionType(FundInitiativeTransaction::TYPE_REFUND)->setMetadataValue(FundInitiativeTransaction::PROPERTY_AMOUNT, $amount->serializeForStorage())->setMetadataValue(FundInitiativeTransaction::PROPERTY_BACKER, $backer->getBackerPHID())->setNewValue($backer->getPHID()); $editor = id(new FundInitiativeEditor())->setActor($viewer)->setContentSource($this->getContentSource()); $editor->applyTransactions($this->getInitiative(), $xactions); }