I upgraded my magento from 1.4.0.1 to 1.6.1 and yes a lot of things broke especially the ability to pay using Paymate.
I did some research and found a lot of people having the issue of non data being passed from Magento to Paymate to populate the fields like address, amount etc. Since there has been no support at all? I decided to take matters into my own hands.
Here is the code from the file: /app/code/community/Fontis/Paymate/Model/Paymate.php
replace this file with your original file Paymate.php. As always I suggest that you back up everything!
This worked for me. Technically the issue was the code didn’t like getting the getQuote() from the checkout/session object. Instead getting the getLastRealOrderId from checkout/session and loading a new model with the order id worked.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 | <?php /** * Fontis Paymate Extension * * NOTICE OF LICENSE * * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.txt. * It is also available through the world-wide-web at this URL: * http://opensource.org/licenses/osl-3.0.php * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@magentocommerce.com so one can be sent to you a copy immediately. * * @category Fontis * @package Fontis_Paymate * @author Lloyd Hazlett * @author Chris Norton * @copyright Copyright (c) 2010 Fontis Pty. Ltd. (http://www.fontis.com.au) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ /** * Paymate payment model * * @category Fontis * @package Fontis_Australia */ class Fontis_Paymate_Model_Paymate extends Mage_Payment_Model_Method_Abstract { const CGI_URL = 'https://www.paymate.com/PayMate/ExpressPayment'; const CGI_URL_TEST = 'https://www.paymate.com/PayMate/TestExpressPayment'; const REQUEST_AMOUNT_EDITABLE = 'N'; protected $_code = 'paymate'; protected $_formBlockType = 'fontis_paymate_block_form'; protected $_allowCurrencyCode = array('AUD', 'EUR', 'GBP', 'NZD', 'USD'); protected $_isGateway = false; protected $_canAuthorize = false; protected $_canCapture = true; protected $_canCapturePartial = false; protected $_canRefund = false; protected $_canVoid = false; protected $_canUseInternal = false; protected $_canUseCheckout = true; protected $_canUseForMultishipping = false; /** * Assign data to info model instance * * @param mixed $data * @return Fontis_Australia_Model_Payment_Paymate */ public function assignData($data) { $details = array(); if ($this->getUsername()) { $details['username'] = $this->getUsername(); } if (!empty($details)) { $this->getInfoInstance()->setAdditionalData(serialize($details)); } return $this; } public function getUsername() { return $this->getConfigData('username'); } public function getUrl() { $url = $this->getConfigData('cgi_url'); if(!$url) { $url = self::CGI_URL_TEST; } return $url; } /** * Get session namespace * * @return Fontis_Australia_Model_Payment_Paymate_Session */ public function getSession() { return Mage::getSingleton('paymate/paymate_session'); } /** * Get checkout session namespace * * @return Mage_Checkout_Model_Session */ public function getCheckout() { return Mage::getSingleton('checkout/session'); } /** * Get current quote * * @return Mage_Sales_Model_Quote */ public function getQuote() { return $this->getCheckout()->getQuote(); } public function getCheckoutFormFields() { $orderIncrementId = $this->getCheckout()->getLastRealOrderId(); $order = Mage::getModel('sales/order')->loadByIncrementId($orderIncrementId); $a = $order->getShippingAddress(); $b = $order->getBillingAddress(); $currency_code = $order->getCurrencyCode(); //$cost = $order->getSubtotal() - $order->getDiscountAmount(); $cost = $order->getGrandTotal(); //$shipping = $order->getShippingAmount(); //$_shippingTax = $order->getShippingAddress()->getTaxAmount(); //$_billingTax = $order->getBillingAddress()->getTaxAmount(); //$tax = sprintf('%.2f', $_shippingTax + $_billingTax); //$cost = sprintf('%.2f', $cost + $tax); $fields = array( 'mid' => $this->getUsername(), 'amt' => sprintf('%.2f', $cost + $shipping), 'amt_editable' => self::REQUEST_AMOUNT_EDITABLE, 'currency' => $currency_code, 'ref' => $orderIncrementId, 'pmt_sender_email' => $b->getEmail(), 'pmt_contact_firstname' => $b->getFirstname(), 'pmt_contact_surname' => $b->getLastname(), 'pmt_contact_phone' => $b->getTelephone(), 'pmt_country' => $b->getCountry(), 'regindi_address1' => $b->getStreet(1), 'regindi_address2' => $b->getStreet(2), 'regindi_sub' => $b->getCity(), 'regindi_state' => $b->getRegion(), // Returns full state name 'regindi_pcode' => $b->getPostcode(), 'return' => Mage::getUrl('paymate/paymate/complete'), 'popup' => 'N', ); // Run through fields and replace any occurrences of & with the word // 'and', as having an ampersand present will conflict with the HTTP // request. $filtered_fields = array(); foreach ($fields as $k=>$v) { $value = str_replace("&","and",$v); $filtered_fields[$k] = $value; } return $filtered_fields; } public function createFormBlock($name) { $block = $this->getLayout()->createBlock('paymate/paymate_form', $name) ->setMethod('paymate') ->setPayment($this->getPayment()) ->setTemplate('fontis/paymate/form.phtml'); return $block; } /*validate the currency code is avaialable to use for paypal or not*/ public function validate() { parent::validate(); $currency_code = $this->getQuote()->getBaseCurrencyCode(); if (!in_array($currency_code,$this->_allowCurrencyCode)) { Mage::throwException(Mage::helper('paymate')->__('Selected currency code ('.$currency_code.') is not compatabile with Paymate')); } return $this; } public function onOrderValidate(Mage_Sales_Model_Order_Payment $payment) { return $this; } public function onInvoiceCreate(Mage_Sales_Model_Invoice_Payment $payment) { } public function canCapture() { return true; } public function getOrderPlaceRedirectUrl() { return Mage::getUrl('paymate/paymate/redirect'); } } |