1 package Business::OnlinePayment::Cardcom;
6 use Business::OnlinePayment 3;
7 use Business::OnlinePayment::HTTPS 0.03;
9 use vars qw($VERSION $DEBUG @ISA);
11 @ISA = qw(Business::OnlinePayment::HTTPS);
18 $self->server('secure.cardcom.co.il');
19 $self->path('/BillGoldPost.aspx');
25 # -Configurable currency
26 # -Configurable deal code
30 #warn Dumper($self) if $DEBUG > 1;
33 card_number => 'cardnumber',
36 password => 'userpassword',
40 my $action = $self->{_content}{'action'};
41 if ( $action =~ /^\s*credit\s*$/i ) {
42 $self->{_content}{dealtype} = 51;
43 $self->{_content}{credittype} = 1;
44 } elsif ( $action !~ /^\s*normal\s*authorization\s*$/i ) {
48 $self->{_content}{'expiration'} =~ /^(\d+)\D+\d*(\d{2})$/
49 or croak "unparsable expiration ". $self->{_content}{expiration};
50 my( $month, $year ) = ( $1, $2 );
51 $month = '0'. $month if $month =~ /^\d$/;
52 $self->{_content}{cardvalidityyear} = $year;
53 $self->{_content}{cardvaliditymonth} = $month;
55 $self->{_content}{amount} = sprintf('%.2f', $self->{_content}{amount} );
56 $self->{_content}{languages} = 'en';
58 $self->terminalnumber =~ /^\d+$/ or die "invalid TerminalNumber";
59 $self->{_content}{TerminalNumber} = $self->terminalnumber;
61 $self->required_fields(
62 qw( login password TerminalNumber card_number amount )
65 if($self->test_transaction) {
66 $self->{_content}{'Username'} = 'gali';
67 $self->{_content}{'userpassword'} = '7654321';
68 $self->{_content}{'TerminalNumber'} = '1000';
71 tie my %fields, 'Tie::IxHash', $self->get_fields( $self->fields );
72 my $post_data = join('&', map "$_=$fields{$_}", keys %fields );
73 warn "POSTING: ".$post_data if $DEBUG > 1;
75 my( $page, $response, @reply_headers) = $self->https_post( $post_data );
77 if ($response !~ /^200/) {
79 $response =~ s/[\r\n]+/ /g; # ensure single line
81 my $diag_message = $response || "connection error";
85 $self->server_response($page);
87 unless ( $page =~ /^(\d+);(\d+);(.*?)$/ ) {
88 die "unparsable response received from gateway" .
89 ( $DEBUG ? ": $page" : '' );
93 my $authorization = $2;
96 $self->result_code($result);
99 $self->authorization($authorization);
101 $self->is_success(0);
102 $self->error_message($message);
126 'info_compat' => '0.01',
127 'gateway_name' => 'Cardcom',
128 'gateway_url' => 'http://www.cardcom.co.il',
129 'module_version' => $VERSION,
130 'supported_types' => [ 'CC' ],
131 'token_support' => 0, # well technically the gateway supports it, but we haven't implemented it
132 'test_transaction' => 1,
133 'supported_actions' => [
134 'Normal Authorization',
146 Business::OnlinePayment::Cardcom - Cardcom backend module for Business::OnlinePayment
150 use Business::OnlinePayment::Cardcom;
153 # One step transaction, the simple case.
156 my $tx = new Business::OnlinePayment("Cardcom", 'TerminalNumber'=>1234 );
159 login => 'Cardcom Username',
160 password => 'Cardcom Password',
161 action => 'Normal Authorization',
163 card_number => '4005550000000019',
164 expiration => '08/06',
169 if($tx->is_success()) {
170 print "Card processed successfully: ".$tx->authorization."\n";
172 print "Card was rejected: ".$tx->error_message."\n";
175 =head1 SUPPORTED TRANSACTION TYPES
179 Content required: type, login, password, action, amount, card_number, expiration.
187 For detailed information see L<Business::OnlinePayment>.
191 Original Author: Erik Levinson
193 Current Maintainer: Ivan Kohler C<< <ivan-cardcom@freeside.biz> >>
195 perl(1). L<Business::OnlinePayment>.
199 Need a complete, open-source back-office and customer self-service solution?
200 The Freeside software includes support for credit card and electronic check
201 processing, integrated trouble ticketing, and customer signup and self-service
204 http://freeside.biz/freeside/