Post by wendynovianto » Wed Apr 23, 2008 4:38 pm

I'm integrating Authorize.net payment module with OpenCart, and currently I'm having some problem with it. I'm attaching the integration that I did, which can be installed the same way with SecurePay, except that the file is different. It's being integrated using Authorize.net SIM.

There are a couple of hacking that needs to be done on OpenCart for this to work.
  • I need to remove "enctype="multipart/form-data" from the checkout_confirm controller template for this payment to work, because it seems to me that Authorize.net cannot proceed with the posting data, if the encoding type being set as multipart/form-data
Transaction can be made successfully, but there are some other things that are not working, such as:
  • By using relay response from Authorize.net, the script stuck at the callback controller, which I'm replacing it by displaying notice that the page will be redirected to the checkout_success controller and using meta-refresh to do the redirection.
  • Because of the above problem, the shopping cart is not being emptied after transaction, but the transaction status had been updated successfully and an email had been sent as well.
If somebody can help me with this, it will be awesome, because I can see the needs of Authorize.net payment gateway to be provided for OpenCart user like me. I'm not sure on how OpenCart react to callback system, because I can see that paypal and cash on delivery is being implemented successfully, but it doesn't seem to work that way on my Authorize.net integration.
Last edited by wendynovianto on Wed Apr 23, 2008 4:47 pm, edited 1 time in total.

Newbie

Posts

Joined
Wed Apr 23, 2008 4:26 pm

Post by wendynovianto » Wed Apr 23, 2008 4:54 pm

If you're wondering why I'm echoing an output during callback is because I keep getting error response from Authorize.net gateway, which sounded like this:
**Please DO NOT REPLY to this message. E-mail support@authorize.net if you have any questions.

Authorize.Net Merchant,

Your script timed out while we were trying to post transaction results to it.
  Transaction ID: 0
Transaction Result: This transaction has been approved.

The following message was displayed to the customer:

------------------------------An error occurred while trying to report this transaction to the merchant. An e-mail has been sent to the merchant informing them of the error. The following is the result of the attempt to charge your credit card.

This transaction has been approved.

It is advisable for you to contact the merchant to verify that you will receive the product or service.
This is the response from Authorize.net gateway staff, which I got from ZenCart forum related to the above error message:
Greetings from Authorize.Net!

When Authorize.Net is responding back to a script on your server our system waits 10 seconds for a response. If we do not get a response in 10 seconds, our server will time out and display an error page. In this case the customer will see the transaction results on an error page that Authorize.net generates.

If this happens we will either send an email to you indicating: "An error occurred while trying to report this transaction to the merchant. An email has been sent to the merchant informing them of the error. The following is a result of the attempt to charge your credit card"

or

The transaction will be declined within your Merchant Interface. The transaction detail will display (Unable to send notification to Customer).

If the customer closes the browser window before we receive data from your script to print to the screen we will change the transaction response reason code to 52.

To prevent these errors the first thing that you will need to look for is the order that your script executes. It is very important that something is printed to the screen before any other process is started. If your script prints to the screen first, we will recognize that you have received the transaction results.

To resolve this issue:
- Before doing anything else start writing to your receipt page. For example: print your page headers and the first part of the page body.
- Check that your script permissions are correct and that it can accept an HTTPS POST.
- Check that the script is not completing other functions before writing to the screen, such as writing to a database or sending emails.
- Please check to see if there are different processes that are used in your script for approvals, declines, or errors. Check each process to be sure that they will write to the screen before any other functions.
- Verify that your script is not using redirects upon receipt of the response from our servers. Redirects strongly are discouraged because they can potentially interfere with the process.
After echoing output on the callback, Authorize.net is no longer returning the error message to the screen, as well as to my email.

Things to note though, even before the above fix, the transaction is still being processed successfully, except that Authorize.net keep showing an error message that was shown above at the end of the payment process. I don't know how to get around it, so I come up with meta-refresh, which I'm using this code below to redirect the user after the callback to checkout_success controller. By using this method, it shows another problem, which I described on the first post.

Please, I need OpenCart expert to help me on this, because I don't know the way how the underlying payment system work in OpenCart.
Your help on this will be greatly appreciated.

Newbie

Posts

Joined
Wed Apr 23, 2008 4:26 pm

Post by wendynovianto » Mon Apr 28, 2008 11:13 am

Somebody? Can someone point me to the right direction, so I can finalize this payment gateway?

