Reply
Highlighted
Member
Posts: 3
Registered: ‎10-06-2011

Integration with Wordpress Eshop Plugin

Hello.

 

I am attempting to integrate a pay form directly into a wordpress site, such that the user will never have to visibly leave our site's domain in order to complete payment processing. For this purpose, it seems that the DPM model is the way to go. However, following the given integration instructions does not seem to work.

 

Any help or experience regarding this would be appreciated!

Highlighted
Posts: 1,609
Topics: 15
Kudos: 201
Solutions: 121
Registered: ‎06-23-2011

Re: Integration with Wordpress Eshop Plugin

There are a myriad of things that could be going wrong, not all of them necessarily the fault of the code. Can you paste your code here (in a code block, see the fifth icon from the left when you post) and describe what happens when you try to run it?

Highlighted
Member
Posts: 3
Registered: ‎10-06-2011

Re: Integration with Wordpress Eshop Plugin

No problem. But I'm warning you, this is a huge block of code! I do not have access to the FTP yet, so including of including the files, I had to paste the php files manually. I also placed the relay file on an FTP server to which I do have direct access. Other than that, I copy-pasted the code from your guide.

 

<?php
if ('checkout.php' == basename($_SERVER['SCRIPT_FILENAME']))
  die ('<h2>Direct File Access Prohibited</h2>');

  
 ////////netrequest.php
 
/**
 * Sends requests to the Authorize.Net gateways.
 *
 * @package    AuthorizeNet
 * @subpackage AuthorizeNetRequest
 */
abstract class AuthorizeNetRequest
{
    
    protected $_api_login;
    protected $_transaction_key;
    protected $_post_string; 
    public $VERIFY_PEER = true; // Set to false if getting connection errors.
    protected $_sandbox = true;
    protected $_log_file = false;
    
    /**
     * Set the _post_string
     */
    abstract protected function _setPostString();
    
    /**
     * Handle the response string
     */
    abstract protected function _handleResponse($string);
    
    /**
     * Get the post url. We need this because until 5.3 you
     * you could not access child constants in a parent class.
     */
    abstract protected function _getPostUrl();
    
    /**
     * Constructor.
     *
     * @param string $api_login_id       The Merchant's API Login ID.
     * @param string $transaction_key The Merchant's Transaction Key.
     */
    public function __construct($api_login_id = false, $transaction_key = false)
    {
        $this->_api_login = ($api_login_id ? $api_login_id : (defined('AUTHORIZENET_API_LOGIN_ID') ? AUTHORIZENET_API_LOGIN_ID : ""));
        $this->_transaction_key = ($transaction_key ? $transaction_key : (defined('AUTHORIZENET_TRANSACTION_KEY') ? AUTHORIZENET_TRANSACTION_KEY : ""));
        $this->_sandbox = (defined('AUTHORIZENET_SANDBOX') ? AUTHORIZENET_SANDBOX : true);
        $this->_log_file = (defined('AUTHORIZENET_LOG_FILE') ? AUTHORIZENET_LOG_FILE : false);
    }
  
....[continue to include files]...
  
  class AuthorizeNetException extends Exception
{
}
  
  
  <?php require_once 'http://www.koraminsurance.com/temp/anet_php_sdk/AuthorizeNet.php'; // The SDK
$relay_response_url = "http://www.koraminsurance.com/temp/relay_response.php"; // You will create this file in See Create relay_response.php...
$api_login_id = '[intentionally deleted]';
$transaction_key = '[intentionally deleted]';
$amount = "5.99";
$fp_sequence = "123"; // Any sequential number like an invoice number.
echo AuthorizeNetDPM::getCreditCardForm($amount, $fp_sequence, $relay_response_url,$api_login_id, $transaction_key);

 

Highlighted
Posts: 1,609
Topics: 15
Kudos: 201
Solutions: 121
Registered: ‎06-23-2011

Re: Integration with Wordpress Eshop Plugin

[ Edited ]

If you require a file using a URL, it's going to give you the generated results rather than the PHP source, unless you have an htaccess directive telling it to treat .php as plaintext or something (which would be very bad for security). So this line is going to create problems. You need the SDK stored locally on the site's hosting so you can reference it locally.

 

<?php require_once 'http://www.koraminsurance.com/temp/anet_php_sdk/AuthorizeNet.php'; // The SDK

Your relay response page also generates a syntax error. Whether it does that when called properly, I don't know, but that might need to be checked into as well.

 

$relay_response_url = "http://www.koraminsurance.com/temp/relay_response.php"; // You will create this file in See Create relay_response.php...

 Also, are you running this on a sandbox account or a production account? The function call needs an additional argument if you're running it on production. From the AuthorizeNetDPM.php file in the lib folder of the PHP SDK:

 

public static function getCreditCardForm($amount, $fp_sequence, $relay_response_url, $api_login_id, $transaction_key, $test_mode = true, $prefill = true)

 Might also help if you can tell me exactly what happens when you try to fill this out.

Highlighted
Member
Posts: 3
Registered: ‎10-06-2011

Re: Integration with Wordpress Eshop Plugin

Hm ok, I'll ask for these files to be uploaded directly to the site's file tree and I'll let you know what happens.


As far as your last question, the form doesn't actually load. Inserting this code seems to cause Wordpress to cease evaling of the code.

Highlighted
Posts: 1,609
Topics: 15
Kudos: 201
Solutions: 121
Registered: ‎06-23-2011

Re: Integration with Wordpress Eshop Plugin

First get it working outside of Wordpress, then worry about integrating it with Wordpress. That would be my advice. If all else fails, you can set up a payment portal under a subdomain on a separate hosting account, that way you don't have to worry about mixing the two.