Forums / Addon Payment Modules / Moneris approved and declined URLs

Moneris approved and declined URLs

Locked

Views: 11,826

Results 1 to 20 of 25
This thread is locked. New replies are disabled.
12 Nov 2007, 6:18 AM
#1
cooperwd avatar

cooperwd

New Zenner

Join Date:
Nov 2007
Posts:
19
Plugin Contributions:
0

Moneris approved and declined URLs

Hi there!

I'm trying to set up my test environment using the contributed Moneris module. Everything works great in the setup, but the readme file says this:

"Please select the POST response method and set the Approved and Declined URLs to your /index.php?main_page=checkout_process.php file location."

Problem is, the Moneris DrirectPost config won't accept that url -- says it's invalid. On a hunch, I removed the .php at the end, and Moneris accepted it.*

But of course when the user gets back to my site, all hell breaks lose at the url without the php:
**
Warning: include(DIR_WS_MONERISinsert_moneris_orderid.php) [function.include]: failed to open stream: No such file or directory in /home/myfolder/public_html/includes/modules/checkout_process.php on line 184

Warning: include() [function.include]: Failed opening 'DIR_WS_MONERISinsert_moneris_orderid.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/myfolder/public_html/includes/modules/checkout_process.php on line 184

Warning: Cannot modify header information - headers already sent by (output started at /home/myfolder/public_html/includes/modules/checkout_process.php:184) in /home/myfolder/public_html/includes/functions/functions_general.php on line 44**

If I refresh at that URL, I get to the shopping cart page, and the transaction is in the admin.

Obviously the root of the problem is with Moneris, but other Zen Cart installations must have cleared this hurdle. Can anyone provide any insight or advice? Thanks in advance for your help!

Dave

  • Actually, the first thing I tried was to url-encode the period in ".php", but Moneris didn't like that either. :)
12 Nov 2007, 7:12 AM
#2
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: Moneris approved and declined URLs

I've never used that module, but I can tell you that there are two problems you're dealing with:

  1. There should not be any .php on the end of main_page=checkout_process

  2. Your error messages are telling you that the constant for DIR_WS_MONERIS is not defined properly. Chances are there are instructions to add a line that defines DIR_WS_MONERIS somewhere in an existing file, or maybe an addon file containing the define statement didn't get uploaded fully or was put in the wrong place.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

12 Nov 2007, 2:28 PM
#3
cooperwd avatar

cooperwd

New Zenner

Join Date:
Nov 2007
Posts:
19
Plugin Contributions:
0

Re: Moneris approved and declined URLs

Thanks DrByte! That must be the problem. The instructions in the readme are as follows:

Add line "define('DIR_WS_MONERIS', DIR_WS_INCLUDES. 'moneris/');" into /catalog/includes/configure.php.

But there's no "catalog" folder in my install. I wondered if it "catalog" was just a custom folder name where the plugin's author had his zen cart install, so I tried adding this line to pblic_html/includes/configure.php -- but the error message persists.

Excuse the ridiculously long post, but I thought I should post the entire contents of the readme file, just to make sure I'm not misreading it.

Thanks again for any help you can provide!

Dave

---README FILE:---

  1. Extract all of the files from the Moneris zip package. Make sure all of the files in the package go into their appropriate folders.

  2. Go to Admin > Tools > Install SQL Patch and upload the file "Moneris.sql". You should receive a message saying "2 statements processed"

  3. Add the following code to the bottom of /catalog/includes/database_tables.php:

// Moneris Orders Table

define('TABLE_MONERIS_ORDERIDS', 'moneris_orderids');

  1. Add line "define('DIR_WS_MONERIS', DIR_WS_INCLUDES. 'moneris/');" into /catalog/includes/configure.php.

In /catalog/includes/modules/checkout_process.php FIND THIS:


for ($i=0, $n=sizeof($order_totals); $i<$n; $i++) {

if ($order_totals[$i]['code'] == 'ot_subtotal') $order_subtotal = $order_totals[$i]['value'];

if ($$order_totals[$i]['code']->credit_class == true) $credits_applied += $order_totals[$i]['value'];

if ($order_totals[$i]['code'] == 'ot_total') $ototal = $order_totals[$i]['value'];

}


