Post by babyewok » Fri Feb 19, 2010 9:50 pm

Hi,

I Have Opencart 1.4 and I am just testing SagePay on my local test server on my computer and I've managed to clear up and Invalid problem I was having with CustomerName, Postcode, etc by using the solution at the end of this thread: http://forum.opencart.com/viewtopic.php ... d&start=15

Now, the only error I am getting is "The FailureURL field should be between 1 and 2000 characters long." which suggest that no Failure URL is specified. Looking at sagepay.php, it is referrenced here on line 33:

Code: Select all

if ($this->request->get['route'] != 'checkout/guest_step_3') {
			$this->data['FailureURL'] = $this->url->https('checkout/payment');
		} else {
			$this->data['FailureURL'] = $this->url->https('checkout/guest_step_2');
		}
Why is SagePay simulator returning this error?
Last edited by i2Paq on Sun Aug 08, 2010 1:27 am, edited 1 time in total.
Reason: Topic moved

New member

Posts

Joined
Mon Oct 19, 2009 11:34 pm

Post by Miguelito » Fri Feb 19, 2010 10:53 pm

Have you cheched the page source before pushing Confirm order how the FailureURL is defined there?

The Finnish OpenCart Forum
"Real programmers don't document. If it was hard to write, it should be hard to understand."


Active Member

Posts

Joined
Sun Jan 10, 2010 10:11 pm

Post by babyewok » Sat Feb 20, 2010 2:24 am

Couldn't see any reference to it, but then there is also no explicit referrence to SuccessURL either and Sage Pay doean't seem to have a problem with that.

New member

Posts

Joined
Mon Oct 19, 2009 11:34 pm

Post by babyewok » Sat Feb 20, 2010 8:49 pm

Please help! I have to get this completed for my client ASAP!

New member

Posts

Joined
Mon Oct 19, 2009 11:34 pm

Post by Miguelito » Sat Feb 20, 2010 11:39 pm

Is your site available from internet/outside so I could take a look?

The Finnish OpenCart Forum
"Real programmers don't document. If it was hard to write, it should be hard to understand."


Active Member

Posts

Joined
Sun Jan 10, 2010 10:11 pm

Post by babyewok » Sat Feb 20, 2010 11:53 pm

No, not yet

New member

Posts

Joined
Mon Oct 19, 2009 11:34 pm

Post by babyewok » Sun Feb 21, 2010 12:15 am

What do you need to look at? Maybe I can post some code.

New member

Posts

Joined
Mon Oct 19, 2009 11:34 pm

Post by babyewok » Sun Feb 21, 2010 12:49 am

What is FailureURL supposed to be? Where is it suppoed to redirect to? I can see that SucessURL is:

Code: Select all

$data['SuccessURL'] = $this->url->https('payment/sagepay/success&order_id=' . $this->session->data['order_id']);
and there is a function for success in Sagepay.php.

I am using opencart v 1.4 by the way and have done nothing to the sagepay.php file except the edits mentioned earlier (and even before that the FailureURL wasn't working anyway)

New member

Posts

Joined
Mon Oct 19, 2009 11:34 pm

Post by Miguelito » Sun Feb 21, 2010 4:04 am

What about you sagepay.tpl file in catalog? Does it has the variable $FailureURL set as FailureURL?

The Finnish OpenCart Forum
"Real programmers don't document. If it was hard to write, it should be hard to understand."


Active Member

Posts

Joined
Sun Jan 10, 2010 10:11 pm

Post by babyewok » Sun Feb 21, 2010 7:42 pm

No. All it has is:

Code: Select all

<form action="<?php echo $action; ?>" method="post" id="checkout">
  <input type="hidden" name="VPSProtocol" value="2.23" />
  <input type="hidden" name="TxType" value="<?php echo $transaction; ?>" />
  <input type="hidden" name="Vendor" value="<?php echo $vendor; ?>" />
  <input type="hidden" name="Crypt" value="<?php echo $crypt; ?>" />
</form>
<div class="buttons">
  <table>
    <tr>
      <td align="left"><a onclick="location='<?php echo $back; ?>'" class="button"><span><?php echo $button_back; ?></span></a></td>
      <td align="right"><a onclick="$('#checkout').submit();" class="button"><span><?php echo $button_confirm; ?></span></a></td>
    </tr>
  </table>
</div>
I tried adding

Code: Select all

<input type="hidden" name="FailureURL" value="<?php echo $FailureURL; ?>" />
but that made no difference.

New member

Posts

Joined
Mon Oct 19, 2009 11:34 pm

Post by Miguelito » Sun Feb 21, 2010 8:21 pm

You don't need to add the FailureURL to the tpl file because it seems that all the data (including FailureURL) is put into an array called data and then somewhere in line 110 in sagepay.php there's:

Code: Select all

$this->data['crypt'] = base64_encode($this->simpleXor(http_build_query($data), $password));
So the actual problem is with lines 33-37 in sagepay.php which is:

Code: Select all

if ($this->request->get['route'] != 'checkout/guest_step_3') {
			$this->data['FailureURL'] = $this->url->https('checkout/payment');
		} else {
			$this->data['FailureURL'] = $this->url->https('checkout/guest_step_2');
		}
And it should be:

Code: Select all

if ($this->request->get['route'] != 'checkout/guest_step_3') {
			$data['FailureURL'] = $this->url->https('checkout/payment');
		} else {
			$data['FailureURL'] = $this->url->https('checkout/guest_step_2');
		}
Hope this solves your problem :)

