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


PHP Varien_Object::setAmount方法代码示例

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


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

示例1: getInstallmentsAvailables

 public function getInstallmentsAvailables()
 {
     $maxInstallments = (int) Mage::getStoreConfig('payment/pagarme_cc/max_installments');
     $minInstallmentValue = (double) Mage::getStoreConfig('payment/pagarme_cc/min_installment_value');
     $interestRate = (double) Mage::getStoreConfig('payment/pagarme_cc/interest_rate');
     $freeInstallments = (int) Mage::getStoreConfig('payment/pagarme_cc/free_installments');
     if ($minInstallmentValue < self::MIN_INSTALLMENT_VALUE) {
         $minInstallmentValue = self::MIN_INSTALLMENT_VALUE;
     }
     $quote = Mage::helper('checkout')->getQuote();
     $total = $quote->getGrandTotal();
     $n = floor($total / $minInstallmentValue);
     if ($n > $maxInstallments) {
         $n = $maxInstallments;
     } elseif ($n < 1) {
         $n = 1;
     }
     $data = new Varien_Object();
     $data->setAmount(Mage::helper('pagarme')->formatAmount($total))->setInterestRate($interestRate)->setMaxInstallments($n)->setFreeInstallments($freeInstallments);
     $response = Mage::getModel('pagarme/api')->calculateInstallmentsAmount($data);
     $collection = $response->getInstallments();
     $installments = array();
     foreach ($collection as $item) {
         if ($item->getInstallment() == 1) {
             $label = $this->__('Pay in full - %s', $quote->getStore()->formatPrice($item->getInstallmentAmount() / 100, false));
         } else {
             $label = $this->__('%sx - %s', $item->getInstallment(), $quote->getStore()->formatPrice($item->getInstallmentAmount() / 100, false)) . ' ';
             $label .= $item->getInstallment() > $freeInstallments ? $this->__('monthly interest rate (%s)', $interestRate . '%') : $this->__('interest-free');
         }
         $installments[$item->getInstallment()] = $label;
     }
     return $installments;
 }
开发者ID:hiuryanderson,项目名称:pagarme-magento,代码行数:33,代码来源:Cc.php

示例2: order

 public function order(Varien_Object $payment, $amount)
 {
     $order = $payment->getOrder();
     $order_id = $order->getId();
     $order_increment_id = $order->getIncrementId();
     $store_id = $order->getStoreId();
     $ccType = $payment->getCcType();
     // reorder
     $reorder_increment_id = explode('-', $order_increment_id);
     // reorder
     $order_increment_id = $reorder_increment_id[0];
     $order_suffix_id = @$reorder_increment_id[1];
     $expiration = strtotime('+' . $this->_getStoreConfig($ccType, 'expiration') . 'days');
     $transaction_expiration = date('Y-m-d', $expiration);
     $increment = $this->_getStoreConfig('slips', 'order_id_increment');
     $order_increment_prefix = $this->_getOrderIncrementPrefix($store_id);
     $number = $order_increment_id - $order_increment_prefix;
     if (!empty($order_suffix_id)) {
         $number *= pow(10, strlen($order_suffix_id));
         $number += $order_suffix_id;
     }
     $number += $increment;
     $data = array('order_id' => $order_id, 'amount' => $amount, 'expiration' => $transaction_expiration, 'number' => $number);
     $result = Mage::getModel('utils/sql')->insert('gamuza_slips_transactions', $data);
     if (!$result) {
         Mage::throwException(Mage::helper('slips')->__('Unable to save the Slip and Deposit informations. Please verify your database.'));
     }
     $this->setStore($payment->getOrder()->getStoreId());
     $payment->setAmount($amount);
     $payment->setLastTransId($order_id);
     $payment->setStatus(self::STATUS_APPROVED);
     return $this;
 }
开发者ID:Hospeed,项目名称:gamuza_slips-magento,代码行数:33,代码来源:Standard.php

示例3: authorize

 public function authorize(Varien_Object $payment, $amount)
 {
     $error = false;
     if ($amount > 0) {
         $payment->setTrxtype(self::TRXTYPE_AUTH_ONLY);
         $payment->setAmount($amount);
         $request = $this->_buildRequest($payment);
         $result = $this->_postRequest($request);
         $payment->setCcTransId($result->getPnref());
         switch ($result->getResultCode()) {
             case self::RESPONSE_CODE_APPROVED:
                 $payment->setStatus(self::STATUS_APPROVED);
                 break;
             case self::RESPONSE_CODE_FRAUDSERVICE_FILTER:
                 $payment->setFraudFlag(true);
                 break;
             default:
                 if ($result->getRespmsg()) {
                     $error = $result->getRespmsg();
                 } else {
                     $error = Mage::helper('paygate')->__('Error in authorizing the payment');
                 }
                 break;
         }
     } else {
         $error = Mage::helper('paygate')->__('Invalid amount for authorization');
     }
     if ($error !== false) {
         Mage::throwException($error);
     }
     return $this;
 }
