Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14018705
D10665.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
D10665.diff
View Options
diff --git a/src/applications/phortune/provider/PhortuneBalancedPaymentProvider.php b/src/applications/phortune/provider/PhortuneBalancedPaymentProvider.php
--- a/src/applications/phortune/provider/PhortuneBalancedPaymentProvider.php
+++ b/src/applications/phortune/provider/PhortuneBalancedPaymentProvider.php
@@ -182,8 +182,36 @@
protected function executeRefund(
PhortuneCharge $charge,
PhortuneCharge $refund) {
- // TODO: Implement.
- throw new PhortuneNotImplementedException($this);
+
+ $root = dirname(phutil_get_library_root('phabricator'));
+ require_once $root.'/externals/httpful/bootstrap.php';
+ require_once $root.'/externals/restful/bootstrap.php';
+ require_once $root.'/externals/balanced-php/bootstrap.php';
+
+ $debit_uri = $charge->getMetadataValue('balanced.debitURI');
+ if (!$debit_uri) {
+ throw new Exception(pht('No Balanced debit URI!'));
+ }
+
+ $refund_cents = $refund
+ ->getAmountAsCurrency()
+ ->negate()
+ ->getValueInUSDCents();
+
+ $params = array(
+ 'amount' => $refund_cents,
+ );
+
+ try {
+ Balanced\Settings::$api_key = $this->getSecretKey();
+ $balanced_debit = Balanced\Debit::get($debit_uri);
+ $balanced_refund = $balanced_debit->refunds->create($params);
+ } catch (RESTful\Exceptions\HTTPError $error) {
+ throw new Exception($error->response->body->description);
+ }
+
+ $refund->setMetadataValue('balanced.refundURI', $balanced_refund->uri);
+ $refund->save();
}
private function getMarketplaceID() {
@@ -217,6 +245,7 @@
/**
* @phutil-external-symbol class Balanced\Card
+ * @phutil-external-symbol class Balanced\Debit
* @phutil-external-symbol class Balanced\Settings
* @phutil-external-symbol class Balanced\Marketplace
* @phutil-external-symbol class Balanced\APIKey
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Nov 6, 6:45 PM (1 w, 5 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6717070
Default Alt Text
D10665.diff (1 KB)
Attached To
Mode
D10665: Implement refunds for Balanced in Phortune
Attached
Detach File
Event Timeline
Log In to Comment