1 package Business::OnlinePayment::Jety;
5 use Business::OnlinePayment 3;
6 use Business::OnlinePayment::HTTPS;
7 use vars qw($VERSION @ISA $me $DEBUG);
12 @ISA = qw(Business::OnlinePayment::HTTPS);
14 $me = 'Business::OnlinePayment::Jety';
42 'login' => 'username',
43 'first_name' => 'firstname',
44 'last_name' => 'lastname',
45 'address' => 'address1',
46 'bank_name' => 'bankname',
47 'bank_city' => 'bankcity',
48 'bank_state' => 'bankstate',
49 'account_number' => 'accountdda',
50 'routing_code' => 'accountaba',
51 'description' => 'programdesc',
56 $self->server('api.cardservicesportal.com');
58 $self->path('/servlet/drafts.echeck');
64 my $content = $self->{_content};
66 $self->remap_fields(%map);
68 die "Jety API only supports ECHECK payments.\n"
69 if(lc($content->{type}) ne 'echeck');
70 die "Jety interface only supports Normal Authorization.\n"
71 if(lc($content->{action}) ne 'normal authorization');
73 $content->{'function'} = 'echeck';
75 substr( time2str('%Y%m%d%H%M%S',time). int(rand(10000)), -15 );
77 $content->{'phone'} ||= '111-111-1111';
79 $content->{'bankname'} ||= 'unknown';
80 $content->{'bankcity'} ||= 'unknown';
81 $content->{'bankstate'} ||= 'XX';
88 $Business::OnlinePayment::HTTPS::DEBUG = $DEBUG;
91 # strip existent but empty fields so that required_fields works right
92 foreach(keys(%{$self->{_content}})) {
93 delete $self->{_content}->{$_}
94 if (!defined($self->{_content}->{$_} ) or
95 $self->{_content}->{$_} eq '');
98 $self->required_fields(qw(
114 tie my %request, 'Tie::IxHash', map { $_ => $self->{_content}->{$_} } @fields;
116 $DB::single = $DEBUG;
117 if($self->test_transaction()) {
118 print "https://".$self->server.$self->path."\n";
119 print "$_\t".$request{$_}."\n" foreach keys(%request);
120 $self->error_message('test mode not supported');
121 $self->is_success(0);
124 my ($reply, $response, %reply_headers) = $self->https_post(\%request);
126 if(not $response =~ /^200/) {
127 croak "HTTPS error: '$response'";
130 # string looks like this:
131 # P1=1234&P2=General Status&P3=Specific Status
132 # P3 is not always there, though.
133 if($reply =~ /^P1=(\d+)&P2=([\w ]*)(&P3=(\S+))?/) {
135 $self->is_success(1);
136 $self->authorization($4);
139 $self->is_success(0);
140 $self->error_message($2.($4 ? "($4)" : ''));
144 croak "Malformed server response: '$reply'";
155 Business::OnlinePayment::Jety - Jety Payments ACH backend for Business::OnlinePayment
159 use Business::OnlinePayment;
162 # Electronic check authorization. We only support
163 # 'Normal Authorization'.
166 my $tx = new Business::OnlinePayment("Jety");
169 login => 'testdrive',
170 password => 'testpass',
171 action => 'Normal Authorization',
172 description => '111-111-1111 www.example.com',
174 invoice_number => '100100',
175 first_name => 'Jason',
176 last_name => 'Kohles',
177 address => '123 Anystreet',
181 account_type => 'personal checking',
182 account_number => '1000468551234',
183 routing_code => '707010024',
184 check_number => '1001', # optional
188 if($tx->is_success()) {
189 print "Check processed successfully: ".$tx->authorization."\n";
191 print "Check was rejected: ".$tx->error_message."\n";
194 =head1 SUPPORTED TRANSACTION TYPES
198 Content required: type, login, password, action, amount, first_name, last_name, account_number, routing_code, description.
200 description should be set in the form "111-111-1111 www.example.com"
204 For detailed information see L<Business::OnlinePayment>.
206 =head1 METHODS AND FUNCTIONS
208 See L<Business::OnlinePayment> for the complete list. The following methods either override the methods in L<Business::OnlinePayment> or provide additional functions.
212 Returns the four-digit result code.
216 Returns a useful error message.
218 =head1 Handling of content(%content) data:
222 The following actions are valid:
228 Mark Wells <mark@freeside.biz>
232 perl(1). L<Business::OnlinePayment>.