Avatar of RobbieSnr
RobbieSnrFlag for United Kingdom of Great Britain and Northern Ireland

asked on 

Using HTTP::Status responses that are not exported by default

I have a Perl callback script that is used to check whether a payment made by a customer to a financial company has been accepted or not. The customer makes a credit card payment to this company, it sends me details of the transaction and my callback script returns this information to the company so that it can verify it and then pass back a note of whether the transaction was approved or rejected. I'm using LWP::UserAgent to contact the company's server.

When I receive the information back I first of all check whether the response is 'is_error'. I see that this doesn't tell me whether there was a problem at my end or at the company's, and that there are two alternative responses, 'is_server_error' and 'is_client_error', that do distinguish. However the HTTP::Status manpage says that these are not exported by default. My question is - what do I have to do if I want to test for either of these responses?
Perl

Avatar of undefined
Last Comment
RobbieSnr
ASKER CERTIFIED SOLUTION
Avatar of Perl_Diver
Perl_Diver

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of RobbieSnr
RobbieSnr
Flag of United Kingdom of Great Britain and Northern Ireland image

ASKER

Can I please ask one other question.

I've exposed the two error messages as you suggest and produced a situation where my code is sending no parameters to the financial company when some are expected. When I check the return code it's coming back just as is_error and a check for both is_client_error and is_server_error fails - I was hoping that it would show up as a client error. Is that what you would expect - are these two codes only returned when  a physical error has occurred in the process?

Thanks.
Avatar of Perl_Diver
Perl_Diver

Is the data sent in the query string (/script.pl?name=value&name=value) or as post data using a CGI form? Either way that is where I would first check to make sure everything is as it should be.
Avatar of RobbieSnr
RobbieSnr
Flag of United Kingdom of Great Britain and Northern Ireland image

ASKER

I've not got a problem with my code, which is there to be activated by the financial institution. They send check and other parameters to this script which then returns them to the institution using LWP::UserAgent. If they're happy with what is returned to them the return code they send back tells me whether the financial transaction that my customer has made with them has succeeded or not. This has been working fine so I've no problems with my code.

There have however been a couple of cases recently where a robot activated my script without any parameters so the details weren't accepted by the financial institution and the return code I picked up was 'is_error'. What I was trying to do was to distinguish in my code between this situation and the one where the fault lay at the financial institution's end, by checking for 'is_client_error' and 'is_server_error' instead of just 'is_error', so that I could send the appropriate message to the folk at my end.

Hope that explains what is happeneing and what I was trying to do.
Perl
Perl

Perl is a high-level, general-purpose, interpreted, dynamic programming languages with over 25 years of development. Perl 5 runs on over 100 platforms from portables to mainframes and is suitable for both rapid prototyping and large-scale development projects. Perl gained widespread popularity as a Common Gateway Interface (CGI) scripting language, in part due to its regular expression and string parsing abilities. In addition to CGI, Perl is used for graphics programming, system administration, network programming, finance, bioinformatics, and other applications.

26K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo