3 final class PhortuneSubscriptionProduct
4 extends PhortuneProductImplementation
{
7 private $subscriptionPHID;
10 public function setSubscriptionPHID($subscription_phid) {
11 $this->subscriptionPHID
= $subscription_phid;
15 public function getSubscriptionPHID() {
16 return $this->subscriptionPHID
;
19 public function setSubscription(PhortuneSubscription
$subscription) {
20 $this->subscription
= $subscription;
24 public function getSubscription() {
25 return $this->subscription
;
28 public function setViewer(PhabricatorUser
$viewer) {
29 $this->viewer
= $viewer;
33 public function getViewer() {
37 public function getRef() {
38 return $this->getSubscriptionPHID();
41 public function getName(PhortuneProduct
$product) {
42 return $this->getSubscription()->getSubscriptionName();
45 public function getPriceAsCurrency(PhortuneProduct
$product) {
46 // Prices are calculated by the SubscriptionImplementation.
47 return PhortuneCurrency
::newEmptyCurrency();
50 public function didPurchaseProduct(
51 PhortuneProduct
$product,
52 PhortunePurchase
$purchase) {
53 return $this->getSubscription()->didPurchaseProduct(
58 public function didRefundProduct(
59 PhortuneProduct
$product,
60 PhortunePurchase
$purchase,
61 PhortuneCurrency
$amount) {
62 // TODO: Callback the subscription.
66 public function getPurchaseName(
67 PhortuneProduct
$product,
68 PhortunePurchase
$purchase) {
69 return $this->getSubscription()->getPurchaseName(
74 public function getPurchaseURI(
75 PhortuneProduct
$product,
76 PhortunePurchase
$purchase) {
77 return $this->getSubscription()->getPurchaseURI(
82 public function loadImplementationsForRefs(
83 PhabricatorUser
$viewer,
86 $subscriptions = id(new PhortuneSubscriptionQuery())
90 $subscriptions = mpull($subscriptions, null, 'getPHID');
93 foreach ($refs as $ref) {
94 $subscription = idx($subscriptions, $ref);
99 $objects[] = id(new PhortuneSubscriptionProduct())
101 ->setSubscriptionPHID($ref)
102 ->setSubscription($subscription);