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

NAME

WebService::PayPal::PaymentsAdvanced::Mocker - A class which returns mocked PPA apps.

VERSION

version 0.000008

SYNOPSIS

    use WebService::PayPal::PaymentsAdvanced::Mocker;
    my $mocker = WebService::PayPal::PaymentsAdvanced::Mocker->new( plack => 1 );
    my $app = $mocker->payflow_pro; # returns a PSGI app

    # OR, to use with a mocking UserAgent
    use Test::LWP::UserAgent;
    use HTTP::Message::PSGI;

    my $ua = Test::LWP::UserAgent->new;
    my $mocker = WebService::PayPal::PaymentsAdvanced::Mocker->new( plack => 1 );
    $ua->register_psgi( 'pilot-payflowpro.paypal.com', $mocker->payflow_pro );
    $ua->register_psgi( 'pilot-payflowlink.paypal.com', $mocker->payflow_link );

    my $ppa = WebService::PayPal::PaymentsAdvanced->new(
        ua => $ua,
        ...
    );

DESCRIPTION

You can use this class to facilitate mocking your PPA integration. When running under $ENV{HARNESS_ACTIVE}, you can pass a Test::LWP::UserAgent to WebService::PayPal::PaymentsAdvanced as in the SYNOPSIS above. Adjust the hostnames as necessary.

CONSTRUCTOR OPTIONS

plack => [0|1]

If you require a PSGI app to be returned, you'll need to enable this option. Disabled by default.

    use WebService::PayPal::PaymentsAdvanced::Mocker;
    my $mocker = WebService::PayPal::PaymentsAdvanced::Mocker->new( plack => 1 );
    my $app = $mocker->payflow_pro; # returns a PSGI app

ua

If may provide your own UserAgent object to this class. This is only necessary if you intend to call the mocked_ua method and need to provide your own customized UserAgent. The object must be Test::LWP::UserAgent object, or a subclass of it.

Returns a Mojolicious::Lite app which mocks the Payflow Link web service.

payflow_pro

Returns a Mojolicious::Lite app which mocks the Payflow Pro web service.

mocked_ua

Returns a UserAgent object mocking already enabled for both live and sandbox PayPal hostnames. The UserAgent will either be the object which you passed via the ua option when you created the object or a vanilla Test::LWP::UserAgent object which this class will create.

AUTHOR

Olaf Alders <olaf@wundercounter.com>

COPYRIGHT AND LICENSE

This software is Copyright (c) 2015 by MaxMind, Inc..

This is free software, licensed under:

  The Artistic License 2.0 (GPL Compatible)