开发者ID:HelioFreitas,项目名称:magento-pt_br,代码行数:32,代码来源:Pro.php

示例4: _prepareGiftVoucher

 protected function _prepareGiftVoucher(Varien_Object $buyRequest, $product)
 {
     $store = Mage::app()->getStore();
     if ($store->isAdmin()) {
         $amount = $product->getPrice();
     } else {
         if ($buyRequest->getAmount()) {
             $amount = $buyRequest->getAmount();
             $includeTax = Mage::getStoreConfig('tax/display/type') != 1;
             $amount = $amount * 100 / Mage::helper('tax')->getPrice($product, 100, $includeTax);
         } else {
             $amount = $product->getPrice();
         }
         if (!$amount) {
             return Mage::helper('giftvoucher')->__('Please enter gift voucher information');
         }
     }
     if (!$buyRequest->getAmount()) {
         $buyRequest->setAmount($amount);
     }
     $product->addCustomOption('amount', $amount);
     $fields = array();
     foreach (Mage::helper('giftvoucher')->getFullGiftVoucherOptions() as $key => $label) {
         if ($value = $buyRequest->getData($key)) {
             $product->addCustomOption($key, $value);
         }
     }
     return array($product);
 }
开发者ID:CherylMuniz,项目名称:fashion,代码行数:29,代码来源:Type.php

示例5: collect

 public function collect(Mage_Sales_Model_Quote_Address $address)
 {
     parent::collect($address);
     // $this->_setAmount (0);
     // $this->_setBaseAmount (0);
     $items = $this->_getAddressItems($address);
     if (!count($items)) {
         return $this;
     }
     $quote = Mage::helper('pagarme')->_getQuote();
     $payment = $quote->getPayment()->getMethod();
     if (!strcmp($payment, 'pagarme_cc') || !strcmp($payment, 'pagarme_checkout')) {
         $maxInstallments = (int) Mage::getStoreConfig('payment/pagarme_cc/max_installments');
         $minInstallmentValue = (double) Mage::getStoreConfig('payment/pagarme_cc/min_installment_value');
         $interestRate = (double) Mage::getStoreConfig('payment/pagarme_cc/interest_rate');
         $freeInstallments = (int) Mage::getStoreConfig('payment/pagarme_cc/free_installments');
         $total = Mage::helper('pagarme')->getBaseSubtotalWithDiscount() + Mage::helper('pagarme')->getBaseShippingAmount();
         $n = floor($total / $minInstallmentValue);
         if ($n > $maxInstallments) {
             $n = $maxInstallments;
         } elseif ($n < 1) {
             $n = 1;
         }
         $data = new Varien_Object();
         $data->setAmount(Mage::helper('pagarme')->formatAmount($total))->setInterestRate($interestRate)->setMaxInstallments($n)->setFreeInstallments($freeInstallments);
         $post = Mage::app()->getRequest()->getPost();
         $payment_installment = 0;
         if (isset($post['payment']['installments'])) {
             $payment_installment = $post['payment']['installments'];
         } else {
             if (isset($post['payment']['pagarme_checkout_installments'])) {
                 $payment_installment = $post['payment']['pagarme_checkout_installments'];
             }
         }
         $installments = Mage::getModel('pagarme/api')->calculateInstallmentsAmount($data);
         $collection = $installments->getInstallments();
         foreach ($collection as $item) {
             if ($item->getInstallment() == $payment_installment) {
                 $famount = intval($item->getInstallmentAmount()) / 100;
                 $iqty = intval($item->getInstallment());
                 $balance = $famount * $iqty - $total;
                 if ($balance < 0) {
                     break;
                 }
                 // The 1 cent problem
                 $address->setFeeAmount($balance);
                 $address->setBaseFeeAmount($balance);
                 $quote->setFeeAmount($balance);
                 $address->setGrandTotal($address->getGrandTotal() + $address->getFeeAmount());
                 $address->setBaseGrandTotal($address->getBaseGrandTotal() + $address->getBaseFeeAmount());
                 break;
             }
         }
     }
     return $this;
 }
开发者ID:eneiasramos,项目名称:pagarme-magento,代码行数:56,代码来源:Fee.php