ADD AFTER:


$selected_processor = $payment_modules->selection();

if( $selected_processor[0]['id'] == 'moneriseselectplus' )

{

include(DIR_WS_MONERIS . 'insert_moneris_orderid.php');

}


In /catalog/admin/orders.php FIND THIS:


<?php for ($i = 0, $n = sizeof($order->totals); $i < $n; $i++) { echo ' <tr>' . "\n" . ' <td align="right" class="'. str_replace('_', '-', $order->totals[$i]['class']) . '-Text">' . $order->totals[$i]['title'] . '</td>' . "\n" . ' <td align="right" class="'. str_replace('_', '-', $order->totals[$i]['class']) . '-Amount">' . $order->totals[$i]['text'] . '</td>' . "\n" . ' </tr>' . "\n"; } ?>
        </table></td>

      </tr>

    </table></td>

  </tr>

ADD AFTER:


<?php //Phet - Show eSelect Plus Order ID. $eSelectPlus_order_id = $db->Execute("select moneris_orderid from " . TABLE_MONERIS_ORDERIDS . " where orders_id = " . $db->prepareInput($oID) ); if ($eSelectPlus_order_id->RecordCount() > 0) { echo ' <tr>' . "\n" . ' <td class="main">' . "\n" . ' <table border="1" cellspacing="0" cellpadding="5">' . "\n" . ' <tr>' . "\n" . ' <td class="smallText" align="center"><b>eSelect Plus Order ID</b></td>' . "\n" . ' </tr>'; while (!$eSelectPlus_order_id->EOF) { echo ' <tr>' . "\n" . ' <td class="smallText" align="center">' . $eSelectPlus_order_id->fields['moneris_orderid'] . '</td>' . "\n" . ' </tr>' . "\n"; $eSelectPlus_order_id->MoveNext(); } echo ' </table>' . "\n" . ' </td>' . "\n" . ' </tr>'; } ?>
  1. Log into the eSelectPlus Merchant Resource Center and create a DirectPost configuration (Admin ñ DirectPost Config).

Please select the ìPOSTî response method and set the Approved and Declined URLís to your ì/index.php?main_page=checkout_process.phpî file location. Select ìnoî for all

other options. For more information about our DirectPost method of integration, please refer to the DirectPost Integration Guide at

https://www3.moneris.com/connect/en/documents/index.html.

  1. Log into the Zen Cart administrative tool to enable the Moneris Solutions' eSelectPlus payment module and configure it to use your DirectPost

configurationís ps_store_id and hpp_key values.

  1. Follow the documentation on how to test Moneris here: https://www3.moneris.com/connect/en/download/feb05/PHP/eSELECTplus_PHP_IG.pdf

Skip to Section 8 How Do I Test My Solution? (P. 19).

12 Nov 2007, 2:49 PM
#4
cooperwd avatar

cooperwd

New Zenner

Join Date:
Nov 2007
Posts:
19
Plugin Contributions:
0

Re: Moneris approved and declined URLs

I also noticed a code-highlighting problem in my text editor -- so I added a space before the period in this line:

define('DIR_WS_MONERIS', DIR_WS_INCLUDES. 'moneris/');

is now:

define('DIR_WS_MONERIS', DIR_WS_INCLUDES . 'moneris/');

-- i.e., added a space after DIR_WS_INCLUDES

Now the previous eror message is gone, but I've got a new one:

1146 Table 'mydb_zc1.moneris_orderids' doesn't exist
in:
[INSERT INTO moneris_orderids (moneris_orderid, orders_id, response_variables) VALUES ('mdp29487797939', '5', 'mdp29487797939;2007-11-12;09:32:59;660021630014062380;1.06;637826;027;01;APPROVED * =;purchase;;4242***4242;V ;1201;1;166c02b1068b592dce3b2653c2e581fd')]

The table is actually called "zen_moneris_orderids" in the database, but the code seems unaware of the prefix. It looks like step #3 in the readme is incomplete, in that it doesn't account for table prefixes.

