当前位置: 首页>>代码示例>>PHP>>正文


PHP Payment::setMethod方法代码示例

本文整理汇总了PHP中Payment::setMethod方法的典型用法代码示例。如果您正苦于以下问题:PHP Payment::setMethod方法的具体用法?PHP Payment::setMethod怎么用?PHP Payment::setMethod使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Payment的用法示例。


在下文中一共展示了Payment::setMethod方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: executeBuy

 public function executeBuy($request)
 {
     $this->user = $this->getUser()->getSubscriber();
     $this->step = 1;
     $this->form = new BuyStep1Form();
     if ($request->isMethod('post') || $request->getParameter('jotag')) {
         // if direct access, stop on step 1
         if (!$request->isMethod('post')) {
             $request->setParameter('step', 1);
         }
         $this->form->bind(array('jotag' => strtolower($request->getParameter('jotag'))));
         if ($this->form->isValid()) {
             // step 1 OK
             $this->jotag_object = $this->form->getValue('jotag_object');
             $this->step = 2;
             if ($this->user->getCredits() || $this->isWebserviceCall()) {
                 if (!$this->user->getCredits()) {
                     // ok, webservice call, but we don't have credits
                     $this->form = null;
                     return sfView::ERROR;
                 }
                 // REDEEM FORK
                 $this->setTemplate('redeem');
                 $this->form = new RedeemStep2Form(array('jotag' => strtolower($this->form->getValue('jotag'))));
                 if ($request->getParameter('step') > 1) {
                     $this->form->bind(array('jotag' => strtolower($request->getParameter('jotag')), 'confirm_jotag' => strtolower($request->getParameter('confirm_jotag'))));
                     if ($this->form->isValid()) {
                         // step 2 OK, here we create new jotag
                         $this->step = 3;
                         if ($this->jotag_object) {
                             $jotag = $this->jotag_object;
                             $ptype = PaymentPeer::PT_RENEW;
                         } else {
                             $jotag = new Tag();
                             $jotag->setJotag(strtolower($this->form->getValue('jotag')));
                             $jotag->setStatus(TagPeer::ST_NEW);
                             $jotag->setUser($this->getUser()->getSubscriber());
                             $jotag->setIsPrimary(false);
                             $ptype = PaymentPeer::PT_NEW;
                         }
                         // mark this jotag as FREE, so we can automatically give credits
                         $jotag->setIsCredit(true);
                         // calculate new expiration date
                         $jotag->setValidUntil($jotag->calcNewDate($this->user->getCredits() * OptionPeer::retrieveOption('BONUS_DAYS_PER_CREDIT'), true));
                         $jotag->setStatus(TagPeer::ST_ACTIVE);
                         // create payment
                         $payment = new Payment();
                         $payment->setTag($jotag);
                         $payment->setMethod(PaymentPeer::PT_CREDITS);
                         $payment->setAmount(0);
                         $payment->setDuration($this->user->getCredits() * OptionPeer::retrieveOption('BONUS_DAYS_PER_CREDIT'));
                         $payment->setCredits($this->user->getCredits());
                         $payment->setUser($this->getUser()->getSubscriber());
                         $payment->setStatus(PaymentPeer::ST_PAID);
                         $payment->setType($ptype);
                         // save
                         $jotag->save();
                         $payment->save();
                         // remove credits from user account
                         $this->user->setCredits(0);
                         $this->user->save();
                         // remove from interest list
                         $this->user->delInterest($jotag->getJotag());
                         $this->payment = $payment;
                         $this->jotag = $jotag;
                         // send receipt to the user
                         Mailer::sendEmail($payment->getUser()->getPrimaryEmail(), 'paymentConfirmation', array('payment' => $payment), $this->getUser()->getSubscriber()->getPreferedLanguage());
                     }
                 }
             } else {
                 // BUY FORK
                 $this->form = new BuyStep2Form(array('jotag' => strtolower($this->form->getValue('jotag'))));
                 if ($request->getParameter('step') > 1) {
                     $this->form->bind(array('jotag' => strtolower($request->getParameter('jotag')), 'confirm_jotag' => strtolower($request->getParameter('confirm_jotag')), 'duration' => $request->getParameter('duration')));
                     if ($this->form->isValid()) {
                         // step 2 OK, create payment
                         $payment = new Payment();
                         if ($this->jotag_object) {
                             $payment->setTag($this->jotag_object);
                             $payment->setType(PaymentPeer::PT_RENEW);
                         } else {
                             $payment->setJotag(strtolower($this->form->getValue('jotag')));
                             $payment->setType(PaymentPeer::PT_NEW);
                         }
                         $payment->setMethod(PaymentPeer::PT_PAYPAL);
                         $payment->setAmount((double) sprintf("%0.2f", $this->form->getValue('duration') * OptionPeer::retrieveOption('BUY_PRICE')));
                         $payment->setDuration($this->form->getValue('duration'));
                         $payment->setUser($this->getUser()->getSubscriber());
                         $payment->setCredits(0);
                         $payment->setStatus(PaymentPeer::ST_NEW);
                         $payment->save();
                         $this->payment = $payment;
                         $this->getUser()->setPaymentId($payment->getId());
                         $this->step = 3;
                         $this->form = new BuyStep3Form(array('jotag' => strtolower($this->form->getValue('jotag')), 'confirm_jotag' => strtolower($this->form->getValue('confirm_jotag')), 'duration' => $this->form->getValue('duration')));
                     }
                 }
             }
         } else {
             if (get_class($this->form["jotag"]->getError()->getValidator()) == "buyJotagValidator") {
//.........这里部分代码省略.........
开发者ID:psskhal,项目名称:symfony-sample,代码行数:101,代码来源:actions.class.php


注:本文中的Payment::setMethod方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。