示例6: getInstallmentsAvailables

 public function getInstallmentsAvailables()
 {
     $plans = Mage::getModel('pagarme/config')->_getPlans();
     if (count($plans) > 0) {
         $allow_multiples = Mage::getStoreConfigFlag('payment/pagarme_subscriptions/allow_multiples');
         if (count($plans) > 1 && !$allow_multiples) {
             $this->_redirectToCart();
             return;
         }
         $_plan = reset($plans);
         // first plan
         $planId = key($plans);
         $_plan = Mage::getModel('pagarme/plans')->load($planId);
         $_planName = $_plan->getName();
         $maxInstallments = $_plan->getInstallments();
     } else {
         $maxInstallments = (int) Mage::getStoreConfig('payment/pagarme_cc/max_installments');
     }
     $minInstallmentValue = (double) Mage::getStoreConfig('payment/pagarme_cc/min_installment_value');
     $interestRate = (double) Mage::getStoreConfig('payment/pagarme_cc/interest_rate');
     $freeInstallments = (int) Mage::getStoreConfig('payment/pagarme_cc/free_installments');
     if ($minInstallmentValue < self::MIN_INSTALLMENT_VALUE) {
         $minInstallmentValue = self::MIN_INSTALLMENT_VALUE;
     }
     $quote = Mage::helper('pagarme')->_getQuote();
     $total = Mage::helper('pagarme')->getBaseSubtotalWithDiscount() + Mage::helper('pagarme')->getBaseShippingAmount();
     $n = floor($total / $minInstallmentValue);
     if ($n > $maxInstallments) {
         $n = $maxInstallments;
     } elseif ($n < 1) {
         $n = 1;
     }
     $data = new Varien_Object();
     $data->setAmount(Mage::helper('pagarme')->formatAmount($total))->setInterestRate($interestRate)->setMaxInstallments($n)->setFreeInstallments($freeInstallments);
     $response = Mage::getModel('pagarme/api')->calculateInstallmentsAmount($data);
     $collection = $response->getInstallments();
     $installments = array();
     foreach ($collection as $item) {
         if ($item->getInstallment() == 1 && count($plans) == 0) {
             $label = $this->__('Pay in full - %s', $quote->getStore()->formatPrice($item->getInstallmentAmount() / 100, false));
             $installments[$item->getInstallment()] = $label;
         } elseif ($item->getInstallment() != $maxInstallments && count($plans) == 0 || $item->getInstallment() == $maxInstallments && count($plans) > 0) {
             $label = $this->__('%sx - %s', $item->getInstallment(), $quote->getStore()->formatPrice($item->getInstallmentAmount() / 100, false)) . ' ';
             $label .= $item->getInstallment() > $freeInstallments ? $this->__('monthly interest rate (%s)', $interestRate . '%') : $this->__('interest-free');
             $label .= !empty($_planName) ? $this->__(' (Plan %s) ', $_planName) : null;
             $installments[$item->getInstallment()] = $label;
         }
     }
     return $installments;
 }
开发者ID:eneiasramos,项目名称:pagarme-magento,代码行数:50,代码来源:Cc.php

示例7: _prepareForm

 protected function _prepareForm()
 {
     $form = new Varien_Data_Form();
     $fieldset = $form->addFieldset('base_fieldset', array('legend' => Mage::helper('giftcards')->__('Create Gift Cards')));
     $fieldset->addField('file_path', 'text', array('name' => 'file_path', 'label' => Mage::helper('giftcards')->__('Path to export Cards Code'), 'title' => Mage::helper('giftcards')->__('Path to export Cards Code'), 'required' => true));
     $fieldset->addField('count', 'text', array('name' => 'count', 'label' => Mage::helper('giftcards')->__('Count of Gift Cards'), 'title' => Mage::helper('giftcards')->__('Count of Gift Cards'), 'required' => true));
     $fieldset->addField('amount', 'text', array('name' => 'amount', 'label' => Mage::helper('giftcards')->__('Gift Cards Amount'), 'title' => Mage::helper('giftcards')->__('Gift Cards Amount'), 'required' => true));
     $createConfig = new Varien_Object();
     $createConfig->setFilePath('/var/backups/cardslist' . date('d-m-Y-His') . '.csv');
     $createConfig->setCount(1);
     $createConfig->setAmount(100);
     $form->setValues($createConfig->getData());
     $form->setAction($this->getUrl('*/adminhtml_cardscreate/save'));
     $form->setMethod('post');
     $form->setUseContainer(true);
     $form->setId('edit_form');
     $this->setForm($form);
     return parent::_prepareForm();
 }
