Hi,

I just tried to capture a order (given with quickpay on website in test mode, and quickpay.dk admin in test mode) and got these errors:
# amount didn't pass validation.
# Request message didn't pass validation.
# warning: preg_match() expects parameter 2 to be string, array given in /home/www/customers/lpp6/html/includes/bootstrap.inc on line 1054.
# Capture failed, type: ,

the order has looks fine, and has amount 184,00 kr.

Tell me what I can dpm to help solve this

Comments

xen’s picture

Status: Active » Postponed (maintainer needs more info)

If you're still using the patch from #779512, then that's your problem. Capture uses the order_total set there, so if you've commented that out, it'll fail.

klavs’s picture

I don't see how it could possibly be the problem.

I just tried to dpm($order) after the uncommented code - and the object has order_total set correctly (as it should).

The code I commented out is IMHO plainly wrong - once an order is finialized - you should NEVER change the total - or unless you're actually editing the order - not in loading of the order.

I dsm'ed the variables you call quickpay_capture with:
trans:20769544-total:184.00000-

So it gets the right information - something else is wrong.

Perhaps the test mode thing?

Unrelated - the dpm was run 20+ times - just by pressing the caputure button. I've seen this "multiple calls to a function" thing in Drupal before - it seems something is absurdly wrong.

Unless I'm missing why it is "normal" to load an order 20+ times :)

klavs’s picture

It seems the problem (atleast one of them) is here:
$currency = variable_get('quickpay_default_currency', NULL);

This is returning NULL.

I can find no way to set this quickpay default currency?

I just grep'ed the code - it's only set in a quickpay.test file - which obviously isn't used by users.

It should probably go in a quickpay.install file

klavs’s picture

After setting this variable it worked like a charm ;)

xen’s picture

How about the currency? It's used to determine the correct multiplier for the amount sent to QuickPay.

> The code I commented out is IMHO plainly wrong - once an order is finialized - you should NEVER change the total - or unless you're actually editing the order - not in loading of the order.

Perhaps not, but maybe the order_total in the uc_order table can get out of sync with reality. I would't put it past the UC developers to fix it in order_load instead of ensuring it doesn't.

> Perhaps the test mode thing?

Shouldn't. I always run in test mode when developing.

> Unrelated - the dpm was run 20+ times - just by pressing the caputure button. I've seen this "multiple calls to a function" thing in Drupal before - it seems something is absurdly wrong.

I get 12 calls to uc_order_load just viewing the payment tab with the capture button. Apparently there's no static caching of the order object like there is in EC4.

> Unless I'm missing why it is "normal" to load an order 20+ times :)

On par with the course for UC.

xen’s picture

Title: capture via payments doesn't work » Enforce supplyingn of currency and remove quickpay_default_currency.
Assigned: Unassigned » xen
Status: Postponed (maintainer needs more info) » Active

Ah, it used to be in the settings. But the plan was to remove it and force UC/EC to supply it themselves as they're supposed to know what currency is in use.

Obviously, quickpay_capture, et al. should error out when the caller fails to do this.

klavs’s picture

Well UC does supply a default currency code.

You'd get that - by doing this: variable_get('uc_currency_code', 'USD');

in UC it defaults to USD - you'd probably want to default it to DKK - but I can't see how it could avoid being set :)

xen’s picture

I spoke too soon. It doesn't make sense to have to supply currency for authorize, as it was specified in the capture. However, QP requires it (what happens if you actually try to capture in another currency, is undefined). And UC doesn't store it.

Using UCs default currency isn't proper (it might have changed since the payment was authorized), but will have to do.

xen’s picture

Status: Active » Fixed

Fixed in head. The variable shouldn't be necessary anymore.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.