So step #3 of the readme should read:

// Moneris Orders Table
define('TABLE_MONERIS_ORDERIDS', DB_PREFIX . 'moneris_orderids');

I'll do some testing and confirm that it's fixed.

Then I'll write to the plugin author :)

12 Nov 2007, 2:54 PM
#5
cooperwd avatar

cooperwd

New Zenner

Join Date:
Nov 2007
Posts:
19
Plugin Contributions:
0

Re: Moneris approved and declined URLs

Ok I've tested and we're in good shape! Dr Byte thanks again for the help.

12 Nov 2007, 3:07 PM
#6
cooperwd avatar

cooperwd

New Zenner

Join Date:
Nov 2007
Posts:
19
Plugin Contributions:
0

Re: Moneris approved and declined URLs

I can't find any way to get in touch with the plugin author, so I'll sum up here:

If your zen cart installation uses database table prefixes, step #3 of the readme should read:

// Moneris Orders Table
define('TABLE_MONERIS_ORDERIDS', DB_PREFIX . 'moneris_orderids');

Step #4 should read:

Add line "define('DIR_WS_MONERIS', DIR_WS_INCLUDES . 'moneris/');" into /includes/configure.php.

**References to "catalog/" in the readme
**
Lastly, any reference to "catalog/" in the readme should be interpreted as "the root folder of your zen cart installation" (in my case, public_html/)

12 Nov 2007, 3:33 PM
#7
cooperwd avatar

cooperwd

New Zenner

Join Date:
Nov 2007
Posts:
19
Plugin Contributions:
0

Re: Moneris approved and declined URLs

Also, step 7 should read (in part):

Please select the "POST" response method and set the Approved and Declined URLs to "http://www.yoursite.com/index.php?main_page=checkout_process".

25 Feb 2009, 4:37 PM
#8
greg_nst avatar

greg_nst

New Zenner

Join Date:
Jan 2009
Posts:
12
Plugin Contributions:
0

Re: Moneris approved and declined URLs

I am using a fresh install of Zen 1.3.8 with the Moneris module version 1.24 found here:

http://www.zen-cart.com/index.php?main_page=product_contrib_info&products_id=666

The issue I am having is remarkably similar to this one:

http://www.zen-cart.com/forum/showthread.php?t=105704&highlight=moneris

though that thread died before an actual solution was found. So, I think I will start another thread, give information on the steps I have followed, hopefully get some help, and find a solution for all the other Canadian companies that are trying to find a payment processor!!

I installed Zen cart, made some changes, and put it through a battery of tests. Everything worked perfectly, so I started trying to install/configure the Moneris module cited above.