开发者ID:AleksNesh,项目名称:pandora,代码行数:19,代码来源:Form.php

示例8: _prepareCustomerCredit

 protected function _prepareCustomerCredit(Varien_Object $buyRequest, $product)
 {
     $store = Mage::app()->getStore();
     if ($store->isAdmin()) {
         $amount = $product->getPrice();
     } else {
         if ($buyRequest->getAmount()) {
             $amount = $buyRequest->getAmount();
             $includeTax = Mage::getStoreConfig('tax/display/type') != 1;
             $amount = $amount * 100 / Mage::helper('tax')->getPrice($product, 100, $includeTax);
         } else {
             $amount = $product->getPrice();
         }
         if (!$amount) {
             return Mage::helper('customercredit')->__('Please enter customercredit information');
         }
     }
     if (!$buyRequest->getAmount()) {
         $buyRequest->setAmount($amount);
     }
     $product->addCustomOption('amount', $amount);
     return array($product);
 }
开发者ID:protechhelp,项目名称:gamamba,代码行数:23,代码来源:Type.php

示例9: createOrder

 public function createOrder(Varien_Object $payment, $amount, $authorize)
 {
     $store_id = Mage::app()->getStore()->getStoreId();
     $logger = Mage::helper('worldpay/logger');
     if ($payment->getOrder()) {
         $orderId = $payment->getOrder()->getIncrementId();
         $order = $payment->getOrder();
     } else {
         $quote = $payment->getQuote();
         $orderId = $quote->getReservedOrderId();
         $quote->save();
     }
     $session = Mage::getSingleton('core/session');
     $token = $session->getData('payment_token');
     $savedCard = $session->getData('saved_card');
     $logger->log('Begin create order');
     $session->setData('wp_3dsSuccess', false);
     $session->setData('wp_orderCode', false);
     $worldpay = $this->setupWorldpay();
     $checkout = Mage::getSingleton('checkout/session')->getQuote();
     $billing = $checkout->getBillingAddress();
     $order_description = Mage::getStoreConfig('payment/worldpay/description', $store_id);
     if (!$order_description) {
         $order_description = "Order";
     }
     $currency_code = Mage::app()->getStore()->getCurrentCurrencyCode();
     $name = $billing->getName();
     $billing_address = array("address1" => $billing->getStreet(1), "address2" => $billing->getStreet(2), "address3" => $billing->getStreet(3), "postalCode" => $billing->getPostcode(), "city" => $billing->getCity(), "state" => "", "countryCode" => $billing->getCountry());
     try {
         $mode = Mage::getStoreConfig('payment/worldpay_mode', Mage::app()->getStore()->getStoreId());
         $settlementCurrency = Mage::getStoreConfig('payment/worldpay/settlementcurrency', Mage::app()->getStore()->getStoreId());
         $createOrderRequest = array('token' => $token, 'orderDescription' => $order_description, 'amount' => $amount * 100, 'currencyCode' => $currency_code, 'name' => $name, 'billingAddress' => $billing_address, 'customerOrderCode' => $orderId, 'settlementCurrency' => $settlementCurrency, 'successUrl' => Mage::getUrl('worldpay/apm/success', array('_secure' => true)), 'pendingUrl' => Mage::getUrl('worldpay/apm/pending', array('_secure' => true)), 'failureUrl' => Mage::getUrl('worldpay/apm/failure', array('_secure' => true)), 'cancelUrl' => Mage::getUrl('worldpay/apm/cancel', array('_secure' => true)));
         $logger->log('Order Request: ' . print_r($createOrderRequest, true));
         $response = $worldpay->createApmOrder($createOrderRequest);
         $logger->log('Order Response: ' . print_r($response, true));
         if ($response['paymentStatus'] === 'SUCCESS') {
             $this->setStore($payment->getOrder()->getStoreId());
             $logger->log('Order: ' . $response['orderCode'] . ' SUCCESS');
             $payment->setStatus(self::STATUS_APPROVED);
             $payment->setAmount($amount);
             $payment->setLastTransId($orderId);
             $payment->setTransactionId($response['orderCode']);
             $payment->setAdditionalInformation("worldpayOrderCode", $response['orderCode']);
             $payment->setShouldCloseParentTransaction(1)->setIsTransactionClosed(1)->registerCaptureNotification($amount);
         } else {
             if ($response['paymentStatus'] == 'PRE_AUTHORIZED') {
                 $logger->log('Order: ' . $response['orderCode'] . ' PRE_AUTHORIZED');
                 $payment->setAmount($amount);
                 $payment->setAdditionalInformation("worldpayOrderCode", $response['orderCode']);
                 $payment->setLastTransId($orderId);
                 $payment->setTransactionId($response['orderCode']);
                 $payment->setIsTransactionClosed(false);
                 $session->setData('wp_redirectURL', $response['redirectURL']);
                 $session->setData('wp_orderCode', $response['orderCode']);
             } else {
                 if (isset($response['paymentStatusReason'])) {
                     throw new Exception($response['paymentStatusReason']);
                 } else {
                     throw new Exception(print_r($response, true));
                 }
             }
         }
     } catch (Exception $e) {
         $payment->setStatus(self::STATUS_ERROR);
         $payment->setAmount($amount);
         $payment->setLastTransId($orderId);
         $logger->log($e->getMessage());
         Mage::throwException('Payment failed, please try again later ' . $e->getMessage());
     }
     return $this;
 }
