Dean Hamstead > Catalyst-Model-PayPal-API-0.32 > Catalyst::Model::PayPal::API

Download:
Catalyst-Model-PayPal-API-0.32.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 0.31   Source  

NAME ^

Catalyst::Model::PayPal::API - PayPal Model for Catalyst

WARNING ^

Although I have been using this model for over 12 months in production, and it has processed over $10,000 in sales - please test thoroughly before risking your livelyhood on it!

This module is really only a layer between Catalyst::Model and Business::PayPal::API, any problems will PayPall are probably problems with the underlying module.

SYNOPSIS ^

  package YourApp::Model::PayPal;
  use parent 'Catalyst::Model::PayPal::API';
  __PACKAGE->config(%paypal_account_details);
  1

  package YourApp::Controller::Foo;

  sub index : Path('/') {
    my ( $self, $c, @args ) = @_;

    my %resp = $c->model('PayPal')->SetExpressCheckout(%options);

    if ( $resp{Ack} eq 'Success' ) {
      # save the various details in a database or something, then redirect

        $c->response->redirect(
            $c->model('PayPal')->redirect_url() . $resp{Token} );

    } else {
      # handle the error details, see Business::PayPal::API
    }
  }
  1

USAGE ^

3-token (Signature) authentication

  package 'Your::Model::PayPal';
  use parent 'Catalyst::Model::PayPal::API';

  __PACKAGE__->config(
      Username   => 'your paypal username',
      Password   => 'ABCDEF',  ## supplied by PayPal
      Signature  => 'xyz',     ## ditto
      sandbox    => 0 || 1,    ## Use sandbox or production API
      subclasses => [qw( ExpressCheckout GetTransactionDetails )],
                               ## Which functions to use
  );
Username

Your paypal API username

Password

As supplied by PayPal

Signature

As supplied by PayPal

sandbox

If true, uses the sandbox apis rather than production APIs

Use this for the thorough testing I mentioned above.

subclasses

Business::PayPal::API has a custom import() function which you must instruct to load which ever API functions you want to use. This sounds less strange than it is. See Business::PayPal::API::* for which API options can be loaded.

Check the documentation for Business::PayPal::API for details on which options you want to use here.

PEM certificate authentication

  package 'Your::Model::PayPal';
  use parent 'Catalyst::Model::PayPal::API';

  __PACKAGE__->config(
      Username   => 'your paypal username',
      Password   => 'ABCDEF',  ## supplied by PayPal
      CertFile   => '/path/to/file', ## file, supplied by PayPal
      KeyFile    => '/path/to/file', ## file, supplied by PayPal
      sandbox    => 0 || 1,    ## Use sandbox or production API
      subclasses => [qw( ExpressCheckout GetTransactionDetails )],
                               ## Which functions to use
  );
Username, Password, sandbox, subclasses

As described previously

CertFile

Location of the CertFile

KeyFile

Location of the KeyFile

Certificate authentication

  package 'Your::Model::PayPal';
  use parent 'Catalyst::Model::PayPal::API';

  __PACKAGE__->config(
      Username    => 'your paypal username',
      Password    => 'ABCDEF',  ## supplied by PayPal
      PKCS12File  => '/path/to/file', ## file, supplied by PayPal
      PKCS12Password => '/path/to/file', ## file, supplied by PayPal
      sandbox     => 0 || 1,    ## Use sandbox or production API
      subclasses  => [qw( ExpressCheckout GetTransactionDetails )],
                                ## Which functions to use
  );
Username, Password, sandbox, subclasses

As described previously

PKCS12File

Location of the PKCS12File

PKCS12Password

Location of the PKCS12Password

DESCRIPTION ^

This is a Catalyst model for Business::PayPal::API, allowing you to use PayPal to bill your clients in your Catalyst application.

When naming this model, I have chosen to drop the 'Business::' so as to shorten the name somewhat.

FUNCTIONS ^

new

You don't need to worry about new(), Catalyst uses this all on its own.

redirect_url

 $redirect = $c->model('PayPal')->redirect_url() . $token;

This is a convenient function which you can use to redirect your customer to PayPal to make their purchases. You just concatenate their token to the end and redirect!

This function knows about the sandbox setting, which is also very convenient when testing. But remember that you provide to PayPal the return URL, so you'll need to match it with your production and testing environments independant on your own!

ERROR HANDLING ^

As per Busines::PayPal::API, errors are in the %resp returned when functions are called.

SEE ALSO ^

Business::PayPal::API

AUTHOR ^

Dean Hamstead, <dean at fragfest.com.au>

BUGS ^

Please report any bugs or feature requests through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Catalyst-Model-PayPal-API. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

Please fork and contribute via https://github.com/djzort/Catalyst-Model-PayPal-API

COPYRIGHT & LICENSE ^

Copyright 2012 Dean Hamstead,

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

syntax highlighting: