cancel
Showing results for 
Search instead for 
Did you mean: 

Direct Post Method - Switching from test to live?

Hi,

 

I am using the Direct Post Method.

<?php
require_once 'anet_php_sdk/AuthorizeNet.php'; // The SDK
$url = "http://www.....com/direct_post.php";
$api_login_id = '...';
$transaction_key = '...';
$md5_setting = '...'; // Your MD5 Setting
$amount = "5.99";
AuthorizeNetDPM::directPostDemo($url, $api_login_id, $transaction_key, $amount, $md5_setting);
?>

 

 

It seems to be working, but I am not sure what I need to do to switch from test mode to live mode (other than changing the option in my account).

 

I tried setting the constant in AuthorizeNet.php:

define("AUTHORIZENET_SANDBOX", false);

...but this did nothing (it still submitted to test.authorize.net).

 

 

I also tried changing the line

protected $_sandbox = true;

to

protected $_sandbox = false;

in AuthorizeNetRequest.php, but that also made no difference :(

 

 

Finally I just changed the actual values in AuthorizeNetAIM.php and AuthorizeNetDPM.php:

const SANDBOX_URL = 'https://test.authorize.net/gateway/transact.dll';

to

const SANDBOX_URL = 'https://secure.authorize.net/gateway/transact.dll';

 

...that at least made the URL change ...but I know that is the wrong way of doing it, and also, I don't know if there is something else that also needs to be changed in the code. There must be an easy way of switching this code over to live, but I can't seem to find it in the documentation.

 

Help?

Thanks!
Heather

 

 

raspberryh
Member
1 ACCEPTED SOLUTION

Accepted Solutions

Inside AuthorizeNetDPM.php:

 

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

 As you can see, $test_mode is passed after the transaction key.

public static function directPostDemo($url, $api_login_id, $transaction_key, $amount = "0.00", $md5_setting = "")
...
            echo AuthorizeNetDPM::getCreditCardForm($amount, $fp_sequence, $url, $api_login_id, $transaction_key);

 Just add yourself a new argument for $test_mode and then pass it. Something like:

 

public static function directPostDemo($url, $api_login_id, $transaction_key, $amount = "0.00", $test_mode = true, $md5_setting = "")
...
            echo AuthorizeNetDPM::getCreditCardForm($amount, $fp_sequence, $url, $api_login_id, $transaction_key, $test_mode);

 Then call the function like so:

 

AuthorizeNetDPM::directPostDemo($url, $api_login_id, $transaction_key, $amount, false, $md5_setting);

View solution in original post

TJPride
Expert
2 REPLIES 2

Inside AuthorizeNetDPM.php:

 

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

 As you can see, $test_mode is passed after the transaction key.

public static function directPostDemo($url, $api_login_id, $transaction_key, $amount = "0.00", $md5_setting = "")
...
            echo AuthorizeNetDPM::getCreditCardForm($amount, $fp_sequence, $url, $api_login_id, $transaction_key);

 Just add yourself a new argument for $test_mode and then pass it. Something like:

 

public static function directPostDemo($url, $api_login_id, $transaction_key, $amount = "0.00", $test_mode = true, $md5_setting = "")
...
            echo AuthorizeNetDPM::getCreditCardForm($amount, $fp_sequence, $url, $api_login_id, $transaction_key, $test_mode);

 Then call the function like so:

 

AuthorizeNetDPM::directPostDemo($url, $api_login_id, $transaction_key, $amount, false, $md5_setting);
TJPride
Expert

Awesome!! Sorry for not replying earlier - I didn't get an email notification about this response. This is great! Thanks so much!


Heather