开发者ID:ao,项目名称:worldpay-magento-1,代码行数:71,代码来源:Abstract.php

示例10: capture

 /**
  * Send capture request to gateway
  *
  * @param Varien_Object $payment
  * @param decimal $amount
  * @return Mage_Paygate_Model_Authorizenet
  * @throws Mage_Core_Exception
  */
 public function capture(Varien_Object $payment, $amount)
 {
     if ($amount <= 0) {
         Mage::throwException(Mage::helper('linkpoint')->__('Invalid amount for transaction.'));
     }
     $payment->setAmount($amount);
     $data = $this->_prepareData();
     $data['ordertype'] = "SALE";
     $creditcard = array('cardnumber' => $payment->getCcNumber(), 'cardexpmonth' => $payment->getCcExpMonth(), 'cardexpyear' => substr($payment->getCcExpYear(), -2));
     if ($this->getConfigData('useccv') == 1) {
         $creditcard["cvmindicator"] = "provided";
         $creditcard["cvmvalue"] = $payment->getCcCid();
     }
     $shipping = array();
     $billing = array();
     $order = $payment->getOrder();
     if (!empty($order)) {
         $BillingAddress = $order->getBillingAddress();
         $billing['name'] = $BillingAddress->getFirstname() . " " . $BillingAddress->getLastname();
         $billing['company'] = $BillingAddress->getCompany();
         $billing['address'] = $BillingAddress->getStreet(1);
         $billing['city'] = $BillingAddress->getCity();
         $billing['state'] = $BillingAddress->getRegion();
         $billing['zip'] = $BillingAddress->getPostcode();
         $billing['country'] = $BillingAddress->getCountry();
         $billing['email'] = $order->getCustomerEmail();
         $billing['phone'] = $BillingAddress->getTelephone();
         $billing['fax'] = $BillingAddress->getFax();
         $ShippingAddress = $order->getShippingAddress();
         if (!empty($shipping)) {
             $shipping['sname'] = $ShippingAddress->getFirstname() . " " . $ShippingAddress->getLastname();
             $shipping['saddress1'] = $ShippingAddress->getStreet(1);
             $shipping['scity'] = $ShippingAddress->getCity();
             $shipping['sstate'] = $ShippingAddress->getRegion();
             $shipping['szip'] = $ShippingAddress->getPostcode();
             $shipping['scountry'] = $ShippingAddress->getCountry();
         }
     }
     $transactiondetails = array();
     $merchantinfo = array();
     $merchantinfo['configfile'] = $data['storenumber'];
     $merchantinfo['keyfile'] = $data['key'];
     $paymentdetails = array();
     $paymentdetails['chargetotal'] = $payment->getAmount();
     $data = array_merge($data, $creditcard, $billing, $shipping, $transactiondetails, $merchantinfo, $paymentdetails);
     $result = $this->_postRequest($data);
     if (is_array($result) && count($result) > 0) {
         if (array_key_exists("r_approved", $result)) {
             if ($result["r_approved"] != "APPROVED") {
                 $payment->setStatus(self::STATUS_ERROR);
                 Mage::throwException("Gateway error : {" . (string) $result["r_error"] . "}");
             } else {
                 $payment->setStatus(self::STATUS_APPROVED);
                 $payment->setLastTransId((string) $result["r_ordernum"]);
                 if (!$payment->getParentTransactionId() || (string) $result["r_ordernum"] != $payment->getParentTransactionId()) {
                     $payment->setTransactionId((string) $result["r_ordernum"]);
                 }
                 return $this;
             }
         } else {
             Mage::throwException("No approval found");
         }
     } else {
         Mage::throwException("No response found");
     }
 }
开发者ID:tannpv,项目名称:magento1702,代码行数:74,代码来源:Linkpoint.php

