Catalyst::Model::PayPal::API - PayPal Model for Catalyst
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.
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
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 );
Your paypal API username
As supplied by PayPal
If true, uses the sandbox apis rather than production APIs
Use this for the thorough testing I mentioned above.
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.
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 );
As described previously
Location of the CertFile
Location of the KeyFile
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 );
Location of the PKCS12File
Location of the PKCS12Password
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.
You don't need to worry about new(), Catalyst uses this all on its own.
$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!
As per Busines::PayPal::API, errors are in the %resp returned when functions are called.
Business::PayPal::API
Dean Hamstead, <dean at fragfest.com.au>
<dean at fragfest.com.au>
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 2012 Dean Hamstead,
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Catalyst::Model::PayPal::API, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Catalyst::Model::PayPal::API
CPAN shell
perl -MCPAN -e shell install Catalyst::Model::PayPal::API
For more information on module installation, please visit the detailed CPAN module installation guide.