Subject: | Posting a return without a credit card |
Hi Ivan,
Thanks for the recent update to the module to work with the latest API and stop forcing the test server.
I have run into a situation where I need post a return for an order but do not want to keep the credit card on file. According to the tech support rep at LinkPoint, there are credits and returns. I've tried to explain the difference in the patch I've attached to this post.
In addition to the new 'order_number' key, I also added a 'debug' key to control when the warnings are printed to my log. I'd rather not have credit card info printed to a plaintext log by default. However, this output is extremely useful when trying to debug code. If you have a better solution, please improve my patch. I looked at other modules but none had any info about debugging in their POD. I updated the POD with these details.
Please review and comment. I'd love to see this patch be included in the next release.
Regards,
William
--- /tmp/Business-OnlinePayment-LinkPoint-0.04/LinkPoint.pm Thu Jun 24 11:32:33 2004
+++ perl5/Business/OnlinePayment/LinkPoint.pm Wed Oct 20 16:53:27 2004
@@ -99,7 +99,8 @@
my %content = $self->content;
my($month, $year);
- unless ( $content{action} eq 'POSTAUTH' ) {
+ unless ( $content{'action'} eq 'POSTAUTH' ||
+ ( $content{'action'} eq 'CREDIT' && exists $content{'order_number'} )) {
if ( $self->transaction_type() =~
/^(cc|visa|mastercard|american express|discover)$/i
@@ -139,6 +140,7 @@
cardexpmonth => \$month,
cardexpyear => \$year,
chargetotal => 'amount',
+ oid => 'order_number',
);
my $lperl = new LPPERL;
@@ -152,16 +154,18 @@
result
chargetotal cardnumber cardexpmonth cardexpyear
name email phone addrnum city state zip country
+ oid
/);
- $post_data{'ordertype'} = $content{action};
-
+ $post_data{'ordertype'} = $content{action};
if ( $content{'cvv2'} ) {
$post_data{cvmindicator} = 'provided';
$post_data{cvmvalue} = $content{'cvv2'};
}
- warn "$_ => $post_data{$_}\n" foreach keys %post_data;
+ if (exists $content{'debug'} && $content{'debug'}) {
+ warn "$_ => $post_data{$_}\n" foreach keys %post_data;
+ }
my %response;
#{
@@ -170,7 +174,9 @@
#}
%response = $lperl->curl_process(\%post_data);
- warn "$_ => $response{$_}\n" for keys %response;
+ if (exists $content{'debug'} && $content{'debug'}) {
+ warn "$_ => $response{$_}\n" for keys %response;
+ }
if ( $response{'r_approved'} eq 'APPROVED' ) {
$self->is_success(1);
@@ -232,7 +238,8 @@
=head1 DESCRIPTION
-For detailed information see L<Business::OnlinePayment>.
+For detailed information see L<Business::OnlinePayment>. Also see the
+LinkPoint API User Manual at http://www.linkpoint.com/support.
=head1 COMPATIBILITY
@@ -241,6 +248,38 @@
Version 0.4 of this module has been updated for the LinkPoint Perl Wrapper
version 3.5.
+
+=head1 RETURNS AND CREDITS
+
+The LinkPoint API supports returns and credits. A credit allows you to return
+money to any credit card. Set the action to 'CREDIT' and include the cc
+number, expiration date and amount in the content method.
+
+A return allows you to post a credit back to the buyer without having to
+submit credit card information. This type of transaction is useful when you do
+not want to store credit card details on your server. Simply submit a
+transaction with the action as 'CREDIT' and the order_number set to the value
+returned by the original purchase (this can be retrieved using the
+$tx->order_number() method after a successful sale). For example:
+
+ $tx->content(
+ action => 'credit',
+ order_number => $order_number,
+ );
+ $tx->submit();
+
+=head1 DEBUGGING
+
+To enable debugging messages in your error log (STDERR), set debug to a true
+value when setting the content:
+
+ $tx->content(
+ type => 'VISA',
+ action => 'Normal Authorization',
+ ....
+ debug => 1,
+ );
+
=head1 BUGS