Newbie

Posts

Joined
Wed Apr 23, 2008 4:26 pm

Post by bruce » Mon Apr 28, 2008 12:43 pm

Hi Wendy, I looked through the authorize.net documentation and can only suggest that you use the hosted receipt response as Relay looks pretty messy.

Active Member

Posts

Joined
Wed Dec 12, 2007 2:26 pm

Post by wendynovianto » Tue Apr 29, 2008 4:43 am

Hi Bruce,

The integration that I did is using SIM (Simple Integration Method), in which I don't have to have an SSL hosting for me to be able to accept credit card payment through Authorize.net. I had implemented this on our home grown shopping cart system, and so far it works fine.

The only problem that I encountered is the relay response that should trigger the final checkout process on OpenCart system, which I'm not sure how to implement it the right way. If someone knows in depth about the system, it will be awesome if I can get a head start on this.

More direction on this will be greatly appreciated, because I've 2 e-commerce website that I'm planning to build on top of OpenCart system, so I'm willing to work on this payment gateway.

Thanks you so much for the reply.
Wendy Novianto

Newbie

Posts

Joined
Wed Apr 23, 2008 4:26 pm

Post by bruce » Tue Apr 29, 2008 1:18 pm

Hosted Receipt and Relay are both part of SIM. So is Silent Response that, based on my reading of the doco, is similar to the callback mechanism of paypal.

I suspect that the reason for the errors is that using Relay, you are expected to post the html for the receipt response back to authorize.net and your code in the callback does not send anything. Have a look at the callback function in the OpenCart paypal payment extension to see how to build and send html to a web site using php. The bit you need is shown below.

Code: Select all

	function callback() {
		$req = 'cmd=_notify-validate';

		foreach ($_POST as $key => $value) {
			$req .= '&' . $key . '=' . urlencode(stripslashes($value));
		}

		$header  = 'POST /cgi-bin/webscr HTTP/1.0' . "\r\n";
		$header .= 'Content-Type: application/x-www-form-urlencoded' . "\r\n";
		$header .= 'Content-Length: ' . strlen($req) . "\r\n\r\n";
		
		if (!$this->config->get('paypal_test')) {
			$fp = fsockopen('ssl://www.paypal.com', 443, $errno, $errstr, 30);
		} else {
			$fp = fsockopen('ssl://www.sandbox.paypal.com', 443, $errno, $errstr, 30);
		}
		
		if ($fp) {
			fputs($fp, $header . $req);
You may be able to use the html built by your home grown shopping cart integration as a basis for what to send.

The rest of what you have done in your callback function is correct wrt processing an order in OpenCart.

Active Member

Posts

Joined
Wed Dec 12, 2007 2:26 pm

Post by wendynovianto » Fri May 23, 2008 7:54 pm

After having the project being integrated with MyBB, we're back on the payment gateway problem.

Bruce, I tried your suggestion, but it doesn't make sense to me. What the Authorize.net did is basically sending the response back to our system through post back. So there is no need for us to post it back again to Authorize.net. I still have no clue and am still trying to find the solution.

If you have anymore input or somebody else might have, it will be greatly appreciated...

Newbie

Posts

Joined
Wed Apr 23, 2008 4:26 pm

Post by bruce » Mon May 26, 2008 10:28 pm

Hi Wendy,

If you would like to post a zipped copy of what you have done so far, I will review it. Please supply all the files in the correct folders so it is easy to install.

Active Member

Posts

Joined
Wed Dec 12, 2007 2:26 pm

Post by wendynovianto » Tue May 27, 2008 1:46 am

It's suppose to be the same with the one above. I haven't made any changes yet since The first time I posted except for a few testing and etc.

Please let me know if you cannot get the above zip file to work with your installation Bruce.

Thank you...

Newbie

Posts

Joined
Wed Apr 23, 2008 4:26 pm

Post by bruce » Tue May 27, 2008 10:55 am

The original is ok.... I thought you may have done some more with it.

Active Member

Posts

Joined
Wed Dec 12, 2007 2:26 pm

Post by wendynovianto » Tue May 27, 2008 2:22 pm

Not yet. I did a couple testing and etc, but none of them is working according to what I'm expecting, so I always return them back to the original.

Thanks for your help Bruce.

Newbie

Posts

Joined
Wed Apr 23, 2008 4:26 pm
Who is online

Users browsing this forum: No registered users and 1 guest