use Win32::OLE; ################################################################### # Create a SecureTrading Object using Win32::OLE $stm = Win32::OLE->new ("SecureTrading.STMerchant") || die "CreateObject: $!"; # create ST object my %Result; # SecureTrading Response Codes $Result{authorised} = 1; # ... $Result{declined} = 2; # ... $Result{error} = 3; # ... $Result{other} = 4; # ... $stroot = "."; # Path to certificate files ################################################################### # SecureTrading merchant reference for this site $stm->{SiteReference} = "T16002"; ################################################################### # SecureTrading certificate files $stm->{CertificateFile} = "$stroot/pem/xyzcotestcert.pem"; $stm->{PrivateKeyFile} = "$stroot/pem/xyzcotestkey.pem"; $stm->{ServerCAFile} = "$stroot/pem/testserverca.pem"; $stm->{GatewaysFile} = "$stroot/testgateways.txt"; ################################################################### # Open Connection $stm->Open(); ################################################################### # Transaction information $stm->{TransactionType} = "AUTHORIZE"; $stm->{CardType} = "VISA"; # Use this number for rejection = "4242 4242 4242 4242" $stm->{CardNumber} = "4111 1111 1111 1111"; $stm->{ExpiryDate} = "02/99"; $stm->{IssueNumber} = "0"; $stm->{Amount} = "1500"; $stm->{Currency} = "GPB"; ################################################################### # Settlement Information $stm->{SettleNow} = 1; ################################################################### # CardHolder Information $stm->{CardHolderPresent} = 1; $stm->{CardHolderEmail} = "test\@test.com"; $stm->{CardHolderCountry} = "UK"; $stm->{CardHolderAddress} = "A test address; somewhere; here;"; $stm->{CardHolderTelephone} = "01233 456 789"; $stm->{CardHolderName} = "Ted tester"; ################################################################### # Internet information about card holder $stm->{CardHolderIp} = $ENV{'REMOTE_IP'}; $stm->{CardHolderBrowser} = $ENV{'BROWSER'}; ################################################################### # Merchant information about order $stm->{MerchantOrderReference} = "TEST-0001#a"; $stm->{MerchantOrderInfo} = "A test transaction"; ################################################################### # Create the STMerchant details print "Creating Transation...\n"; $stm->Create(); ################################################################### # Send Transaction print "Sending Transation...\n"; $stm->Send(); print "Transaction Sent.\n\n"; ################################################################### # Display results print "**** RESULT ****\n"; print "Reference Number: ", $stm->{ReferenceNumber}, "\n"; if ($stm->{result} == $Result{authorised}) { print "Transaction: Authorized\n"; print "Auth Code: ", $stm->{AuthCode}, "\n"; print "Confidence Rating: ", $stm->{ConfidenceRating}, "\n"; } elsif ($stm->{result} == $Result{declined}) { print "Transaction: Declined\n"; } elsif ($stm->{result} == $Result{error}) { print "There was an error in authorizing the transaction\n"; print "Error : ", $stm->{Error}, "\n"; } else { print "There was an unknown error!!\n"; } ################################################################### # Close the connection to the SecureTrading Module $stm->Close($stm);