Business-OnlinePayment-IPayment
view release on metacpan or search on metacpan
t/payment.t view on Meta::CPAN
test_success($response);
my $ipayres = $secbopi->get_response_obj($response->header('location'));
# we build this anew, as in the web it will be a fresh request, so we
# don't do nothing about the previous one.
$ipayres->set_credentials(
my_amount => $secbopi->trx_obj->trxAmount,
my_currency => $secbopi->trx_obj->trxCurrency,
# my_userid => $secbopi->trxuserid,
# my_security_key => $secbopi->app_security_key,
);
ok($ipayres->url_is_valid, "Url is ok");
ok($ipayres->is_valid, "Payment looks ok");
ok(!$ipayres->validation_errors, "No errors found");
is($ipayres->paydata_cc_number, 'XXXXXXXXXXXX1111', "CC num returned masked");
is($ipayres->paydata_cc_cardowner, "Mario Pegula", "CC owner returned");
is($ipayres->paydata_cc_typ, "VisaCard", "Visa card returned");
my $expiration_expected = next_year();
$expiration_expected =~ s/^(\d\d)(\d\d)/02$2/;
is($ipayres->paydata_cc_expdate, $expiration_expected,
"Expiration returned $expiration_expected");
# while if we tamper fails
$ipayres->my_amount(5000000);
ok(!$ipayres->is_valid, "Tampered data not ok");
ok($ipayres->validation_errors, "Errors: " . $ipayres->validation_errors);
# passing only the security key should work too
my $location = URI->new($response->header('location'));
my %params = $location->query_form;
$ipayres = Business::OnlinePayment::IPayment::Response->new(%params);
eval {$ipayres->is_valid };
ok($@, "no secret key: $@");
# with security key pass is ok.
$ipayres = Business::OnlinePayment::IPayment::Response->new(%params);
$ipayres->my_security_key("testtest");
ok($ipayres->is_success && $ipayres->is_valid, "Payment looks ok");
ok $ipayres->shopper_id, "Shopper id retrieve: " . $ipayres->shopper_id;
ok($ipayres->url_is_valid($response->header('location')),
"Url looks untampered");
ok(!$ipayres->validation_errors, "No errors");
$ipayres->my_security_key("testtestX");
ok(!$ipayres->is_valid, "wrong secret key yields failure");
ok($ipayres->validation_errors, "Errors: " . $ipayres->validation_errors);
# diag "Please wait 2 minutes before running me again, or the tests will fail!";
# diag "Test run on " . localtime;
sub test_success {
my $r = shift;
is($r->status_line, '302 Found', "We are redirected");
unlike($r->decoded_content, qr/ERROR/, "No error");
like($r->decoded_content, qr/<a href="http:/, "Redirect");
my $uri = URI->new($r->header('location'));
# my %result = $uri->query_form;
# print Dumper(\%result);
}
sub next_year {
my $year = strftime('%Y', localtime(time())) + 1;
}
( run in 1.785 second using v1.01-cache-2.11-cpan-9789f410c06 )