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


PHP Mage_Payment_Model_Info::getMethodInstance方法代码示例

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


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

示例1: getMethodInstance

 /**
  * Retrieve payment method model object
  *
  * @return Mage_Payment_Model_Method_Abstract
  */
 public function getMethodInstance()
 {
     $method = parent::getMethodInstance();
     return $method->setStore($this->getQuote()->getStore());
 }
开发者ID:relue,项目名称:magento2,代码行数:10,代码来源:Payment.php

示例2: getInfoBlock

 /**
  * Retrieve payment information block
  *
  * @param   Mage_Payment_Model_Info $info
  * @return  Mage_Core_Block_Template
  */
 public function getInfoBlock(Mage_Payment_Model_Info $info)
 {
     $blockType = $info->getMethodInstance()->getInfoBlockType();
     if ($this->getLayout()) {
         $block = $this->getLayout()->createBlock($blockType);
     } else {
         $className = Mage::getConfig()->getBlockClassName($blockType);
         $block = new $className();
     }
     $block->setInfo($info);
     return $block;
 }
开发者ID:codercv,项目名称:urbansurprisedev,代码行数:18,代码来源:Data.php

示例3: getInfoBlock

 /**
  * Retrieve payment information block
  *
  * @param   Mage_Payment_Model_Info $info
  * @return  Mage_Core_Block_Template
  */
 public function getInfoBlock(Mage_Payment_Model_Info $info)
 {
     $blockType = $info->getMethodInstance()->getInfoBlockType();
     $layout = $this->getLayout() ?: Mage::app()->getLayout();
     $block = $layout->createBlock($blockType);
     $block->setInfo($info);
     return $block;
 }
开发者ID:nemphys,项目名称:magento2,代码行数:14,代码来源:Data.php

示例4: collectPayment

 public function collectPayment(\Mage_Payment_Model_Info $payment, $amount, $capture = true)
 {
     $Currency = Mage::app()->getStore()->getBaseCurrencyCode();
     require_once MAGENTO_ROOT . '/lib/Start/autoload.php';
     # At the top of your PHP file
     $token = isset($_POST['payfortToken']) ? $_POST['payfortToken'] : false;
     $email = isset($_POST['payfortEmail']) ? $_POST['payfortEmail'] : false;
     if (!$token || !$email) {
         //this block will be executed if the order was authorized earlier and now trying to capture amount
         $token_array = $payment->getAdditionalInformation('token');
         $token = $token_array['token'];
         $email = $token_array['email'];
     }
     if (!$token || !$email) {
         Mage::throwException('Invalid Token');
     }
     $currency = !isset($Currency) ? 'AED' : $Currency;
     if (file_exists(MAGENTO_ROOT . '/data/currencies.json')) {
         $currency_json_data = json_decode(file_get_contents(MAGENTO_ROOT . '/data/currencies.json'), 1);
         $currency_multiplier = $currency_json_data[$currency];
     } else {
         $currency_multiplier = 100;
     }
     $amount_in_cents = $amount * $currency_multiplier;
     $order = $payment->getOrder();
     $order_items_array_full = array();
     foreach ($order->getAllVisibleItems() as $value) {
         $order_items_array['title'] = $value->getName();
         $order_items_array['amount'] = round($value->getPrice(), 2) * $currency_multiplier;
         $order_items_array['quantity'] = $value->getQtyOrdered();
         array_push($order_items_array_full, $order_items_array);
     }
     $shipping_amount = $order->getShippingAmount();
     $shipping_amount = $shipping_amount * $currency_multiplier;
     if (Mage::getSingleton('customer/session')->isLoggedIn()) {
         $customer = Mage::getSingleton('customer/session')->getCustomer();
         $username = $customer->getName();
         $registered_at = date(DATE_ISO8601, strtotime($customer->getCreatedAt()));
     } else {
         $username = "Guest";
         $registered_at = date(DATE_ISO8601, strtotime(date("Y-m-d H:i:s")));
     }
     $billing_data = $order->getBillingAddress()->getData();
     if (is_object($order->getShippingAddress())) {
         $shipping_data = $order->getShippingAddress()->getData();
         $shipping_address = array("first_name" => $shipping_data['firstname'], "last_name" => $shipping_data['lastname'], "country" => $shipping_data['country_id'], "city" => $shipping_data['city'], "address" => $shipping_data['customer_address'], "phone" => $shipping_data['telephone'], "postcode" => $shipping_data['postcode']);
     } else {
         $shipping_address = array();
     }
     $billing_address = array("first_name" => $billing_data['firstname'], "last_name" => $billing_data['lastname'], "country" => $billing_data['country_id'], "city" => $billing_data['city'], "address" => $billing_data['customer_address'], "phone" => $billing_data['telephone'], "postcode" => $billing_data['postcode']);
     $shopping_cart_array = array('user_name' => $username, 'registered_at' => $registered_at, 'items' => $order_items_array_full, 'billing_address' => $billing_address, 'shipping_address' => $shipping_address);
     $orderId = Mage::getSingleton('checkout/session')->getLastRealOrderId();
     $charge_args = array('description' => "Magento charge for " . $email, 'card' => $token, 'currency' => $currency, 'email' => $email, 'ip' => $_SERVER['REMOTE_ADDR'], 'amount' => $amount_in_cents, 'capture' => $capture, 'shipping_amount' => $shipping_amount, 'shopping_cart' => $shopping_cart_array, 'metadata' => array('reference_id' => $orderId));
     $ver = new Mage();
     $version = $ver->getVersion();
     $userAgent = 'Magento ' . $version . ' / Start Plugin ' . self::PLUGIN_VERSION;
     Start::setUserAgent($userAgent);
     $method = $payment->getMethodInstance();
     if ($method->getConfigData('test_mode') == 1) {
         Start::setApiKey($method->getConfigData('test_secret_key'));
     } else {
         Start::setApiKey($method->getConfigData('live_secret_key'));
     }
     try {
         // Charge the token
         $charge = Start_Charge::create($charge_args);
         //need to process charge as success or failed
         $payment->setTransactionId($charge["id"]);
         if ($capture) {
             $payment->setIsTransactionClosed(1);
         } else {
             $payment->setIsTransactionClosed(0);
         }
     } catch (Start_Error $e) {
         $error_code = $e->getErrorCode();
         if ($error_code === "card_declined") {
             $errorMsg = 'Charge was declined. Please, contact you bank for more information or use a different card.';
         } else {
             $errorMsg = $e->getMessage();
         }
         throw new Mage_Payment_Model_Info_Exception($errorMsg);
     }
     //need to process charge as success or failed
 }
开发者ID:payfort,项目名称:magento,代码行数:84,代码来源:Paymentmethod.php

示例5: isInlinePayment

 /**
  * checks if the payment method can pbe processed via direct link
  *
  * @param Mage_Payment_Model_Info $payment
  *
  * @return bool
  */
 public function isInlinePayment(Mage_Payment_Model_Info $payment)
 {
     $result = false;
     $methodInstance = $payment->getMethodInstance();
     if ($methodInstance instanceof Netresearch_OPS_Model_Payment_DirectDebit || $methodInstance instanceof Netresearch_OPS_Model_Payment_Cc && ($methodInstance->hasBrandAliasInterfaceSupport($payment) || Mage::helper('ops/data')->isAdminSession())) {
         $result = true;
     }
     return $result;
 }
开发者ID:roshu1980,项目名称:add-computers,代码行数:16,代码来源:Payment.php


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