Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

SecureTrading COM

by $code or die (Deacon)
on Nov 02, 2000 at 18:38 UTC ( #39637=sourcecode: print w/ replies, xml ) Need Help??

Category: Win32 Stuff
Author/Contact Info $code or die
Description: Repost - I thought that the code tags would be added automatically because the box below is expecting code! My mistake.

A example script to use SecureTrading in Perl on Win32 systems. SecureTrading does online credit card authorization. The perl scripts on their site only run on *nix systems. They didn't reply to my offer of them putting this example on their website :(

It uses Win32::OLE, so you will need to download the ASP COM object from securetrading.com for this script to work.

Before you flame me - I don't work for securetrading and this is NOT an advert :-). I worked ALL last night getting this to work because I refused to use ASP instead of Perl, and I had no option about the platform unfortunately.
use Win32::OLE;

###################################################################
# Create a SecureTrading Object using Win32::OLE
$stm = Win32::OLE->new ("SecureTrading.STMerchant") || die "CreateObje
+ct: $!";    # 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);

Comment on SecureTrading COM
Download Code
RE: SecureTrading COM
by $code or die (Deacon) on Nov 02, 2000 at 18:42 UTC
    Dear Monks,

    I appologise for the multiple posts of this code. It's my first post to the code section and I made a boo-boo.

    Thanks, $code or die

Back to Code Catacombs

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: sourcecode [id://39637]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (9)
As of 2014-08-20 07:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (107 votes), past polls