示例11: authorize

 public function authorize(Varien_Object $payment, $amount)
 {
     $orderId = $payment->getOrder()->getIncrementId();
     try {
         $paymentValues = array("cardType" => $payment->getCcCid(), "expiresMonth" => $payment->getCcExpMonth(), "expiresYear" => $payment->getCcExpYear(), "cardHolderName" => $payment->getCcOwner(), "cardNumber" => $payment->getCcNumber(), "amount" => $amount, "orderId" => $orderId, "bankId" => $payment->getOrder()->getPosBankId(), "installment" => $payment->getOrder()->getPosInstallment());
         //FIXME: Find a way to define this part in the $payment object which is Magento_Sales_Info or something like that.
         if ($bankid == 12) {
             //Different banks...
             $paymentValues['username'] = "my_bank_username";
             $paymentValues['password'] = "my_secret_password_generally_not_that_secret";
             $paymentValues['clientid'] = "my_clientid_given_to_me_by_the_bank";
         } else {
             if ($bankid == 14) {
                 //... can require different values to be sent to them
                 $paymentValues['username'] = "my_second_bank_username";
                 $paymentValues['password'] = "my_secret_password_generally_not_that_secret";
                 $paymentValues['clientid'] = "my_clientid_given_to_me_by_the_bank";
                 $paymentValues['additionalSecondBankField'] = "additional_info";
             } else {
                 Mage::throwException("Invalid bankid: {$bankid}");
             }
         }
         //Define the url where I'm making the request...
         $urlToPost = "https://my.bank.com/pos/service/address/";
         //Now Create the request which I will send via Post Method...
         //Create a string like: cardType=VI&expiresMonth=12&expiresYear=2011&amount=100.50
         $postData = "";
         foreach ($paymentValues as $key => $val) {
             $posData .= "{$key}=" . urlencode($val) . "&";
         }
         //Let's create a curl request and send the values above to the bank...
         $ch = curl_init();
         curl_setopt($ch, CURLOPT_URL, $urlToPost);
         curl_setopt($ch, CURLOPT_TIMEOUT, 180);
         curl_setopt($ch, CURLOPT_HEADER, false);
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
         curl_setopt($ch, CURLOPT_POST, true);
         curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);
         //Put the created string here in use...
         curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
         curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
         $data = curl_exec($ch);
         //This value is the string returned from the bank...
         if (!$data) {
             throw new Exception(curl_error($ch));
         }
         $httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
         if ($httpcode && substr($httpcode, 0, 2) != "20") {
             //Unsuccessful post request...
             Mage::throwException("Returned HTTP CODE: " . $httpcode . " for this URL: " . $urlToPost);
         }
         curl_close($ch);
     } catch (Exception $e) {
         $payment->setStatus(self::STATUS_ERROR);
         $payment->setAmount($amount);
         $payment->setLastTransId($orderId);
         $this->setStore($payment->getOrder()->getStoreId());
         Mage::throwException($e->getMessage());
     }
     /*
      * Data outputted from the curl request
      *  is generally an xml string.
      * Assume that it is something like:
      *
      * <response>
      *   <isPaymentAccepted>1</isPaymentAccepted>
      *   <bankOrderId>1234233241</bankOrderId>
      * </response>
      *
      * However no bank response is never this simple by the way...
      * But this one gives you a general view of the thing.
      */
     $xmlResponse = new SimpleXmlElement($data);
     //Simple way to parse xml, Magento might have an equivalent class
     $isPaymentAccepted = $xmlResponse->isPaymentAccepted == 1;
     if ($isPaymentAccepted) {
         $this->setStore($payment->getOrder()->getStoreId());
         $payment->setStatus(self::STATUS_APPROVED);
         $payment->setAmount($amount);
         $payment->setLastTransId($orderId);
     } else {
         $this->setStore($payment->getOrder()->getStoreId());
         $payment->setStatus(self::STATUS_ERROR);
         //Throw an exception to fail the current transaction...
         Mage::throwException("Payment is not approved");
     }
     return $this;
 }
开发者ID:maxamillion32,项目名称:magento-examples,代码行数:88,代码来源:Payment.php

