dmx1 Posted November 17, 2020 Share Posted November 17, 2020 Hi Larry, Hope you are well. I have hit a brick wall on page 336 on Effortless Ecommerce 2nd edition. I have written all the code up to this point. The only modification I have made is changing the urls beginning with 'https' to 'http' in the billing.php page eg: $location = 'https://' . BASE_URL . 'checkout.php'; to $location = 'http://' . BASE_URL . 'checkout.php'; and $location = 'http://' . BASE_URL . 'final.php'; to $location = '/final.php'; These are temporary adjustments because I don't have a ssl certificate installed yet. When I get to the billing.php page and fill out all the form details which are all correct. I then click the 'place order' button to process the payment, and absolutely nothing happens. My 'API_LOGIN_ID' id and 'TRANSACTION_KEY' are both correct. The billing.php page just refreshes with the same values in the fields, and not going to the 'final.php' page. I debugged the program and when I got to the billing.php page, when I got to the 'Process payment section' // Process the payment! if (isset($order_id, $order_total)) { I encountered an error at the following line: '$response = $aim->authorizeOnly();' all the values contained in the '$response' variable came back as null, ie: _response_array = null approved = (bool) false declined = null error = (bool)true response_code = null transaction_id = null invoice_number = null description = null customer_id = null first_name = null last_name = null etc so the following line: $r = mysqli_query($dbc, "CALL add_transaction($order_id, '{$response->transaction_type}', $order_total, {$response->response_code}, '$reason', {$response->transaction_id}, '$full_response')"); came back as false so if ($response->approved) returned false I don't understand what happened because all the entered fields in the 'billing.php' page were correct, but for some reason, when passed to Authorize.net, the values are failing and returning null values. I have tried for 3 full days to work this out but no luck. Can you please help Thank you regards Link to comment Share on other sites More sharing options...
dmx1 Posted November 18, 2020 Author Share Posted November 18, 2020 Upon further research, the problem happens in the billing.php page, specifically at the line: $response = $aim->authorizeOnly(); All my entered values are entered correctly, but when the following class is called in the 'anet_php_sdk' folder: class AuthorizeNetAIM extends AuthorizeNetRequest() and then the following method inside the class is called: public function authorizeOnly($amount = false, $card_num = false, $exp_date = false) { ($amount ? $this->amount = $amount : null); ($card_num ? $this->card_num = $card_num : null); ($exp_date ? $this->exp_date = $exp_date : null); $this->type = "AUTH_ONLY"; return $this->_sendRequest(); } The following variable parameters: '$amount', '$card_num', and '$exp_date' all return null values Up until then, all the variables '$amount', '$card_num', and '$exp_date' all have valid values, but for some reason, they are not being passed into the parameters inside the above 'authorizeOnly($amount = false, $card_num = false, $exp_date = false)' function So the values that have been entered for the credit card details, are never passed into the above method because the boolean 'false' is assigned to these values. I tried to take away all the 'false' values in the parameter in the 'authorizeOnly()' function, but all I got back was a blank 'billing.php' page. So because all 'null' values are returned in the above 'authorizeOnly()' method, the following method in the 'billing.php' page, returns false, and the payment is never processed. if ($response->approved) {) Can you help me solve this problem please. Thank you. regards Link to comment Share on other sites More sharing options...
Larry Posted November 18, 2020 Share Posted November 18, 2020 Hmmm...it's been a long while since I've looked at this code. What version of the Authorize.NET PHP library are you using? This could be a change in their library since the book was written. Link to comment Share on other sites More sharing options...
dmx1 Posted November 18, 2020 Author Share Posted November 18, 2020 Hi Larry, I am using the following version which can be found at: https://github.com/objco/anet_php_sdk It's called anet_php_sdk-master The reason I am using this version is because the link developer.authorize.net/downloads where you said we could download the version you are using on page 325, is obsolete, so I had no choice but to find another link where there was another version. I believe I am using a slightly different version from the one you are using. regards Link to comment Share on other sites More sharing options...
dmx1 Posted November 18, 2020 Author Share Posted November 18, 2020 Looking at it again, I think it's the same version that you are using, but just a different link. It's version 1.1.8 Link to comment Share on other sites More sharing options...
Larry Posted November 21, 2020 Share Posted November 21, 2020 Okay, so the code is the same as in the book and the library is roughly the same and the code examples in GitHub are roughly the same. This is going to be hard to debug! My inclination is that either the library doesn't work on HTTP or it has something to do with the sandbox. I would first log into Authorize.net and see if I can view the requests being made. First check that the requests are getting there. Then, if so, check that the requests are receiving the CC dummy values. Link to comment Share on other sites More sharing options...
dmx1 Posted November 22, 2020 Author Share Posted November 22, 2020 Okay, I will give that a shot. Thanks Larry Link to comment Share on other sites More sharing options...
dmx1 Posted November 22, 2020 Author Share Posted November 22, 2020 27 minutes ago, dmx1 said: Okay, I will give that a shot. Thanks Larry Link to comment Share on other sites More sharing options...
Recommended Posts