cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

(LART me!) [PHP] $transaction->amount is null...

Had everything working in sandbox, using PHP AIM.

Management decided to give price breaks, so now I have to check a button on the form and assign the transaction amount based on the user input.

For some reason this is breaking:

$transaction = new AuthorizeNetAIM(API_Login_ID,Transaction_Key);//my test ID and Key
   if (defined(PKG_PRICE)) {
      die("PKG_PRICE is defined...");
      $transaction->amount = PKG_PRICE;
   } else {
      echo "making a good assignment now...";
      $transaction->amount = $this_pkg_price;
   }
   echo "the transaction amount is supposed to be $this_pkg_price, but it's coming up as: ";
   echo ($transaction->amount);exit;

 
And my output is "making a good assignment now", then "making a good assignment now
the transaction amount is supposed to be 2950, but it's coming up as: "

$transaction passes is_object().  $this_pkg_price is obviously set.

It's 4 PM here and must be something simple....

kkinsey
Member
1 ACCEPTED SOLUTION

Accepted Solutions

Well, not sure why it's not working that way --- like I said, it seemed to have been working before.

As I suspected, though, it does work if we use our own variable as the first arg to the AuthorizeandCapture function:


$response = $transaction->authorizeAndCapture($my_special_price_variable);

 
I can code around that.  Thanks for the help.

View solution in original post

5 REPLIES 5

is null or just your echo is not displaying? why did you have that is a seperated line?

RaynorC1emen7
Expert

@RaynorC1emen7 wrote:

is null or just your echo is not displaying? why did you have that is a seperated line?



Heavy debugging, Raynor.

To further elaborate, "null" is an understatement.  $transaction->amount is (apparently) not even set.

I'm currently operating under the assumption that the cause of this issue is that the variable is protected inside the AuthorizeNetAIM object.

However, I could swear that the code was working last week with simply "$transaction->amount = $variable;"

I'm sure I'll knock it, given enough time ... would appreciate any insight, though.

are you sure you wasn't using

setFields

 

$transaction->amount isn't it for the response?

Well, not sure why it's not working that way --- like I said, it seemed to have been working before.

As I suspected, though, it does work if we use our own variable as the first arg to the AuthorizeandCapture function:


$response = $transaction->authorizeAndCapture($my_special_price_variable);

 
I can code around that.  Thanks for the help.