[ic] help with payment/gateway integration.

Dan interchange-users@interchange.redhat.com
Fri Feb 15 01:53:00 2002


On Thu, 2002-02-14 at 15:14, Joachim Leidinger wrote:
> Dan wrote:
> ....
> .... 
> > I could just catch the data and translate it into a form which the user
> > would have to submit...but this increases the number of clicks to
> > process an order in an already long process. In addition this is after
> > the CC has been approved and should be bullet/user-proof.
> 
> If the callback-IC-Page has the name like "CallBackfromtheGateway.html",
> you can finish the order with
> 
> You can submit the order with
> 
> [if scratch return-message-of-the-gateway =~ /success/]
<snip see below>
>  [bounce href="[scratch url]"]
> [/tmp]
> [/if]
> 
> by IC and IC finish the order without any clicks of process.
> (Big thanks to Racke for the hint!)
> 
.....
> I hope, you get the picture! :-)
>  

Thank you Joachim,

I am getting the picture. I have gotten this scenerio (see code below)
to work assuming that the user does everything asked of him. It would be
more user proof to be able to do this from the gateway's "silent post".
When the gateway processes the CC it sends a single POST request to a
seperate backend page. This page needs to be able to hook into [area
href=process ...] w/o the [bounce]. As I understand it, [bounce] depends
on the HTTP 302 redirect and thus requires a UserAgent (read Browser)
which understands HTTP 1.1. Since the "silent post" is a one shot
process which only hangs around long enough to recieve the code 200
success there is no UserAgent for [bounce] to work with.

I have implemented a usertag for posting URLs using LWP::UserAgent.
I get two different responses depending on how I call the URL. One
reports success (using [bounce]) and the other a missing page (using
post-url)

So the question is. How can I hook into the form processor by using the
usertag [post-url] or any other method. 

Here is the code as it currently works with [bounce]
[perl arg="cgi scratch"]
        $Safe{'scratch'}->{"mv_session_id"}  = $Safe{'cgi'}->{"USER1"};
        $Safe{'scratch'}->{"approvalcode"}  = $Safe{'cgi'}->{"RESPMSG"};
        $Safe{'scratch'}->{"tmp1"} = "";
[/perl]
...
[if scratch approvalcode =~ /Approved/]
...
	[seti url][area href=process form="
		mv_todo=submit
		mv_payment=Credit Card
		mv_session_id=[mv_session_id]
		mv_order_route=log main copy_user
		mv_order_report=ord/report
		mv_order_receipt=ord/receipt"]
	[/seti]
...
	[bounce href="[scratch url]"]
[/if]

replacing 
[bounce href="[scratch url]"]
with
[post-url url="[scratch url]"]
leads to a call to special-pages/missing.
(I have attached the code for [post-url] below.

Any ideas on implementing this would be much appreciated.

Many thanks

-dan





--------------------------
UserTag post-url Order url
UserTag post-url AddAttr
UserTag post-url Documentation <<EOD

usage: [post-url url="valid_url"]

Uses the LWP libraries to fetch a URL and return the contents.
EOD

UserTag post-url Routine <<EOR
sub {
        my ($url, $opt) = @_;
        eval {
                require HTTP::Request::Common;
                require LWP::UserAgent;
        };
        if($@) {
                ::logError("Cannot use post-url tag, no LWP modules
installed.");
                return undef;
        }
        my($url) = @_;
        print("post-url url $url\n") if $Global::DEBUG;
        my $string = "";
        $url = "http://$url" unless ($url =~ /^\w+:\/\//);
        my $ua = new LWP::UserAgent;
        my $request = new HTTP::Request 'POST', $url;
        my $response = $ua->request($request);
        if ($response->is_success)
        {
                $string = $response->content();
        }
        return $string;
}
EOR