<?php if (!defined('VB_ENTRY')) die('Access denied.'); class vB_Library_Paidsubscription extends vB_Library { protected $subobj = null; protected function __construct() { parent::__construct(); require_once(DIR . '/includes/class_paid_subscription.php'); $this->subobj = new vB_PaidSubscription(); $this->subobj->cache_user_subscriptions(); } public function getSubObject() : vB_PaidSubscription { return $this->subobj; } public function getSpecificSubcriptionObject($subscriptionid) { $sub = $this->subobj->subscriptioncache[$subscriptionid] ?? null; if (is_null($sub)) { throw new vB_Exception_Api('payment_api_error'); } $sub['newoptions'] = @unserialize($sub['newoptions'], ['allowed_classes' => false]); return $sub; } public function convertArrayToPaidsubscriptionEntity( $vbsubscriptionid, $vbsubscription_subid, $timeAndCosts, $currency, $userid = 0, $vbhash = '' ) : vB_Entity_Paidsubscription { $actualCost = $timeAndCosts[$vbsubscription_subid]['cost'][$currency] ?? null; if (is_null($actualCost)) { throw new vB_Exception_Api('invalid_currency'); } $vbsubscriptioninfo = vB_Entity_Paidsubscription::createFromArray([ 'cost' => $actualCost, 'currency' => $currency, 'recurring' => $timeAndCosts[$vbsubscription_subid]['recurring'], 'duration' => $timeAndCosts[$vbsubscription_subid]['length'], 'duration_units' => $timeAndCosts[$vbsubscription_subid]['units'], 'subscriptionid' => $vbsubscriptionid, 'subscriptionsubid' => $vbsubscription_subid, 'userid' => $userid, 'vbhash' => $vbhash, ]); return $vbsubscriptioninfo; } } 