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
27 # -Refunds or whatever this thing calls them
31 warn Dumper($self) if $DEBUG > 1;
34 card_number => 'cardnumber',
37 password => 'userpassword',
41 die "invalid action" unless
42 $self->{_content}{'action'} =~ /^\s*normal\s*authorization\s*$/i;
44 $self->{_content}{'expiration'} =~ /^(\d+)\D+\d*(\d{2})$/
45 or croak "unparsable expiration ". $self->{_content}{expiration};
46 my( $month, $year ) = ( $1, $2 );
47 $month = '0'. $month if $month =~ /^\d$/;
48 $self->{_content}{cardvalidityyear} = $year;
49 $self->{_content}{cardvaliditymonth} = $month;
51 $self->{_content}{amount} = sprintf('%.2f', $self->{_content}{amount} );
52 $self->{_content}{languages} = 'en';
54 $self->terminalnumber =~ /^\d+$/ or die "invalid TerminalNumber";
55 $self->{_content}{TerminalNumber} = $self->terminalnumber;
57 $self->required_fields(
58 qw( login password TerminalNumber card_number amount )
61 if($self->test_transaction) {
62 $self->{_content}{'Username'} = 'gali';
63 $self->{_content}{'userpassword'} = '7654321';
64 $self->{_content}{'TerminalNumber'} = '1000';
67 tie my %fields, 'Tie::IxHash', $self->get_fields( $self->fields );
68 my $post_data = join('&', map "$_=$fields{$_}", keys %fields );
69 warn "POSTING: ".$post_data if $DEBUG > 1;
71 my( $page, $response, @reply_headers) = $self->https_post( $post_data );
73 if ($response !~ /^200/) {
75 $response =~ s/[\r\n]+/ /g; # ensure single line
77 my $diag_message = $response || "connection error";
81 $self->server_response($page);
83 unless ( $page =~ /^(\d+);(\d+);(.*?)$/ ) {
84 die "unparsable response received from gateway" .
85 ( $DEBUG ? ": $page" : '' );
89 my $authorization = $2;
92 $self->result_code($result);
95 $self->authorization($authorization);
98 $self->error_message($message);
120 'info_compat' => '0.01',
121 'gateway_name' => 'Cardcom',
122 'gateway_url' => 'http://www.cardcom.co.il',
123 'module_version' => $VERSION,
124 'support_types' => [ 'CC' ],
125 'token_support' => 0, # well technically the gateway supports it, but we haven't implemented it
126 'test_transaction' => 1,
127 'supported_actions' => [ # XXX refunds
128 'Normal Authorization',
139 Business::OnlinePayment::Cardcom - Cardcom backend module for Business::OnlinePayment
143 use Business::OnlinePayment::Cardcom;
146 # One step transaction, the simple case.
149 my $tx = new Business::OnlinePayment("Cardcom");
152 login => 'Cardcom Username',
153 password => 'Cardcom Password',
154 terminalnumber => 'Cardcom Terminal Number',
155 action => 'Normal Authorization',
157 card_number => '4005550000000019',
158 expiration => '08/06',
163 if($tx->is_success()) {
164 print "Card processed successfully: ".$tx->authorization."\n";
166 print "Card was rejected: ".$tx->error_message."\n";
169 =head1 SUPPORTED TRANSACTION TYPES
173 Content required: type, login, password, action, amount, card_number, expiration, terminalnumber.
181 For detailed information see L<Business::OnlinePayment>.
185 Erik Levinson <levinse@freeside.biz>
189 perl(1). L<Business::OnlinePayment>.