The Finnish OpenCart Forum
"Real programmers don't document. If it was hard to write, it should be hard to understand."


Active Member

Posts

Joined
Sun Jan 10, 2010 10:11 pm

Post by babyewok » Sun Feb 21, 2010 8:40 pm

Well that worked just fine (could have sworn I had tried that before!).

Now I can go through to the simulator, but when I click OK (to return an order success result), I get this:

Notice: Undefined index: order_id in C:\UniServer5_5a\UniServer\www\Opencart\catalog\controller\payment\sagepay.php on line 146Notice: Undefined index: order_id in C:\UniServer5_5a\UniServer\www\Opencart\catalog\controller\payment\sagepay.php on line 190Warning: Cannot modify header information - headers already sent by (output started at C:\UniServer5_5a\UniServer\www\Opencart\index.php:67) in C:\UniServer5_5a\UniServer\www\Opencart\system\engine\controller.php on line 22

Thanks so much for your help so far.

New member

Posts

Joined
Mon Oct 19, 2009 11:34 pm

Post by Miguelito » Sun Feb 21, 2010 9:06 pm

I think the problem is with public function success which has a line:

Code: Select all

$this->model_checkout_order->confirm($this->request->get['order_id'], $this->config->get('sagepay_order_status_id'));
And it should be:

Code: Select all

$this->model_checkout_order->confirm($data['VendorTxCode'], $this->config->get('sagepay_order_status_id'));
<- this is ok if Sagepay returns the sent order_id in VendorTxCode. If it's some other variable then you should change that one instead of 'VendoTxCode'.

Also remember to change the same variable/field in the same function to:
$this->model_checkout_order->update($this->request->get['order_id'], $this->config->get('sagepay_order_status_id'), $message, FALSE);

The Finnish OpenCart Forum
"Real programmers don't document. If it was hard to write, it should be hard to understand."


Active Member

Posts

Joined
Sun Jan 10, 2010 10:11 pm

Post by babyewok » Sun Feb 21, 2010 9:08 pm

OK, so not claiming to actually know what on earth I am doing here, I looked at the teh files for som of the other payment gateways and changed

line 146 from:

Code: Select all

$this->model_checkout_order->confirm($this->request->get['order_id'], $this->config->get('sagepay_order_status_id'));


to:

Code: Select all

$this->model_checkout_order->confirm($this->session->data['order_id'], $this->config->get('sagepay_order_status_id'));
and line 191 from:

Code: Select all

$this->model_checkout_order->update($this->request->get['order_id'], $this->config->get('sagepay_order_status_id'), $message, FALSE);
to:

Code: Select all

$this->model_checkout_order->update($this->session->data['order_id'], $this->config->get('sagepay_order_status_id'), $message, FALSE);
which seemed to resolve that problem to reveal anoother! I then got and error about an undefined index 'name' in catalog/model/checkout/order.php. The line sin question were with in the Text mail section, both reading:

Code: Select all

$text .= $language->get('text_order_status') . ' ' . $order_status_query->row['name'] . "\n\n";
I simply commented them out as I couldn't see a a reference to 'text_order_status' in the HTML email section. That seemed to do the trick.

Were those lines left in by accident form an older version or do I need to figure out how to get them working again?
Last edited by babyewok on Sun Feb 21, 2010 9:14 pm, edited 1 time in total.

New member

Posts

Joined
Mon Oct 19, 2009 11:34 pm

Post by babyewok » Sun Feb 21, 2010 9:13 pm

We seemed to reply at teh same time there! I tried your solution - didn't seem to work, so maybe I actually got it right myself?!!

New member

Posts

Joined
Mon Oct 19, 2009 11:34 pm

Post by Miguelito » Mon Feb 22, 2010 4:48 am

Have you checked that your orders are inserted into Opencart only after the customer has completed the payment through Sagepay or are orders inserted into Opencart before the customer has completed the payment? Just wondering how your fix worked out in end-to-end perspective...

The Finnish OpenCart Forum
"Real programmers don't document. If it was hard to write, it should be hard to understand."


Active Member

Posts

Joined
Sun Jan 10, 2010 10:11 pm

Post by babyewok » Mon Feb 22, 2010 6:01 pm

Just went through SagePay simulator and returned a Not Authorised result and the order was not placed. Tried again as Success and the order was placed.

Seems to be working fine. Thanks for checking - you help has been invaluable!

New member

Posts

Joined
Mon Oct 19, 2009 11:34 pm

Post by httpsNOVICE » Wed Feb 24, 2010 12:35 am

for those of use that at some stage might get this problem, maybe a update could be put together to help who might need it!?

New member

Posts

Joined
Sat Jan 09, 2010 4:31 am

Post by babyewok » Wed Feb 24, 2010 3:21 am

OK, so now it's all working properly, I should really point out that the Failure URL does nothing but return the user to the 2nd page of the guest checkout - there is no actual warning to the user that there has been a problem. They woudl just end up going around in circles.

Is that what's supposed to happen?

New member

Posts

Joined
Mon Oct 19, 2009 11:34 pm

Post by babyewok » Tue Mar 02, 2010 12:32 am

So is there just not supposed to be any actual error message? FailureURL is just to satisfy SagePay?

New member

Posts

Joined
Mon Oct 19, 2009 11:34 pm
Who is online

Users browsing this forum: No registered users and 26 guests