Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Custom Payment Module (Beanstream) Problems
 
kevin123
Jr. Member
 
Total Posts:  27
Joined:  2008-11-04
 

Hello Everyone,

First off, I am developing with Magento ver. 1.2.1.

I have based a lot of my code on what I learned from the following tutorials:
http://www.magentocommerce.com/wiki/how-to/create-payment-method-module
http://eliasinteractive.com/blog/magento-create-new-payment-method-cash-on-delivery/

and also this forum thread:
http://www.magentocommerce.com/boards/viewthread/832

Also, I have based my code on the existing Authorizenet payment module packaged with magento.

With that aside, I am trying to develop a custom payment module to connect Magento to Beanstream Payment Gateway.

I have reached the point where, I can see my new module in:
Admin > Advanced > Advanced

However, when I try goto
Admin > Sales > Payment Methods

I get the following error.

Warning: include(Pxcv/Paygate/Model/Authorizenet/Source/PaymentAction.php[function.include]failed to open streamNo such file or directory  in /home/public_html/dev/kevin/app/code/core/Mage/Core/functions.php on line 72
Trace
:
#0 /home/public_html/dev/kevin/app/code/core/Mage/Core/functions.php(72): mageCoreErrorHandler(2, 'include(Pxcv/Pa...', '/home/pub...', 72, Array)
#1 /home/public_html/dev/kevin/app/code/core/Mage/Core/functions.php(72): __autoload()
#2 [internal function]: __autoload('Pxcv_Paygate_Mo...')
#3 /home/public_html/dev/kevin/app/code/core/Mage/Core/Model/Config.php(788): class_exists('Pxcv_Paygate_Mo...')
#4 /home/public_html/dev/kevin/app/Mage.php(317): Mage_Core_Model_Config->getModelInstance('paygate/authori...', Array)
#5 /home/public_html/dev/kevin/app/Mage.php(331): Mage::getModel('paygate/authori...', Array)
#6 /home/public_html/dev/kevin/app/code/core/Mage/Adminhtml/Block/System/Config/Form.php(270): Mage::getSingleton('paygate/authori...')
#7 /home/public_html/dev/kevin/app/code/core/Mage/Adminhtml/Block/System/Config/Form.php(180): Mage_Adminhtml_Block_System_Config_Form->initFields(Object(Varien_Data_Form_Element_Fieldset), Object(Mage_Core_Model_Config_Element), Object(Mage_Core_Model_Config_Element))
#8 /home/public_html/dev/kevin/app/code/core/Mage/Adminhtml/Block/System/Config/Edit.php(91): Mage_Adminhtml_Block_System_Config_Form->initForm()
#9 /home/public_html/dev/kevin/app/code/core/Mage/Adminhtml/controllers/System/ConfigController.php(88): Mage_Adminhtml_Block_System_Config_Edit->initForm()
#10 /home/public_html/dev/kevin/app/code/core/Mage/Core/Controller/Varien/Action.php(367): Mage_Adminhtml_System_ConfigController->editAction()
#11 /home/public_html/dev/kevin/app/code/core/Mage/Core/Controller/Varien/Router/Admin.php(143): Mage_Core_Controller_Varien_Action->dispatch('edit')
#12 /home/public_html/dev/kevin/app/code/core/Mage/Core/Controller/Varien/Front.php(158): Mage_Core_Controller_Varien_Router_Admin->match(Object(Mage_Core_Controller_Request_Http))
#13 /home/public_html/dev/kevin/app/Mage.php(457): Mage_Core_Controller_Varien_Front->dispatch()
#14 /home/public_html/dev/kevin/index.php(52): Mage::run()
#15 {main}

I am not sure what is causing the authorizenet reference in the error:

Warning: include(Pxcv/Paygate/Model/Authorizenet/Source/PaymentAction.php[function.include]failed to open streamNo such file or directory  in /home/public_html/dev/kevin/app/code/core/Mage/Core/functions.php on line 72

I am hoping someone with a fresh pair of eyes, could point out what I am doing wrong.

These are the files I currently have on my server for this custom module:

/app/etc/modules/Pxcv_Paygate.xml
/app/code/local/Pxcv/Paygate/etc/config.xml
/app/code/local/Pxcv/Paygate/etc/system.xml
/app/code/local/Pxcv/Paygate/Helper/Data.php
/app/code/local/Pxcv/Paygate/sql/paygate_setup/mysql4-install-0.1.0.php
/app/code/local/Pxcv/Paygate/Model/Beanstream.php
/app/code/local/Pxcv/Paygate/Model/Beanstream/Request.php
/app/code/local/Pxcv/Paygate/Model/Beanstream/Result.php

In the next post I will post source code for each (Keep in mind, the actual payment module functions (authorize/refund/etc) are not completed:

 
Magento Community Magento Community
Magento Community
Magento Community
 
kevin123
Jr. Member
 
Total Posts:  27
Joined:  2008-11-04
 

Source Code below:

/app/etc/modules/Pxcv_Paygate.xml

<config>
  <
modules>
      <
Pxcv_Paygate>
          <
active>true</active>
          <
codePool>local</codePool>
          <
depends>
              <
Mage_Payment />
          </
depends>
          <
version>0.1.0</version>
      </
Pxcv_Paygate>
  </
modules>
</
config>

/app/code/local/Pxcv/Paygate/etc/config.xml

<?xml version="1.0"?>
<config>
  <
modules>
     <
Pxcv_Paygate>
        <
version>0.1.0</version>
     </
Pxcv_Paygate>
  </
modules>

  <global>
      <
models>
          <
paygate>
              <class>
Pxcv_Paygate_Model</class>
          </
paygate>
      </
models>

      <
resources>
          <
paygate_setup>
              <
setup>
                  <
module>Pxcv_Paygate</module>
              </
setup>
              <
connection>
                  <use>
core_setup</use>
              </
connection>
          </
paygate_setup>
          <
paygate_write>
              <
connection>
                <use>
core_write</use>
              </
connection>
          </
paygate_write>
          <
paygate_read>
             <
connection>
              <use>
core_read</use>
            </
connection>
          </
paygate_read>
      </
resources>
  </global>

  <default>
      <
payment>
          <
beanstream>
              <
active>0</active>
              <
model>paygate/beanstream</model>
              <
order_status>1</order_status>
              <
title>Credit Card (Beanstream.com)</title>
              <
cgi_url>https://www.beanstream.com/scripts/process_transaction.asp</cgi_url>
              
<test>1</test>          
              <
cctypes>AE,VI,MC,DI</cctypes>
              <
payment_action>authorize</payment_action>
              <
allowspecific>0</allowspecific>
          </
beanstream>
       </
payment>
  </default>
</
config>
 
Magento Community Magento Community
Magento Community
Magento Community
 
kevin123
Jr. Member
 
Total Posts:  27
Joined:  2008-11-04
 

Source code continued:

/app/code/local/Pxcv/Paygate/etc/system.xml

<?xml version="1.0"?>
<config>
 <
sections>
<!-- 
payment tab -->
      <
payment>
          <
groups>
              <
beanstream translate="label" module="paygate">
                  <
label>Beanstream.com</label>
                  <
sort_order>670</sort_order>
                  <
show_in_default>1</show_in_default>
                  <
show_in_website>1</show_in_website>
                  <
show_in_store>0</show_in_store>
                  <
fields>
                      <
active translate="label">
                          <
label>Enabled</label>
                          <
frontend_type>select</frontend_type>
                          <
source_model>adminhtml/system_config_source_yesno</source_model>
                          <
sort_order>1</sort_order>
                          <
show_in_default>1</show_in_default>
                          <
show_in_website>1</show_in_website>
                          <
show_in_store>0</show_in_store>
                      </
active>
                      <
title translate="label">
                          <
label>Title</label>
                          <
frontend_type>text</frontend_type>
                          <
sort_order>2</sort_order>
                          <
show_in_default>1</show_in_default>
                          <
show_in_website>1</show_in_website>
                          <
show_in_store>0</show_in_store>
                      </
title>
                      <
login translate="label">
                          <
label>Merchant ID</label>
                          <
frontend_type>text</frontend_type>
                          <
backend_model>adminhtml/system_config_backend_encrypted</backend_model>
                          <
sort_order>3</sort_order>
                          <
show_in_default>1</show_in_default>
                          <
show_in_website>1</show_in_website>
                          <
show_in_store>0</show_in_store>
                      </
login
                      <
cgi_url>
                          <
label>Gateway URL</label>
                          <
frontend_type>text</frontend_type>
                          <
sort_order>4</sort_order>
                          <
show_in_default>1</show_in_default>
                          <
show_in_website>1</show_in_website>
                          <
show_in_store>0</show_in_store>
                      </
cgi_url>                                            
                      <
order_status translate="label">
                          <
label>New order status</label>
                          <
frontend_type>select</frontend_type>
                          <
source_model>adminhtml/system_config_source_order_status_processing</source_model>
                          <
sort_order>5</sort_order>
                          <
show_in_default>1</show_in_default>
                          <
show_in_website>1</show_in_website>
                          <
show_in_store>0</show_in_store>
                      </
order_status>
                      <
test translate="label">
                          <
label>Test mode</label>
                          <
frontend_type>select</frontend_type>
                          <
source_model>adminhtml/system_config_source_yesno</source_model>
                          <
sort_order>6</sort_order>
                          <
show_in_default>1</show_in_default>
                          <
show_in_website>1</show_in_website>
                          <
show_in_store>0</show_in_store>
                      </
test>                      
                  </
fields>
              </
beanstream>
          </
groups>
      </
payment>
  </
sections>
</
config>

/app/code/local/Pxcv/Paygate/Helper/Data.php

<?php
/**
 * Paygate data helper
 */
class Pxcv_Paygate_Helper_Data extends Mage_Core_Helper_Abstract {

}

/app/code/local/Pxcv/Paygate/sql/paygate_setup/mysql4-install-0.1.0.php

<?php
$installer 
$this;
/* @var $installer Mage_Core_Model_Resource_Setup */

$installer->startSetup();

$installer->endSetup();
?>

/app/code/local/Pxcv/Paygate/Model/Beanstream/Request.php

<?php
class Pxcv_Paygate_Model_Beanstream_Request extends Varien_Object {
    
}

/app/code/local/Pxcv/Paygate/Model/Beanstream/Result.php

<?php
class Pxcv_Paygate_Model_Beanstream_Result extends Varien_Object {
    
}
 
Magento Community Magento Community
Magento Community
Magento Community
 
kevin123
Jr. Member
 
Total Posts:  27
Joined:  2008-11-04
 

Source Code Continued [Final Page]

/app/code/local/Pxcv/Paygate/Model/Beanstream.php

<?php
Class Pxcv_Paygate_Model_Beanstream extends Mage_Payment_Model_Method_Cc {
    
    
const CGI_URL 'https://www.beanstream.com/scripts/process_transaction.asp';

    const 
REQUEST_METHOD_CC                 'CC';

    const 
REQUEST_TYPE_AUTH_CAPTURE         'AUTH_CAPTURE';
    const 
REQUEST_TYPE_AUTH_ONLY            'AUTH_ONLY';
    const 
REQUEST_TYPE_CAPTURE_ONLY         'CAPTURE_ONLY';
    const 
REQUEST_TYPE_CREDIT               'CREDIT';
    const 
REQUEST_TYPE_VOID                 'VOID';
    const 
REQUEST_TYPE_PRIOR_AUTH_CAPTURE     'PRIOR_AUTH_CAPTURE';
        
    const 
RESPONSE_DELIM_CHAR                 ',';

    const 
RESPONSE_CODE_APPROVED             1;
    const 
RESPONSE_CODE_DECLINED             0;
    const 
RESPONSE_CODE_ERROR                3;
    const 
RESPONSE_CODE_HELD                 4;
            
    
/**
    * unique internal payment method identifier
    *
    * @var string [a-z0-9_]
    */    
    
protected $_code                     'beanstream';
        
    
/**
     * Availability options
     */    

    /**
     * Is this payment method a gateway (online auth/charge) ?
     */    
    
protected $_isGateway               true;
    
    
/**
     * Can authorize online?
     */    
    
protected $_canAuthorize            true;

    
/**
     * Can capture funds online?
     */
    
protected $_canCapture              true;    

    
/**
     * Can capture partial amounts online?
     */
    
protected $_canCapturePartial       false;

    
/**
     * Can refund online?
     */
    
protected $_canRefund               false;
     
    
/**
     * Can void transactions online?
     */     
    
protected $_canVoid                 true;

    
/**
     * Can use this payment method in administration panel?
     */    
    
protected $_canUseInternal          true;
   
    
/**
     * Can show this payment method as an option on checkout payment page?
     */    
    
protected $_canUseCheckout          true;
    
/**
     * Is this payment method suitable for multi-shipping checkout?
     */    
    
protected $_canUseForMultishipping  true;
    
    
/**
     * Can save credit card information for future processing?
     */    
    
protected $_canSaveCc                 false;

    
/**
     * Send authorize request to gateway
     *
     * @param   Varien_Object $payment
     * @param   decimal $amount
     * @return  Mage_Paygate_Model_Authorizenet
     */
    
public function authorize(Varien_Object $payment$amount{
        $error 
false;

        if(
$amount>0){
            $payment
->setAnetTransType(self::REQUEST_TYPE_AUTH_ONLY);
            
$payment->setAmount($amount);

            
$request $this->_buildRequest($payment);
            
$result  $this->_postRequest($request);

            
$payment->setCcApproval($result->getApprovalCode())
                ->
setLastTransId($result->getTransactionId())
                ->
setCcTransId($result->getTransactionId())
                ->
setCcAvsStatus($result->getAvsResultCode())
                ->
setCcCidStatus($result->getCardCodeResponseCode());

            switch (
$result->getResponseCode()) {
                
case self::RESPONSE_CODE_APPROVED:
                    
$payment->setStatus(self::STATUS_APPROVED);
                    break;
                case 
self::RESPONSE_CODE_DECLINED:
                    
$error Mage::helper('paygate')->__('Payment authorization transaction has been declined.');
                    break;
                default:
                    
$error Mage::helper('paygate')->__('Payment authorization error.');
                    break;
            
}
        }else{
            $error 
Mage::helper('paygate')->__('Invalid amount for authorization.');
        
}

        
if ($error !== false{
            Mage
::throwException($error);
        
}
        
return $this;        
    
}
    
    
public function capture(Varien_Object $payment$amount{
        
    }
    
    
/**
     * void transaction
     *
     * @param   Varien_Object $payment
     * @param   string $payment Varien_Object object
     * @return  Mage_Payment_Model_Abstract
     */
    
public function void(Varien_Object $payment{    
    }
    
    
/**
     * Refund the amount with transaction id
     *
     * @access    public
     * @param    string $payment Varien_Object object
     * @return    Mage_Payment_Model_Abstract
     */
    
public function refund(Varien_Object $payment$amount{
        
    }
    
    
/**
     * Prepare request to gateway
     *
     * @link http://www.authorize.net/support/AIM_guide.pdf
     * @param Mage_Sales_Model_Document $order
     * @return unknown
     */    
    
protected function _buildRequest(Varien_Object $payment{
        
    }
    
    
/**
     * Post request to gateway
     *
     * @link http://www.authorize.net/support/AIM_guide.pdf
     * @param Mage_Sales_Model_Document $order
     * @return unknown
     */    
    
protected function _postRequest(Varien_Object $request{
        
    }
}
?>
 
Magento Community Magento Community
Magento Community
Magento Community
 
kevin123
Jr. Member
 
Total Posts:  27
Joined:  2008-11-04
 

I apologize for the mega long post.

Any feedback would be much appreciated!

 
Magento Community Magento Community
Magento Community
Magento Community
 
kevin123
Jr. Member
 
Total Posts:  27
Joined:  2008-11-04
 

Ok, well it took two days to figure out. But I fixed the problem..

The name of my module is Pxcv_Paygate. I changed this to Pxcv_Paygatee (for fun) and bingo the bug is gone.

I guess, there is some sort of naming clash with Mage_Paygate..

I thought the Magento namespaces would keep this from happening..

 
Magento Community Magento Community
Magento Community
Magento Community
 
goldfishpk
Jr. Member
 
Total Posts:  1
Joined:  2011-04-07
 

Dear kevin123,

Thanks a lot for your posts on Bean Stream Payment method.  Its work like charm smile

 
Magento Community Magento Community
Magento Community
Magento Community
 
RedRave
Jr. Member
 
Total Posts:  10
Joined:  2012-10-14
 

Sorry to resuscitate an old topic, but can someone advise if I can use this code as-is on Magento 1.7.0.2?

Many thanks!

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top