mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-26 16:52:41 +01:00
Allow subscriptions to cost amounts other than one dollar and twenty three cents
Summary: Ref T6881. Sometimes, goods and services cost arbitrary amounts. Test Plan: See next diff. Reviewers: btrahan Reviewed By: btrahan Subscribers: epriestley Maniphest Tasks: T6881 Differential Revision: https://secure.phabricator.com/D11594
This commit is contained in:
parent
07d640d2b6
commit
93e6a9b3ca
4 changed files with 15 additions and 3 deletions
|
@ -43,6 +43,7 @@ final class PhortuneSubscriptionProduct
|
|||
}
|
||||
|
||||
public function getPriceAsCurrency(PhortuneProduct $product) {
|
||||
// Prices are calculated by the SubscriptionImplementation.
|
||||
return PhortuneCurrency::newEmptyCurrency();
|
||||
}
|
||||
|
||||
|
|
|
@ -183,6 +183,13 @@ final class PhortuneSubscription extends PhortuneDAO
|
|||
return "/phortune/merchant/{$merchant_id}/subscription/view/{$id}/";
|
||||
}
|
||||
|
||||
public function getCostForBillingPeriodAsCurrency($start_epoch, $end_epoch) {
|
||||
return $this->getImplementation()->getCostForBillingPeriodAsCurrency(
|
||||
$this,
|
||||
$start_epoch,
|
||||
$end_epoch);
|
||||
}
|
||||
|
||||
|
||||
/* -( PhabricatorPolicyInterface )----------------------------------------- */
|
||||
|
||||
|
|
|
@ -8,6 +8,10 @@ abstract class PhortuneSubscriptionImplementation {
|
|||
|
||||
abstract public function getRef();
|
||||
abstract public function getName(PhortuneSubscription $subscription);
|
||||
abstract public function getCostForBillingPeriodAsCurrency(
|
||||
PhortuneSubscription $subscription,
|
||||
$start_epoch,
|
||||
$end_epoch);
|
||||
|
||||
protected function getContentSource() {
|
||||
return PhabricatorContentSource::newForSource(
|
||||
|
|
|
@ -42,9 +42,9 @@ final class PhortuneSubscriptionWorker extends PhabricatorWorker {
|
|||
|
||||
$purchase = $cart->newPurchase($actor, $product);
|
||||
|
||||
// TODO: Consider allowing subscriptions to cost an amount other than one
|
||||
// dollar and twenty-three cents.
|
||||
$currency = PhortuneCurrency::newFromUserInput($actor, '1.23 USD');
|
||||
$currency = $subscription->getCostForBillingPeriodAsCurrency(
|
||||
$last_epoch,
|
||||
$next_epoch);
|
||||
|
||||
$purchase
|
||||
->setBasePriceAsCurrency($currency)
|
||||
|
|
Loading…
Reference in a new issue