The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Business::OnlinePayment::Mock - A backend for mocking fake results for test cards

VERSION

version 0.006

SYNOPSIS

   # 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";
     }
   }

DESCRIPTION

Ability to get any Business::OnlinePayment result you want using this mock driver.

METHODS

set_default_mock

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,
   });

set_mock_response

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,
   });

test_transaction

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

Submit the content to the mocked API

  $self->content(action => 'Credit' ...)

  $self->submit;

NAME

Business::OnlinePayment::Mock - A backend for mocking fake results in the Business::OnlinePayment environment

AUTHOR

Jason Terry <oaxlin@gmail.com>

COPYRIGHT AND LICENSE

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.