Business::OnlinePayment::Mock - A backend for mocking fake results for test cards
version 0.006
# During initilaziation of your scripts, setup the responses you want from each aciton/card number $mock->set_mock_response({ action => 'Credit', card_number => '4111111111111111', error_message => 'Approved', is_success => 1, error_code => 0, order_number => 1, }); # Then later once you are ready to use the mock module my $transaction = new Business::OnlinePayment('Mock'); $transaction->content( type => 'Visa', amount => '49.95', card_number => '1234123412341238', expiration => '06/15', name => 'John Q Doe', ); eval { $transaction->submit(); }; if ( $@ ) { print "$processor error: $@\n"; } else { if ( $transaction->is_success() ) { print "Card processed successfully: ". $transaction->authorization()."\n"; } else { print "Card was rejected: ". $transaction->error_message(). "\n"; } }
Ability to get any Business::OnlinePayment result you want using this mock driver.
Sets the default mock for the Business::OnlinePayment object
$mock->set_default_mock({ error_message => 'Declined', is_success => 0, error_code => 100, order_number => 1, });
Sets the mock response the Business::OnlinePayment object
$mock->set_mock_response({ action => 'Credit', card_number => '4111111111111111', error_message => 'Approved', is_success => 1, error_code => 0, order_number => 1, });
Get/set the server used for processing transactions. Because we are mocked, this method effectively does nothing. Default: Live
#Live $self->test_transaction(0); #Certification $self->test_transaction(1);
Submit the content to the mocked API
$self->content(action => 'Credit' ...) $self->submit;
Business::OnlinePayment::Mock - A backend for mocking fake results in the Business::OnlinePayment environment
Jason Terry <oaxlin@gmail.com>
This software is copyright (c) 2018 by Jason Terry.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Business::OnlinePayment::Mock, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Business::OnlinePayment::Mock
CPAN shell
perl -MCPAN -e shell install Business::OnlinePayment::Mock
For more information on module installation, please visit the detailed CPAN module installation guide.