Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15394005
D19020.id45589.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
D19020.id45589.diff
View Options
diff --git a/src/applications/phortune/query/PhortunePaymentMethodQuery.php b/src/applications/phortune/query/PhortunePaymentMethodQuery.php
--- a/src/applications/phortune/query/PhortunePaymentMethodQuery.php
+++ b/src/applications/phortune/query/PhortunePaymentMethodQuery.php
@@ -34,19 +34,12 @@
return $this;
}
+ public function newResultObject() {
+ return new PhortunePaymentMethod();
+ }
+
protected function loadPage() {
- $table = new PhortunePaymentMethod();
- $conn = $table->establishConnection('r');
-
- $rows = queryfx_all(
- $conn,
- 'SELECT * FROM %T %Q %Q %Q',
- $table->getTableName(),
- $this->buildWhereClause($conn),
- $this->buildOrderClause($conn),
- $this->buildLimitClause($conn));
-
- return $table->loadAllFromArray($rows);
+ return $this->loadStandardPage($this->newResultObject());
}
protected function willFilterPage(array $methods) {
@@ -106,8 +99,8 @@
return $methods;
}
- protected function buildWhereClause(AphrontDatabaseConnection $conn) {
- $where = array();
+ protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) {
+ $where = parent::buildWhereClauseParts($conn);
if ($this->ids !== null) {
$where[] = qsprintf(
@@ -144,9 +137,7 @@
$this->statuses);
}
- $where[] = $this->buildPagingClause($conn);
-
- return $this->formatWhereClause($where);
+ return $where;
}
public function getQueryApplicationClass() {
diff --git a/src/applications/phortune/storage/PhortuneCart.php b/src/applications/phortune/storage/PhortuneCart.php
--- a/src/applications/phortune/storage/PhortuneCart.php
+++ b/src/applications/phortune/storage/PhortuneCart.php
@@ -118,6 +118,13 @@
->setAmountAsCurrency($this->getTotalPriceAsCurrency());
if ($method) {
+ if (!$method->isActive()) {
+ throw new Exception(
+ pht(
+ 'Attempting to apply a charge using an inactive '.
+ 'payment method ("%s")!',
+ $method->getPHID()));
+ }
$charge->setPaymentMethodPHID($method->getPHID());
}
diff --git a/src/applications/phortune/storage/PhortunePaymentMethod.php b/src/applications/phortune/storage/PhortunePaymentMethod.php
--- a/src/applications/phortune/storage/PhortunePaymentMethod.php
+++ b/src/applications/phortune/storage/PhortunePaymentMethod.php
@@ -128,6 +128,10 @@
return $month.'/'.$year;
}
+ public function isActive() {
+ return ($this->getStatus() === self::STATUS_ACTIVE);
+ }
+
/* -( PhabricatorPolicyInterface )----------------------------------------- */
diff --git a/src/applications/phortune/worker/PhortuneSubscriptionWorker.php b/src/applications/phortune/worker/PhortuneSubscriptionWorker.php
--- a/src/applications/phortune/worker/PhortuneSubscriptionWorker.php
+++ b/src/applications/phortune/worker/PhortuneSubscriptionWorker.php
@@ -141,6 +141,10 @@
$method = id(new PhortunePaymentMethodQuery())
->setViewer($viewer)
->withPHIDs(array($subscription->getDefaultPaymentMethodPHID()))
+ ->withStatuses(
+ array(
+ PhortunePaymentMethod::STATUS_ACTIVE,
+ ))
->executeOne();
if (!$method) {
$issues[] = pht(
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Mar 16, 11:18 PM (4 d, 23 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7655645
Default Alt Text
D19020.id45589.diff (3 KB)
Attached To
Mode
D19020: Fix a Phortune billing issue where subscription autopay could charge disabled cards
Attached
Detach File
Event Timeline
Log In to Comment