WebService-PayPal-PaymentsAdvanced

 view release on metacpan or  search on metacpan

lib/WebService/PayPal/PaymentsAdvanced/Mocker/SilentPOST.pm  view on Meta::CPAN

    if ( $self->_secure_token_id eq 'NOPPREF' ) {
        delete $args->{PPREF};
    }
    return $args;
}

sub _set_defaults {
    my $self     = shift;
    my $defaults = shift;

    my %method_for = (
        BAID          => 'baid',
        CORRELATIONID => 'correlationid',
        PNREF         => 'pnref',
        PPREF         => 'ppref',
        TRANSTIME     => 'transtime',
        SECURETOKEN   => 'secure_token',
        TOKEN         => 'token',
    );

    for my $key ( keys %method_for ) {
        if ( exists $defaults->{$key} ) {
            my $method = $method_for{$key};
            $defaults->{$key} = $self->_helper->$method;
        }
    }

    $defaults->{SECURETOKENID} = $self->_secure_token_id;
    if ( $self->_secure_token_id eq 'NOPPREF' ) {
        delete $defaults->{PPREF};
    }
    return $defaults;
}

1;

=pod

=encoding UTF-8

=head1 NAME

WebService::PayPal::PaymentsAdvanced::Mocker::SilentPOST - Easily mock Silent POST transactions

=head1 VERSION

version 0.000028

=head1 SYNOPSIS

    use LWP::UserAgent;
    use WebService::PayPal::PaymentsAdvanced::Mocker::SilentPOST;

    my $mocker
        = WebService::PayPal::PaymentsAdvanced::Mocker::SilentPOST->new();

    my $ua = LWP::UserAgent->new(...);
    $ua->post(
        '/silent-post-url',
        $mocker->paypal_success,
        'X-Forwarded-For' => '173.0.81.65'
    );

=head2 paypal_success

Returns a C<HashRef> of POST params which can be used to mock a successful
PayPal authorization.

=head2 credit_card_success

Returns a C<HashRef> of POST params which can be used to mock a successful
credit card authorization.

=head2 credit_card_auth_verification_success

Returns a C<HashRef> of POST params which can be used to mock a successful zero
dollar credit card authorization.

=head2 credit_card_duplicate_invoice_id

Returns a C<HashRef> of POST params which can be used to mock a unsuccessful
credit card payment.  In this case you've sent an invoice ID which is already
attached to a previously successful transaction.

=head1 DESCRIPTION

Use these methods to get a HashRef of params which you can POST to your
application's silent POST endpoint. Keep in mind that if you have IP
validation enabled you'll either need to spoof the originating IP of the
request or disable the IP validation in test mode.  I'd encourage you to do
the former, if at all possible.

=head1 SUPPORT

Bugs may be submitted through L<https://github.com/maxmind/webservice-paypal-paymentsadvanced/issues>.

=head1 AUTHOR

Olaf Alders <olaf@wundercounter.com>

=head1 COPYRIGHT AND LICENSE

This software is copyright (c) 2022 by MaxMind, Inc.

This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.

=cut

__END__

# ABSTRACT: Easily mock Silent POST transactions



( run in 1.487 second using v1.01-cache-2.11-cpan-39bf76dae61 )