Name
Business::CSI - Perl extension for Card Services International
The Example
use strict;
use Business::CSI qw/ :simple :mail /;
my $max_tries = 5;
add_settings({
'csi_config'=> '666999',
'csi_host' => 'secure.linkpt.net',
'csi_port' => '1139',
'csi_key' => '/etc/keyfile.pem',
});
add_settings({
'card_number' => '1234 5678 1234 5678',
'card_expr_m' => '07',
'card_expr_y' => '07',
'name_on_card' => 'Some Looser',
'email_addy' => 'looser@aol.com',
});
add_item("A happy meal", 0.5); # you don't need to use these.
add_item("A sad meal", 0.5); # but it makes the line items show
# in the admin/customer e-mail
add_settings({
'grand_total' => calc_total, # note that calc_total does not account
'real' => 0, # for or affect the ship/sub/tax totals
});
my $count = 0;
my %result = ();
{
%result = simple_transaction;
if(not $result{connected}) {
print "$result{error_type} => $result{error}\n";
die "Your order fail'd $max_tries times ... I give up." if $max_tries <= ++$count;
redo;
}
}
# at this point, we're successfull
customer_notification_mail_settings({
# see the documentation below if you want to use templates.
'template' => "filename.txt",
'BCC' => "sales@our.downtown.com",
});
customer_notification_mail(1); # generally you wouldn't use the 1, see below
foreach my $k (keys %result) {
print "\$result{$k} = $result{$k}\n";
}
%results population
Success
These are all retrieved from a cc_order_get(order,
OrderField_R_Something ... function call. These values are well
documented in the linkpoint api so if you're wondering what values
these can take on, consult the aforementioned documentation.
'approval' => $result[0], # OrderField_R_Approved
'ref' => $result[1], # OrderField_R_Ref
'code' => $result[2], # OrderField_R_Code
'ordernum' => $result[3], # OrderField_R_Ordernum
'error' => $result[4], # OrderField_R_Error
'time' => $result[5], # OrderField_R_Time
'connected' => 1
Failure
'error_type' => $result[0], # any of process or setrequest
'error' => $result[1], # the error returned from CSI
'connected' => 0
The error_type is the stage of the order process, either 'process' or
'setrequest'. Again, consult the linkpoint api docs to see what
values can be returned.
Settings
Settings - The available settings
csi_config csi_key csi_host csi_port cust_id
order_id name_on_card email_addy card_number card_expr_m
card_expr_y sub_total tax_total ship_total grand_total real
Settings - The defaults
'csi_host' => 'secure.linkpt.net',
'csi_port' => '1139',
'cust_id' => 'imcertainihavenoidea',
'order_id' => ('order' . '.'. time . '.' . $$),
'email_addy' => 'unknown@aol.com',
'real' => 0,
'ship_total' => 0,
'sub_total' => 0,
'tax_total' => 0,
Settings - Extra Info
Unless otherwise listed, they all default to undef.
Note that 'csi_config' and 'csi_key' are really really needed.
'csi_config' is your store number (or whatever they call it now).
'csi_key' is your keyfile.pem.
Another important setting is 'real'. 'real' should be set to
0 while you're practicing -- not $real, and 1 when you're ready
to do it for real. ;)
Email settings Note that in order ot use the Email functions, you must put a ':mail' in your use line -- as seen in the example.
customer_notification_mail;
This is the function that actually sends a mail to the customer.
If you want it to use the localhost mail gateway (sendmail?), then
call it like it was called in the example above.
If (for some reason) you wish to use the customers own mail gateway,
as discovered through the MX records for the domain, call the function
with a 1 as the argument:
customer_notification_mail(1);
template => "filename.txt"
If this funciton is used, the customer_notification_mail function will
use the named template to do the notification. SUMMARY and ITEMIZED_LIST
should appear on a line by themselves somewhere in the template. They
get replaced appropriately.
from => "someone", from => "someone@something.tld"
Use this to set the email address the mail comes from (postmaster by
default). Business::CSI will attempt to appened a logical fqdn if
it can't find an [@] in the address.
from_full => "Some Dude Department"
With this you can set the Full Name for the from: header.
This is reccomended ... for asthetic reasons.
subject => "Your Order with Some Damn Co."
The subject line (if not specified) will be:
'Subject: Your order (#X)'
Where X will get replaced with the order # you specified.
BCC => "someoneelse@at.our.co"
Our sales department keeps track of all our orders in a spreadsheet.
I think that's kinda dumb, and offered to do a database thing.
*shrug* They'd rather get a copy of this. That's what this is
for.
To do
1. Billing Shipping info
2. Credit card number sanity checks using Business::CreditCard
3. ... I am accepting requests especially if you wanna throw me
code snippits. ;)
4. More documentation. As people ask me questions, I make more and more
less not clear. ;)
Known Bugs
None... they're fixed
Unknown Bugs
None AFAIK.
Credits
"David Deppner" <dave@psyber.com>:
1. The double/float bugfix mentioned in the Changes log.
2. Insisted on a README.
Author
Jettero Heller <jettero@voltar.org>
See Also
perl(1).