Subject: | problem parsing multiple errors in response |
A response with multiple errors is causing the following error to be
reported:
Bad index while coercing array into hash at
/usr/local/asp/arcos/lib/Business/OnlinePayment/Vanco.pm line 434.
Here is a snippet of a response with two errors:
<Response>
<Errors>
<Error>
<ErrorCode>495</ErrorCode>
<ErrorDescription>CustomerAddress1 Field Contains Invalid
Characters</ErrorDescription>
</Error>
<Error>
<ErrorCode>495</ErrorCode>
<ErrorDescription>CardBillingAddr1 Field Contains Invalid
Characters</ErrorDescription>
</Error>
</Errors>
</Response>
XMLIn gives the array ref at
$response->{Response}->{Errors}->{Error}
not at
$response->{Response}->{Errors}
where we are currently looking.
A small change has this fixed in my local copy:
diff -rub Business-OnlinePayment-Vanco-0.024/Vanco.pm
Business-OnlinePayment-Vanco-0.025/Vanco.pm
--- Business-OnlinePayment-Vanco-0.024/Vanco.pm 2009-01-08
12:28:34.000000000 -0500
+++ Business-OnlinePayment-Vanco-0.025/Vanco.pm 2009-01-16
12:29:16.000000000 -0500
@@ -421,8 +421,8 @@
&& !exists($response->{Response}->{Errors})) { # so much for docs
$error->{ErrorDescription} = '';
$error->{ErrorCode} = '';
- }elsif (ref($response->{Response}->{Errors}) eq 'ARRAY') {
- $error = $response->{Response}->{Errors}->[0];
+ }elsif (ref($response->{Response}->{Errors}->{Error}) eq 'ARRAY') {
+ $error = $response->{Response}->{Errors}->{Error}->[0];
}else{
$error = $response->{Response}->{Errors}->{Error};
}