While I was setting up the Moneris Module, I got stuck at this step (quoted from the module's 'readme.txt' file.

"7. Log into the eSelectPlus Merchant Resource Center and create a DirectPost configuration (Admin – DirectPost Config).
Please select the “POST” response method and set the Approved and Declined URL’s to your “/index.php?main_page=checkout_process.php” file location. Select “no” for all
other options."

That URL would not validate in Moneris' backend (404 not found). So, I did some reading on here and changed the URL to:

https://mysite.com/index.php?main_page=checkout_process

The URL worked, but that is when things started getting dodgy. When I put a failed transaction through, I am redirected to 'Step 2 of 3 - Payment Information'. The error message appears in the URL, but nowhere on screen. Not a big problem, hey?

But hold on, it gets worse - when I put a successful transaction through, the transaction times out.

Now, if I change the URL above to the actual success page URL, everything works perfectly on Moneris' backend (ie - I get an email with the perfect message/response code, but the order neither shows up in Zen's backend, nor do I get an actual order number on the success page.

Sorry for that long description....

My questions are:

(1) Would anyone like to volunteer to do my job for a little while? If so, I'll be in Mexico until the cart is working and winter is over.
(2) But, if not, does anyone know what URL I should enter into Moneris' backend. The readme file was written for Zen 1.3.7, so I suspect that some of the structure has changed.

Thank you in advance......

Greg

6 Aug 2009, 3:14 PM
#9
greg_nst avatar

greg_nst

New Zenner

Join Date:
Jan 2009
Posts:
12
Plugin Contributions:
0

Re: Moneris approved and declined URLs

Ooooops, I should have posted here several months ago.

If anyone runs into a similar problem, please let me know. I got this module working perfectly, though I had to make a few changes to get it there. While I should have documented what I did when I did it, I am confident that I can help anyone out who is having a similar problem.

Best of luck and enjoy Zen Cart!

GH

7 Aug 2009, 11:29 AM
#10
nixak avatar

nixak

Zen Follower

Join Date:
Nov 2007
Location:
Essex, UK
Posts:
137
Plugin Contributions:
1

Re: Moneris approved and declined URLs

Hi, although i'm using a different module I am have the same problems as you were, can you tell me how you fixed it please as its driving me insane lol.

16 Sep 2009, 11:39 AM
#12
jestientbob avatar

jestientbob

New Zenner

Join Date:
May 2008
Posts:
3
Plugin Contributions:
0

Re: Moneris approved and declined URLs

I am using 3.8a. I am receiving the following message

FAILED TO IDENTIFY STORE - INCORRECT STORE CREDENTIALS HAVE BEEN SENT

the site is http://cabotix.ca

27 Oct 2009, 7:12 AM
#13
jammin320 avatar

jammin320

Zen Follower

Join Date:
Mar 2007
Location:
Seattle, WA
Posts:
158
Plugin Contributions:
0

Re: Moneris approved and declined URLs

Can you folks expand on your solutions? I am having the same issues. It took some digging, but I was able to update my URL in the module to https://esplus.moneris.com/DPHPP/index.php. However, now whenever I put through a transaction, I land on a page at that URL that displays
Source: https://www.mysite.com/zencart/index.php?main_page=checkout_confirmation - POST-esplus.moneris.com. It sounds like you guys have solved this, do you have any advise you can share?

5 Jan 2010, 3:58 PM
#14
flar avatar

flar

New Zenner

Join Date:
Jan 2010
Posts:
2
Plugin Contributions:
0

Re: Moneris approved and declined URLs

I'm using the Moneris module v1.24 described in post 1 with a fresh install of zencart 1.3.8. So far, I can successfully complete a test transaction, with one issue.

Does anyone know how to output the confirmation details of a transaction to the user (i.e. the auth code, date, card type etc)? I can't seem to get this going.

Instead of just showing the confirmed/denied page from within zen cart (https://www.yoursite.com/store/index.php?main_page=checkout_success for example) I also want to output specific transaction details to the user for their records, so they can print it out or do whatever they need to do with it.

Can this be done by creating new confirmed / denied pages using the Define Pages Editor (editing define_checkout_success.php) or modifying the module itself? Or am I way off here? How would this change impact the confirmation email the user receives, would that need to be modified too?

Any help is appreciated, thanks!

6 Jan 2010, 6:42 AM
#15
jammin320 avatar

jammin320

Zen Follower

Join Date:
Mar 2007
Location:
Seattle, WA
Posts:
158
Plugin Contributions:
0

Re: Moneris approved and declined URLs

Hi flar,

I wasn't ever able to get as far as you have using the stock module. My post above was never resolved, and so I ended up building a custom module to plug into my cart. However, to get the info that you are looking for, I used the method that comes with the Moneris API. The following bit of code pulls it from their response and places it into variables in my module. I then save those variables into my database in the comments section of the order. Now, whenever the order is loaded, this information appears. I hi-jacked this method from the Authorize.net API if you need a deeper exampled - approx line 452 in includes/modules/payment/authorizenet_aim.php.

This code here is my solution.

		//Response Object
		$mpgResponse = $mpgHttpPost->getMpgResponse();
		
		$this->ResponseCode = $mpgResponse->getResponseCode();
		$this->transaction_id = $mpgResponse->getTxnNumber();
		$this->reference_num = $mpgResponse->getReferenceNum();
		$this->auth_code =	$mpgResponse->getAuthCode();
		$this->responseMessage = $mpgResponse->getMessage();
		
		//Build a string to save to the database
		while(list($key, $value) = each($mpgResponse->responseData)) {
			$response_list .= ($key) . '=' . urlencode(ereg_replace(',', '', $value)) . ' &';
		}
		// Remove the last "&" from the string
		$response_list = substr($response_list, 0, -1);
		
		//Debug info
		$response_list .= ' - cc_owner: ' .$order->info['cc_owner'] .' - cc_type: ' .$order->info['cc_type'];
		
		//Add the Moneris Response to the DB
		$db->Execute("INSERT INTO " . TABLE_MONERIS_ORDERIDS . "(moneris_orderid, orders_id, response_variables) VALUES ('" .$new_moneris_id ."','" .$new_order_id ."','" .$response_list ."')");

I hope that helps.

7 Jan 2010, 5:17 PM
#16
flar avatar

flar

New Zenner

Join Date:
Jan 2010
Posts:
2
Plugin Contributions:
0

Re: Moneris approved and declined URLs

jammin320,

Thanks for the reply.

After some tinkering, I figured out that in fact I do already have access to the response variables in the db, they are stored in moneris_orderids as ";" separated values, similar to the code you've written. I can call them in and use the explode function to break them up and show them, however, I'm positive i've gone about this the wrong way.

What I'm trying to do is run a query like this:

$theOrderId = 1;
global $db;
$sql = "select orders_id,response_variables from " . TABLE_MONERIS_ORDERIDS . " where orders_id = :orderID:";
$sql = $db->bindVars($sql, ':orderID:', $theOrderId, 'integer');
$result = $db->Execute($sql);

$data = $result->fields['response_variables'];

and then used php explode to break up $data and assign a variable to each result.

This works, and I have all the response variables, which is great. The problem is i'm doing this right from the "define_checkout_success.php" over ride file, located here:

/store/includes/languages/english/html_includes/<your_template>/define_checkout_success.php

So, I'm trying to use this as the "receipt" page, which probably is not the right way to do it (or is it?).

That's kind of where I'm stuck;

  1. From define_checkout_success.php I don't have access to the current order id, so I have to manually assign it (as shown above), which is bad. I've been trying to find where in the script it assigns the new order number, but no luck so far.

  2. Should the response data be included in the confirmation email the user receives as well? If so, where do I edit that?
    It doesn't specify in the Integration Guide from Moneris that it needs to be in the email too, but I thought it might be better for the user to have it on file too.

Can you offer any insight? Thanks!

8 Jan 2010, 6:31 AM
#17
jammin320 avatar

jammin320

Zen Follower

Join Date:
Mar 2007
Location:
Seattle, WA
Posts:
158
Plugin Contributions:
0

Re: Moneris approved and declined URLs

Hi flar,

I can offer some help, though I am not sure it is exactly what you are looking for.

First, you are correct about the define_checkout_success.php file. I am not an expert on the whole checkout process, but it is my expectation that any change made in the define_checkout_success file will affect all of the payment modules where as the change that you are looking to make needs to be restricted to the Moneris module. Knowing the way the world works, some time down the road, when you have forgotten all of the changes that you have made, you'll need to change payment modules to something like Authorize.net and find that your changes break their module. You want to keep your modifications in the Moneris payment module file. My file is custom so it may be titled differently than yours, but for me, that file is includes/modules/payment/monerisselectplus.php.

To get the order ID, I again borrowed code from the Authorizenet_AIM module as it works well and uses similar technology to the Moneris setup. In the function before_process(), I have added the following code:

		// Calculate the next expected order id
		$last_order_id = $db->Execute("select * from " . TABLE_ORDERS . " order by orders_id desc limit 1");
		$new_order_id = $last_order_id->fields['orders_id'];
		$new_order_id = ($new_order_id + 1);		

It is a little crude, but it works without a hitch.

As for where to include the response data, I felt that it met Moneris' criteria without that info in the email. The email includes a link to the online invoice and the data is included there for easy reference. It also stays safely behind the user's login credentials rather than emailed via plain text. That is just my opinion though. I have never updated the email template and don't know off of the top of my head where that code lives.

I hope that helps.

2 Mar 2010, 7:42 PM
#18
mgmoore avatar

mgmoore

New Zenner

Join Date:
Oct 2008
Posts:
13
Plugin Contributions:
0

Re: Moneris approved and declined URLs

Greg_nst:

Ooooops, I should have posted here several months ago.

If anyone runs into a similar problem, please let me know. I got this module working perfectly, though I had to make a few changes to get it there. While I should have documented what I did when I did it, I am confident that I can help anyone out who is having a similar problem.

Best of luck and enjoy Zen Cart!

GH
Hi Greg - Can you tell me how you fixed this problem - I'm having the same issue.
Thanks,
Gemma

2 Mar 2010, 8:54 PM
#19
cwhittaker avatar

cwhittaker

New Zenner

Join Date:
Jan 2010
Posts:
28
Plugin Contributions:
0

Re: Moneris approved and declined URLs

Hi Greg,

I too am trying to configure the Monaris payment module. I used the eselect module for zen cart and it doesn't work properly I receive a blank white screen after the order is confirmed.

I didn't know about the Monaris module you are referring to. I will try installing it and let you know if I have any success. Thank you.

I will also update this thread if i find answered to the issues your having.

Best,
Cynthia.

Greg_nst:

I am using a fresh install of Zen 1.3.8 with the Moneris module version 1.24 found here:

http://www.zen-cart.com/index.php?main_page=product_contrib_info&products_id=666

The issue I am having is remarkably similar to this one:

http://www.zen-cart.com/forum/showthread.php?t=105704&highlight=moneris

though that thread died before an actual solution was found. So, I think I will start another thread, give information on the steps I have followed, hopefully get some help, and find a solution for all the other Canadian companies that are trying to find a payment processor!!

I installed Zen cart, made some changes, and put it through a battery of tests. Everything worked perfectly, so I started trying to install/configure the Moneris module cited above.

While I was setting up the Moneris Module, I got stuck at this step (quoted from the module's 'readme.txt' file.

"7. Log into the eSelectPlus Merchant Resource Center and create a DirectPost configuration (Admin – DirectPost Config).
Please select the “POST” response method and set the Approved and Declined URL’s to your “/index.php?main_page=checkout_process.php” file location. Select “no” for all
other options."

That URL would not validate in Moneris' backend (404 not found). So, I did some reading on here and changed the URL to:

https://mysite.com/index.php?main_page=checkout_process

The URL worked, but that is when things started getting dodgy. When I put a failed transaction through, I am redirected to 'Step 2 of 3 - Payment Information'. The error message appears in the URL, but nowhere on screen. Not a big problem, hey?

But hold on, it gets worse - when I put a successful transaction through, the transaction times out.

Now, if I change the URL above to the actual success page URL, everything works perfectly on Moneris' backend (ie - I get an email with the perfect message/response code, but the order neither shows up in Zen's backend, nor do I get an actual order number on the success page.

Sorry for that long description....

My questions are:

(1) Would anyone like to volunteer to do my job for a little while? If so, I'll be in Mexico until the cart is working and winter is over.
(2) But, if not, does anyone know what URL I should enter into Moneris' backend. The readme file was written for Zen 1.3.7, so I suspect that some of the structure has changed.

Thank you in advance......

Greg

2 Mar 2010, 11:11 PM
#20
cwhittaker avatar

cwhittaker

New Zenner

Join Date:
Jan 2010
Posts:
28
Plugin Contributions:
0

Re: Moneris approved and declined URLs

Hi Greg,

Just an update, I have the exact problem the credit card processes perfectly and posts to the test site correctly but does not show up under orders in Zen Cart. ARGH!!!

Will let you know if I figure out anything...I think I might join you in Mexico!!! LOL ;)

Cheers,
Cynthia.

cwhittaker:

Hi Greg,

I too am trying to configure the Monaris payment module. I used the eselect module for zen cart and it doesn't work properly I receive a blank white screen after the order is confirmed.

I didn't know about the Monaris module you are referring to. I will try installing it and let you know if I have any success. Thank you.

I will also update this thread if i find answered to the issues your having.

Best,
Cynthia.