summaryrefslogtreecommitdiff
path: root/faker/ConfirmPayment.cgi
diff options
context:
space:
mode:
authorMark Wells <mark@freeside.biz>2013-06-28 16:36:47 -0700
committerMark Wells <mark@freeside.biz>2013-06-28 16:36:47 -0700
commit472f07098c2e10ac025b132df098f4b51c14adb1 (patch)
treefb6f5bb33ff55b658b298f3cd00316c054225b82 /faker/ConfirmPayment.cgi
start
Diffstat (limited to 'faker/ConfirmPayment.cgi')
-rwxr-xr-xfaker/ConfirmPayment.cgi45
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);