diff options
Diffstat (limited to 'faker/ConfirmPayment.cgi')
-rwxr-xr-x | faker/ConfirmPayment.cgi | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/faker/ConfirmPayment.cgi b/faker/ConfirmPayment.cgi new file mode 100755 index 0000000..d4be353 --- /dev/null +++ b/faker/ConfirmPayment.cgi @@ -0,0 +1,45 @@ +#!/usr/bin/perl -T + +my $LANDING_URL = + "http://localhost:2080/selfservice.cgi?action=finish_thirdparty_payment"; + +use CGI; +use URI; +use Date::Format 'time2str'; +use Cache::FileCache; +use strict; + +my $cache = Cache::FileCache->new( + { cache_root => '/tmp', namespace => 'FCMB-Faker' } +); + +my $landing = URI->new($LANDING_URL); + +my $cgi = CGI->new; +my $reference = $cgi->param('reference'); +my $txn = $cache->get($reference); + +if ( $cgi->param('submit') eq 'Cancel' ) { + $txn->{status} = 3; #canceled + $landing->query_form(_cancel => 1); +} else { + + # some information captured from the customer + # (in Real Life this would also be their credit card/bank account number) + $txn->{first} = $cgi->param('first'); + $txn->{last} = $cgi->param('last'); + # set status = the last digit of cents + # (0 = success) + my $cents = ($txn->{amt} - int($txn->{amt})) * 100; + $txn->{status} = $cents % 10; + $txn->{date} = time2str('%Y-%m-%d', time); + + $landing->query_form( + $landing->query_form, + 'OrderID' => $txn->{orderId}, + 'TransactionReference' => $reference + ); +} +# update the cache +$cache->set($reference => $txn); +print $cgi->redirect($landing); |