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


PHP Payment::setAmount方法代码示例

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


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

示例1: Payment

 function test_humanized_amount()
 {
     $payment = new Payment(12.35, 'Inscripcio', '29292929');
     $this->assertEqual(12.35, $payment->getHumanizedAmount());
     $payment->setAmount(12);
     $this->assertEqual(12.0, $payment->getHumanizedAmount());
     $payment->setAmount(120);
     $this->assertEqual(120.0, $payment->getHumanizedAmount());
     $payment->setAmount(120.3);
     $this->assertEqual(120.3, $payment->getHumanizedAmount());
     $payment->setAmount(120.21);
     $this->assertEqual(120.21, $payment->getHumanizedAmount());
     $payment->setAmount('12.35');
     $this->assertEqual(12.35, $payment->getHumanizedAmount());
     $payment->setAmount('12');
     $this->assertEqual(12.0, $payment->getHumanizedAmount());
     $payment->setAmount('120');
     $this->assertEqual(120.0, $payment->getHumanizedAmount());
     $payment->setAmount('120.3');
     $this->assertEqual(120.3, $payment->getHumanizedAmount());
     $payment->setAmount('120.21');
     $this->assertEqual(120.21, $payment->getHumanizedAmount());
 }
开发者ID:ritxi,项目名称:sermepa_tpv,代码行数:23,代码来源:payment_test.php

示例2: initializeWithRawData

 /**
  * Initialize the object with raw data
  *
  * @param $data
  * @return Payment
  */
 public static function initializeWithRawData($data)
 {
     $item = new Payment();
     if (isset($data['amount'])) {
         $item->setAmount($data['amount']);
     }
     if (isset($data['paid_at'])) {
         $item->setPaidAt(new \DateTime('@' . strtotime($data['paid_at'])));
     }
     if (isset($data['identifier'])) {
         $item->setIdentifier($data['identifier']);
     }
     return $item;
 }
开发者ID:sumocoders,项目名称:factr,代码行数:20,代码来源:Payment.php

示例3: generatePayments

 protected function generatePayments()
 {
     // Payments
     $date1 = sfDate::getInstance($this->inv->getIssueDate());
     $date2 = sfDate::getInstance($this->inv->getDueDate());
     $total = $this->inv->setAmounts()->getGrossAmount();
     if (mt_rand(1, 10) == 1) {
         $q = mt_rand(1, 5);
         $paid = 0;
         for ($k = 0; $k < $q && $paid < $total; $k++) {
             $payment = new Payment();
             $payment_date = sfDate::getInstance($date2->get() - mt_rand(1, $date2->diff($date1)));
             $payment->setDate($payment_date->format('Y-m-d'));
             $payment->setNotes($this->items[array_rand($this->items)]);
             $rest = $total - $paid;
             $sum = round($rest * (0.25 * mt_rand(1, 3)), 2);
             $paid += $sum;
             $payment->setAmount($sum);
             $this->inv->Payments[] = $payment;
         }
     } else {
         $payment = new Payment();
         $payment_date = sfDate::getInstance($date2->get() - mt_rand(1, $date2->diff($date1)));
         $payment->setDate($payment_date->format('Y-m-d'));
         $payment->setNotes($this->items[array_rand($this->items)]);
         $payment->setAmount($total);
         $this->inv->Payments[] = $payment;
     }
 }
开发者ID:solutema,项目名称:siwapp-sf1,代码行数:29,代码来源:RandomDataLoadTask.class.php

示例4: dirname

<?php

include dirname(__FILE__) . '/../../bootstrap/Doctrine.php';
include dirname(__FILE__) . '/../../testTools.php';
$t = new lime_test(2, new lime_output_color());
PropertyTable::set('currency_decimals', 3);
$p = new Payment();
$p->setAmount(2.1215);
$t->is($p->getAmount(), 2.122, 'rounds amount to 3 decimals');
PropertyTable::set('currency_decimals', 2);
$p->setAmount(2.123);
$t->is($p->getAmount(), 2.12, 'rounds amount to 2 decimals');
开发者ID:solutema,项目名称:siwapp-sf1,代码行数:12,代码来源:PaymentTest.php

示例5: array

$serviceRequestDetails = $serviceRequest->getServiceRequest(array("service_no" => "DESC"), array("service_no" => array($serviceRequestId, Equal)));
$serviceRequestDetails = $serviceRequestDetails[0];
$payment = new Payment();
$payments = $payment->getPayments(array("payment_no" => "DESC"), array("service_no" => array($serviceRequestId, Equal)));
$totalPayments = 0;
foreach ($payments as $payment) {
    $totalPayments += $payment->getAmount();
}
if ($isPaypal && isset($_REQUEST["PaypalSubmit"])) {
    $paypal = new Paypal($_POST);
    if ($result = $paypal->DoPayment()) {
        $packageAmount = $serviceRequestDetails->getPackageDetails()[0]->getPrice();
        $paymenstatus = $totalPayments + $result["amount"] >= $packageAmount ? "complete" : "partial";
        $payment->setOr_id($result["transactionID"]);
        $payment->setMode("paypal");
        $payment->setAmount($result["amount"]);
        $payment->setService_no($serviceRequestId);
        $payment->setStat($paymenstatus);
        $payment->save();
        header("Location:ViewPayments.php?id=" . $serviceRequestId);
    } else {
        header("Location:" . $_SERVER["PHP_SELF"] . "?message=Failed");
    }
} elseif ($isBank && isset($_REQUEST["BankSubmit"])) {
    $packageAmount = $serviceRequestDetails->getPackageDetails()[0]->getPrice();
    $paymenstatus = $totalPayments + $result["amount"] >= $packageAmount ? "complete" : "partial";
    $payment->setOr_id($_POST["depositCode"]);
    $payment->setMode("bank");
    $payment->setAmount($_POST["depositAmount"]);
    $payment->setService_no($serviceRequestId);
    $payment->setStat($paymenstatus);
开发者ID:bongdelarosa,项目名称:cateringsystem-bong,代码行数:31,代码来源:CreatePayment.php

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