8 my $cache = Cache::FileCache->new(
9 { cache_root => '/tmp', namespace => 'FCMB-Faker' }
13 'Successful', 'Failed', 'Pending', 'Cancelled', 'Not Processed',
14 'Invalid Merchant', 'Inactive Merchant', 'Inactive Order ID',
15 'Duplicate Order ID', 'Invalid Amount'
19 my $oid = $cgi->param('ORDER_ID');
21 # inefficient, but this is not production code, so who cares?
22 my ($txn) = grep { $_->{orderId} eq $oid }
23 map { $cache->get($_) } $cache->get_keys;
27 MerchantID => $txn->{mercId},
28 OrderID => $txn->{orderId},
29 StatusCode => $txn->{status},
30 Status => $status[$txn->{status}],
31 Amount => sprintf('%.2f', $txn->{amt}),
33 TransactionRef => $txn->{reference},
34 PaymentRef => sprintf('%06d', rand(1000000)),
35 ResponseCode => sprintf('%02d', rand(100)),
36 ResponseDescription => 'response description',
37 CurrencyCode => $txn->{currCode},
40 @out = ( Status => 'Invalid Order ID', StatusCode => '07' );
42 my $doc = XML::LibXML::Document->new;
43 my $root = $doc->createElement('UPay');
44 $doc->setDocumentElement($root);
46 my $name = shift @out;
47 my $value = shift @out;
48 my $node = $doc->createElement($name);
49 $node->appendChild( XML::LibXML::Text->new($value) );
50 $root->appendChild($node);
53 my $content = $doc->toString;
54 print $cgi->header('text/xml');