示例12: authorize

 public function authorize(Varien_Object $payment, $amount)
 {
     $order = $payment->getOrder();
     $order_id = $order->getId();
     $order_increment_id = $order->getIncrementId();
     $quote = $order->getQuote();
     $store_id = $order->getStoreId();
     $ccType = $payment->getCcType();
     $code = $this->_getStoreConfig('code');
     $key = $this->_getStoreConfig('key');
     $obs = $this->_getStoreConfig('obs');
     $obsadd1 = $this->_getStoreConfig('obsadd1');
     $obsadd2 = $this->_getStoreConfig('obsadd2');
     $obsadd3 = $this->_getStoreConfig('obsadd3');
     $tax_vat = $order->getCustomer()->getTaxvat();
     $address = $quote->getBillingAddress();
     $name = $address->getName();
     $street1 = $address->getStreet1();
     $street2 = $address->getStreet2();
     $postcode = $address->getPostcode();
     $city = $address->getCity();
     $region = $address->getRegion();
     $expiration = strtotime('+' . $this->_getStoreConfig('expiration') . 'days');
     $bank_expiration = date('dmY', $expiration);
     $transaction_expiration = date('Y-m-d', $expiration);
     $return_url = $this->_getStoreConfig('return_url');
     $increment = $this->_getStoreConfig('order_id_increment');
     $order_increment_prefix = $this->_getOrderIncrementPrefix($store_id);
     $number = $order_increment_id - $order_increment_prefix + $increment;
     $submit_dc = Mage::getModel('itaushopline/itaucripto')->geraDados($code, $number, str_replace('.', "", number_format($amount, 2, ',', '.')), $obs, $key, $name, '01', $tax_vat, $street1, $street2, $postcode, $city, $region, $bank_expiration, $return_url, $obsadd1, $obsadd2, $obsadd3);
     if (strlen($submit_dc) < self::ITAU_SHOPLINE_SUBMIT_TRANSACTION_LENGTH) {
         Mage::throwException(Mage::helper('itaushopline')->__('Unable to generate submit transaction code. Please check your settings.'));
     }
     $query_dc = Mage::getModel('itaushopline/itaucripto')->geraConsulta($code, $number, '0', $key);
     if (strlen($query_dc) < self::ITAU_SHOPLINE_QUERY_TRANSACTION_LENGTH) {
         Mage::throwException(Mage::helper('itaushopline')->__('Unable to generate query transaction code. Please check your settings.'));
     }
     $data = array('order_id' => $order_id, 'amount' => $amount, 'expiration' => $transaction_expiration, 'number' => $number, 'submit_dc' => $submit_dc, 'query_dc' => $query_dc);
     $result = Mage::getModel('utils/sql')->insert('gamuza_itaushopline_transactions', $data);
     if (!$result) {
         Mage::throwException(Mage::helper('itaushopline')->__('Unable to save the Itau ShopLine informations. Please verify your database.'));
     }
     $this->setStore($payment->getOrder()->getStoreId());
     $payment->setAmount($amount);
     $payment->setLastTransId($order_id);
     $payment->setStatus(self::STATUS_APPROVED);
     return $this;
 }
开发者ID:rafaelferreiraxd,项目名称:modulos-magento,代码行数:48,代码来源:Standard.php

示例13: capture

 public function capture(Varien_Object $payment, $amount)
 {
     $session = Mage::getSingleton('core/session');
     $logger = Mage::helper('worldpay/logger');
     if ($session->getData('wp_3dscompletionNeeded')) {
         $payment->setIsTransactionClosed(0);
         $payment->setSkipOrderProcessing(true);
         $payment->setStatus(self::STATUS_APPROVED);
         $payment->setAmount($amount);
         $payment->setShouldCloseParentTransaction(1);
         $payment->setAdditionalInformation("worldpayOrderCode", $session->getData('wp_orderCode'));
         $payment->setLastTransId($session->getData('wp_orderCode'));
         $payment->setTransactionId($session->getData('wp_orderCode'));
         $session->setData('wp_3dscompletionNeeded', false);
         return $this;
     }
     $worldpayOrderCode = $payment->getData('last_trans_id');
     if ($worldpayOrderCode) {
         $worldpay = $this->setupWorldpay();
         try {
             $authorizationTransaction = $payment->getAuthorizationTransaction();
             if ($authorizationTransaction) {
                 $payment->setAdditionalInformation("worldpayOrderCode", $authorizationTransaction->getTxnId());
                 $worldpayOrderCode = $authorizationTransaction->getTxnId();
             } else {
                 $worldpayOrderCode = $payment->getAdditionalInformation('worldpayOrderCode');
             }
             $worldpay->captureAuthorisedOrder($worldpayOrderCode, $amount * 100);
             $payment->setShouldCloseParentTransaction(1)->setIsTransactionClosed(1);
             $logger->log('Capture Order: ' . $session->getData('wp_orderCode') . ' success');
         } catch (Exception $e) {
             $logger->log('Capture Order: ' . $session->getData('wp_orderCode') . ' failed with ' . $e->getMessage());
             Mage::throwException('Payment failed, please try again later ' . $e->getMessage());
         }
     } else {
         $payment->setAdditionalInformation('payment_type', 'capture');
         return $this->createOrder($payment, $amount, false);
     }
 }
