0
我使用Net :: Stripe處理信用卡。如果信用卡號碼有效,它工作正常。但是,當我考不好的信用卡號,我去排隊Stripe.pm 676:Perl Net :: Stripe Internal Server Error with Bad Credit Card Number
676: die $e;
和產生這個錯誤:
1 at /usr/share/perl/5.14/perl5db.pl line 7799.
這會導致內部服務器錯誤,在瀏覽器中。
的代碼Stripe.pm與模具語句結束的塊是這樣的:
if ($resp->code == 200) {
return _hash_to_object(decode_json($resp->content));
} elsif ($resp->code == 500) {
die Net::Stripe::Error->new(
type => "HTTP request error",
code => $resp->code,
message => $resp->status_line . " - " . $resp->content,
);
}
my $e = eval {
my $hash = decode_json($resp->content);
Net::Stripe::Error->new($hash->{error})
};
if ([email protected]) {
Net::Stripe::Error->new(
type => "Could not decode HTTP response: [email protected]",
message => $resp->status_line . " - " . $resp->content,
);
};
warn "$e\n" if $self->debug;
die $e;
正從條返回的響應代碼是402
我試圖處理錯誤從條紋的消息用下面的代碼:
my $card_token = $stripe->post_token(
card => {
number => $FORM{'Credit Card #'},
exp_month => $FORM{'Expiration Month'},
exp_year => $FORM{'Expiration Year'},
currency => 'usd',
cvc => $FORM{'Credit Card Security Code'},
name => $FORM{'Name on Card'},
address_line1 => $FORM{'Address'},
address_city => $FORM{'City'},
address_state => $FORM{'State'},
address_zip => $FORM{'Zip'}
}
);
if ($card_token->{failure_message}) {
$error = $card_token->{failure_message};
print "Content-type: text/html\n\n";
print "There was an error processing your credit card:<br><br>$error";
}
但退出的正在試圖獲取令牌代碼塊之前的代碼是死亡。
有沒有辦法抑制這個「死」的聲明?