OpenID::PayPal::LIPP - Login with PayPal
use OpenID::PayPal::LIPP; my $lipp = OpenID::PayPal::LIPP->new( client_id => 'CLIENT_ID', client_secret => 'CLIENT_SECRET', account => 'ACCOUNT', mode => 'sandbox', redirect_uri => 'http://localhost/callback', ); my $url = $lipp->login_url(); # user after visiting that url, user will be redirected to http://localhost/callback with a parameter code # you can either directly the user info with the code, or exchange code for access token my $token = $pp->exchange_code( $code ); #$token contain an access token and a refresh token #to get a new access token from refresh token : $token = $pp->refresh_token( $token->{refresh_token} ); #to get user info, you can either give access_token, or authorization code my $user_info = $pp->get_user_details( access_token => $token->{access_token} ); my $user_info = $pp->get_user_details( authorization_code => $code ); print $user_info->email
OpenID::PayPal::LIPP is a simple implementation for the Login with PayPayl API.
Following methods are available
Constructor take the following required arguments:
client_id: client id of your paypal application
client_secret: client secret of your paypal application
account: account linked to your paypal application
redirect_uri: redirection url registered in your paypal application, user will be redirected there after login in PayPal website
mode: sandbox or live
You have some more control with the following optionnal argument:
scope: arrayref of the scope you want to get access to, default is [ 'openid', 'email' ]
logger: coderef to a sub used to log some internal debug messages, see logger section
Return login url to redirect the user to, state if provided will be passed to paypal, and return to your callback url
Exchange authorization code for token, token is a hash of 2 keys, access_token and refresh_token.
Allow you to refresh your access token from your refresh token, it will return a hash of 2 keys, access_token and refresh_token.
Call that method with either the authorization code or an access token to get paypal's user info, in a hash
In case there is an issue on paypal side, the module with croak, so you should use it in an eval block, or better with Try::Tiny To get some more info, you can pass a sub to the constructor in field logger. That sub will get called with debug message within the process of calling paypal.
my $lipp = OpenID::PayPal::LIPP->new( client_id => 'CLIENT_ID', client_secret => 'CLIENT_SECRET', account => 'ACCOUNT', mode => 'sandbox', redirect_uri => 'http://localhost/callback', logger => sub { warn @_ } );
Pierre VIGIER <pierre.vigier@gmail.com>
Copyright 2016- Pierre VIGIER
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install OpenID::PayPal::LIPP, copy and paste the appropriate command in to your terminal.
cpanm
cpanm OpenID::PayPal::LIPP
CPAN shell
perl -MCPAN -e shell install OpenID::PayPal::LIPP
For more information on module installation, please visit the detailed CPAN module installation guide.