开发者ID:JGMAgency,项目名称:worldpay-magento,代码行数:39,代码来源:CreditCards.php

示例14: _prepareCustomerCredit

 protected function _prepareCustomerCredit(Varien_Object $buyRequest, $product)
 {
     if (Mage::app()->getStore()->isAdmin()) {
         $store = Mage::getSingleton('adminhtml/session_quote')->getStore();
     } else {
         $store = Mage::app()->getStore();
     }
     $amount = $buyRequest->getAmount();
     if ($amount) {
         $creditAmount = Mage::helper('customercredit/creditproduct')->getCreditValue($product);
         switch ($creditAmount['type']) {
             case 'range':
                 if ($amount < $this->convertPrice($product, $creditAmount['from'])) {
                     $amount = $this->convertPrice($product, $creditAmount['from']) * $creditAmount['storecredit_rate'];
                 } elseif ($amount > $this->convertPrice($product, $creditAmount['to'])) {
                     $amount = $this->convertPrice($product, $creditAmount['to']) * $creditAmount['storecredit_rate'];
                 } else {
                     if ($amount > 0) {
                         $amount = $amount * $creditAmount['storecredit_rate'];
                     } else {
                         $amount = 0;
                     }
                 }
                 $fnPrice = $amount;
                 break;
             case 'dropdown':
                 if (!empty($creditAmount['options'])) {
                     $check = false;
                     $giftDropdown = array();
                     for ($i = 0; $i < count($creditAmount['options']); $i++) {
                         $giftDropdown[$i] = $this->convertPrice($product, $creditAmount['options'][$i]);
                         if ($amount == $giftDropdown[$i]) {
                             $check = true;
                         }
                     }
                     if (!$check) {
                         $amount = $creditAmount['options'][0];
                     }
                     $fnPrices = array_combine($giftDropdown, $creditAmount['prices']);
                     $fnPrice = $fnPrices[$amount];
                 }
                 break;
             case 'static':
                 if ($amount != $this->convertPrice($product, $creditAmount['value'])) {
                     $amount = $creditAmount['value'];
                 }
                 $fnPrice = $creditAmount['credit_price'];
                 break;
             default:
                 return Mage::helper('customercredit')->__('Please enter Store Credit information.');
         }
     } else {
         return Mage::helper('customercredit')->__('Please enter Store Credit information.');
     }
     $buyRequest->setAmount($amount);
     $product->addCustomOption('credit_price_amount', $fnPrice);
     foreach (Mage::helper('customercredit')->getFullCreditProductOptions() as $key => $label) {
         if ($value = $buyRequest->getData($key)) {
             $product->addCustomOption($key, $value);
         }
     }
     return array($product);
 }
开发者ID:javik223,项目名称:Evron-Magento,代码行数:63,代码来源:Type.php

示例15: _placeTransaction

 protected function _placeTransaction($payment, $amount, $requestType)
 {
     $payment->setAnetTransType($requestType);
     $payment->setAmount($amount);
     $this->_initCardsStorage($payment);
     switch ($requestType) {
         case parent::REQUEST_TYPE_AUTH_ONLY:
             $newTransactionType = Mage_Sales_Model_Order_Payment_Transaction::TYPE_AUTH;
             break;
         case parent::REQUEST_TYPE_AUTH_CAPTURE:
             $newTransactionType = Mage_Sales_Model_Order_Payment_Transaction::TYPE_CAPTURE;
             break;
     }
     $this->getCardsStorage($payment)->flushCards();
     $result = new Varien_Object();
     $result->setRequestedAmount($amount);
     $result->setTransactionId($payment->getTransactionId());
     $result->setAmount($amount);
     $card = $this->_registerCard($result, $payment);
     parent::_addTransaction($payment, $card->getLastTransId(), $newTransactionType, array('is_transaction_closed' => 0), array($this->_realTransactionIdKey => $card->getLastTransId()), Mage::helper('paygate')->getTransactionMessage($payment, $requestType, $card->getLastTransId(), $card, $amount));
     if ($requestType == parent::REQUEST_TYPE_AUTH_CAPTURE) {
         $card->setCapturedAmount($card->getProcessedAmount());
         $this->getCardsStorage($payment)->updateCard($card);
     }
     return $this;
 }
开发者ID:xiaoguizhidao,项目名称:mydigibits,代码行数:26,代码来源:Authorizenet.php


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