本文整理匯總了PHP中Plan::isTrial方法的典型用法代碼示例。如果您正苦於以下問題:PHP Plan::isTrial方法的具體用法?PHP Plan::isTrial怎麽用?PHP Plan::isTrial使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Plan
的用法示例。
在下文中一共展示了Plan::isTrial方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: transaction
public function transaction($userId, $planId)
{
$user = new User($userId);
$plan = new Plan($planId);
$request = $this->getRequest()->request;
$planPeriodId = $request->get('plan_period');
$planPeriod = new Plans_period($planPeriodId);
$systemId = $request->get('system');
$system = new Payment_gateways($systemId);
$interval = new DateInterval('P' . $planPeriod->period . ucwords($planPeriod->qualifier));
/* @var Core\Service\Subscriber\Subscriber $subscriber */
$subscriber = $this->get('core.subscriber');
$subscriber->setUser($user);
if (!($planPeriod->price == 0 && $plan->isTrial())) {
$transactionManager = $this->get('core.payment.transactions.manager');
$transaction = $transactionManager->createForSubscription(array('amount' => $planPeriod->price, 'description' => 'subscribe on ' . $plan->name), $user, $system);
} else {
$subscriber->addTrialSubscription($plan, $interval);
if (!$this->ion_auth->logged_in()) {
$this->ion_auth->loginForce($user->email, true);
}
redirect('dashboard');
}
$subscriber->addNewSubscription($transaction, $plan, $interval);
if (!$this->ion_auth->logged_in()) {
$this->ion_auth->loginForce($user->email, true);
}
redirect('payment/pay/' . $transaction->id . '/' . $planPeriodId);
}