Catalyst-Model-PayPal-IPN

 view release on metacpan or  search on metacpan

lib/Catalyst/Model/PayPal/IPN.pm  view on Meta::CPAN

                    amount      => $tariff->peruser,
                    page_style  => $c->config->{paypal}->{page_style},
                    no_shipping => $c->config->{paypal}->{no_shipping},
                    no_note     => $c->config->{paypal}->{no_note},
                    'lc'        => $c->config->{paypal}->{lc},
                    bn          => $c->config->{paypal}->{bn},
                    custom      => $c->req->param('subid'),
                );

                if ( $c->debug ) {
                    for my $param ( keys %data ) {
                        $c->log->debug( $param . '=' . $data{$param} );
                    }
                }
                $c->stash->{unencrypted_form_data} =
                  $c->model('Paypal::IPN')->form_info( \%data );

                my @button_info = (
                    $tariff->itemdesc, $tariff->peruser,
                    $c->stash->{unencrypted_form_data}
                );
                push @{ $c->stash->{unencrypted_buttons} }, \@button_info;

                #$c->stash->{encrypted_form_data} =
                #  $c->model('Paypal::IPN')->encrypt_form( \%data );

                #my @button_info = (
                #    $tariff->itemdesc, $tariff->peruser,
                #    $c->stash->{encrypted_form_data}
                #);
                #push @{ $c->stash->{encrypted_buttons} }, \@button_info;
            }
        }
    }

    buttons.tt

    <table>
        [% FOREACH button IN unencrypted_buttons %]
            <tr>
                <td><b>[% button.0 %]</b></td>
                <td><b>Price:</b> £[% button.1 %]</td>
                <td class="content">
                    <form method="post" action="[% c.model('Paypal::IPN').paypal_gateway %]">
                    <input type="hidden" name="cmd" value="_xclick">
                    <input type="image" src="https://www.paypal.com/en_US/i/btn/x-click-but23.gif" border="0"
                    name="submit" alt="Make payments with PayPal - it's fast, free and secure!">
                    <img alt="" border="0" src="https://www.paypal.com/en_GB/i/scr/pixel.gif" width="1" height="1">
            [% FOREACH key IN button.2.keys %]
                    <input type="hidden" name="[% key %]" value="[% button.2.$key %]" />
            [% END %]
                    </form>
                </td>
            </tr>
        [% END %]
            <tr>
                <td class="content">
                    <input type="button" onclick="dojo.widget.byId('profdiag').hide();" value="Close" name="close"/>
                </td>
                <td class="content" colspan="2">
                    <a href="#" onclick="javascript:window.open('https://www.paypal.com/uk/cgi-bin/webscr?cmd=xpt/cps/popup/OLCWhatIsPayPal-outside','olcwhatispaypal','toolbar=no,location=no, directories=no, status=no, menubar=no, scrollbars=yes,resi...
alt="Solution Graphics"></a>
                </td>
            </tr>
    </table>


=head1 DESCRIPTION

This model handles all the latest PayPal IPN vars, and provides an
easy method for checking that the transaction was successful.

There are also convenience methods for generating encrypted and non-encrypted
PayPal forms and buttons.

See L<Business::PayPal::IPN> for more info.

B<WARNING:> this module does not have real tests yet, if you encounter problems
please report them via L<http://rt.cpan.org/> .

=head1 INTERFACE

=head2 build_paypal_gateway

If debug_mode is on, returns sandbox url, otherwise normal PayPal gateway

=head2 is_completed

Calls is_completed from L<Business::PayPal::IPN>

=head2 error

Calls error from L<Business::PayPal::IPN>

=head2 buyer_info

Returns IPN vars via L<Business::PayPal::IPN>

See L<https://www.paypal.com/IntegrationCenter/ic_ipn-pdt-variable-reference.html>

=head2 correlation_info

Returns a hashref of amount, invoice and custom.

=head2 form_info

Takes a hashref and returns form data for looping through to create your form.

See L<SYNOPSIS>

=head2 encrypt_form

Encrypts form data.

    $c->model('Paypal::IPN')->encrypt_form( \%data );

=head1 CONFIGURATION AND ENVIRONMENT

The usual techniques for suppling model configuration data in Catalyst apply,
but the follow should be present:



( run in 1.092 second using v1.01-cache-2.11-cpan-364913b4093 )