@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Implement refunds for Balanced in Phortune

Summary: Ref T2787. Does refunds for Balanced.

Test Plan: {F215205}

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T2787

Differential Revision: https://secure.phabricator.com/D10665

+31 -2
+31 -2
src/applications/phortune/provider/PhortuneBalancedPaymentProvider.php
··· 182 182 protected function executeRefund( 183 183 PhortuneCharge $charge, 184 184 PhortuneCharge $refund) { 185 - // TODO: Implement. 186 - throw new PhortuneNotImplementedException($this); 185 + 186 + $root = dirname(phutil_get_library_root('phabricator')); 187 + require_once $root.'/externals/httpful/bootstrap.php'; 188 + require_once $root.'/externals/restful/bootstrap.php'; 189 + require_once $root.'/externals/balanced-php/bootstrap.php'; 190 + 191 + $debit_uri = $charge->getMetadataValue('balanced.debitURI'); 192 + if (!$debit_uri) { 193 + throw new Exception(pht('No Balanced debit URI!')); 194 + } 195 + 196 + $refund_cents = $refund 197 + ->getAmountAsCurrency() 198 + ->negate() 199 + ->getValueInUSDCents(); 200 + 201 + $params = array( 202 + 'amount' => $refund_cents, 203 + ); 204 + 205 + try { 206 + Balanced\Settings::$api_key = $this->getSecretKey(); 207 + $balanced_debit = Balanced\Debit::get($debit_uri); 208 + $balanced_refund = $balanced_debit->refunds->create($params); 209 + } catch (RESTful\Exceptions\HTTPError $error) { 210 + throw new Exception($error->response->body->description); 211 + } 212 + 213 + $refund->setMetadataValue('balanced.refundURI', $balanced_refund->uri); 214 + $refund->save(); 187 215 } 188 216 189 217 private function getMarketplaceID() { ··· 217 245 218 246 /** 219 247 * @phutil-external-symbol class Balanced\Card 248 + * @phutil-external-symbol class Balanced\Debit 220 249 * @phutil-external-symbol class Balanced\Settings 221 250 * @phutil-external-symbol class Balanced\Marketplace 222 251 * @phutil-external-symbol class Balanced\APIKey