X-Git-Url: http://git.freeside.biz/gitweb/?p=Business-OnlinePayment-Cardcom.git;a=blobdiff_plain;f=Cardcom.pm;h=de8f4117c918c8be6f9cad34934996ccba59dfdd;hp=cd8b2a8c187d52a309aa8244daa14dea31a837b1;hb=dd8ab8c86706923f32a005fe05537194aad3e929;hpb=691bb9412fd331e9cda0013df41e2fb418d97674 diff --git a/Cardcom.pm b/Cardcom.pm index cd8b2a8..de8f411 100644 --- a/Cardcom.pm +++ b/Cardcom.pm @@ -5,11 +5,11 @@ use Carp; use Tie::IxHash; use Business::OnlinePayment 3; use Business::OnlinePayment::HTTPS 0.03; -use Data::Dumper; +#use Data::Dumper; use vars qw($VERSION $DEBUG @ISA); @ISA = qw(Business::OnlinePayment::HTTPS); -$VERSION = '0.01'; +$VERSION = '0.02'; $DEBUG = 0; sub set_defaults { @@ -24,19 +24,26 @@ sub set_defaults { # -Identity number # -Configurable currency # -Configurable deal code -# -Refunds or whatever this thing calls them sub submit { my($self) = @_; + #warn Dumper($self) if $DEBUG > 1; + $self->remap_fields( card_number => 'cardnumber', amount => 'Sum', login => 'Username', + password => 'userpassword', cvv2 => 'cvv', ); - die "invalid action" unless - $self->{_content}{'action'} =~ /^\s*normal\s*authorization\s*$/i; + my $action = $self->{_content}{'action'}; + if ( $action =~ /^\s*credit\s*$/i ) { + $self->{_content}{dealtype} = 51; + $self->{_content}{credittype} = 1; + } elsif ( $action !~ /^\s*normal\s*authorization\s*$/i ) { + die "invalid action"; + } $self->{_content}{'expiration'} =~ /^(\d+)\D+\d*(\d{2})$/ or croak "unparsable expiration ". $self->{_content}{expiration}; @@ -51,6 +58,16 @@ sub submit { $self->terminalnumber =~ /^\d+$/ or die "invalid TerminalNumber"; $self->{_content}{TerminalNumber} = $self->terminalnumber; + $self->required_fields( + qw( login password TerminalNumber card_number amount ) + ); + + if($self->test_transaction) { + $self->{_content}{'Username'} = 'gali'; + $self->{_content}{'userpassword'} = '7654321'; + $self->{_content}{'TerminalNumber'} = '1000'; + } + tie my %fields, 'Tie::IxHash', $self->get_fields( $self->fields ); my $post_data = join('&', map "$_=$fields{$_}", keys %fields ); warn "POSTING: ".$post_data if $DEBUG > 1; @@ -76,9 +93,10 @@ sub submit { my $authorization = $2; my $message = $3; - $self->authorization($authorization); + $self->result_code($result); if ( $result == 0 ) { $self->is_success(1); + $self->authorization($authorization); } else { $self->is_success(0); $self->error_message($message); @@ -95,11 +113,30 @@ sub fields { cardvalidityyear cardvaliditymonth Username + userpassword languages + dealtype + credittype cvv ); } +sub _info { + { + 'info_compat' => '0.01', + 'gateway_name' => 'Cardcom', + 'gateway_url' => 'http://www.cardcom.co.il', + 'module_version' => $VERSION, + 'supported_types' => [ 'CC' ], + 'token_support' => 0, # well technically the gateway supports it, but we haven't implemented it + 'test_transaction' => 1, + 'supported_actions' => [ + 'Normal Authorization', + 'Credit', + ], + }; +} + 1; __END__ @@ -116,16 +153,16 @@ Business::OnlinePayment::Cardcom - Cardcom backend module for Business::OnlinePa # One step transaction, the simple case. #### - my $tx = new Business::OnlinePayment("Cardcom"); + my $tx = new Business::OnlinePayment("Cardcom", 'TerminalNumber'=>1234 ); $tx->content( type => 'CC', login => 'Cardcom Username', password => 'Cardcom Password', - terminalnumber => 'Cardcom Terminal Number', action => 'Normal Authorization', amount => '49.95', card_number => '4005550000000019', expiration => '08/06', + cvv2 => '123', ); $tx->submit(); @@ -139,25 +176,34 @@ Business::OnlinePayment::Cardcom - Cardcom backend module for Business::OnlinePa =head2 CC -Content required: type, login, password, action, amount, card_number, expiration, terminalnumber. +Content required: type, login, password, action, amount, card_number, expiration. =head1 PREREQUISITES - URI::Escape Tie::IxHash - Net::SSLeay _or_ ( Crypt::SSLeay and LWP ) - =head1 DESCRIPTION For detailed information see L. =head1 AUTHOR -Erik Levinson +Original Author: Erik Levinson + +Current Maintainer: Ivan Kohler C<< >> =head1 SEE ALSO perl(1). L. +=head1 ADVERTISEMENT + +Need a complete, open-source back-office and customer self-service solution? +The Freeside software includes support for credit card and electronic check +processing, integrated trouble ticketing, and customer signup and self-service +web interfaces. + +http://freeside.biz/freeside/ + + =cut