Business-PayPal-API
view release on metacpan or search on metacpan
CONTRIBUTING.md view on Meta::CPAN
To test this module type the following:
WPP_TEST=auth.txt prove -lvr t
Please notice that this module requires you have several things before
you can test it:
- a sandbox personal PayPal account
- a sandbox business PayPal account
- API credentials (either a certificate or signature)
- auth.txt, which contains your API credentials
Read PayPal's and this module's documentation to learn more about how to
acquire PayPal sandbox credentials.
If you do not set the WPP_TEST environment variable, sandbox tests will be
skipped.
The format of the authentication tokens file defined by WPP_TEST may be found
in the Business::PayPal::API documentation under "TESTING". Sample auth.txt
files may be found in 'auth.sample.3token' and 'auth.sample.cert' in this
distribution.
Creates a new **Business::PayPal::API** object.
A note about certificate authentication: PayPal (and this module)
support either PKCS#12 certificate authentication or PEM certificate
authentication. See options below.
- **Username**
Required. This is the PayPal API username, usually in the form of
'my\_api1.mydomain.tld'. You can find or create your API credentials by
logging into PayPal (if you want to do testing, as you should, you
should also create a developer sandbox account) and going to:
My Account -> Profile -> API Access -> Request API Credentials
Please see the _PayPal API Reference_ and _PayPal Sandbox User
Guide_ for details on creating a PayPal business account and sandbox
account for testing.
- **Password**
if( $response{Ack} ne 'Success' ) {
for my $err ( @{$response{Errors}} ) {
warn "Error: " . $err->{LongMessage} . "\n";
}
}
# TESTING
Testing the **Business::PayPal::API::\*** modules requires that you
create a file containing your PayPal Developer Sandbox authentication
credentials (e.g., API certificate authentication or 3-Token
authentication signature, etc.) and setting the **WPP\_TEST**
environment variable to point to this file.
The format for this file is as follows:
Username = your_api.username.com
Password = your_api_password
and then ONE of the following options:
a) supply 3-token authentication signature
Signature = xxxxxxxxxxxxxxxxxxxxxxxx
b) supply PEM certificate credentials
CertFile = /path/to/cert_key_pem.txt
KeyFile = /path/to/cert_key_pem.txt
c) supply PKCS#12 certificate credentials
PKCS12File = /path/to/cert.p12
PKCS12Password = pkcs12_password
You may also set the appropriate HTTPS\_\* environment variables for b)
and c) above (e.g., HTTPS\_CERT\_FILE, HTTPS\_KEY\_FILE,
HTTPS\_PKCS12\_File, HTTPS\_PKCS12\_PASSWORD) in lieu of putting this
information in a file.
Then use "WPP\_TEST=my\_auth.txt make test" (for Bourne shell derivates) or
Any of the following variables are recognized:
Username Password Signature Subject
CertFile KeyFile PKCS12File PKCS12Password
BuyerEmail
Note: PayPal authentication may _fail_ if you set the certificate
environment variables and attempt to connect using 3-token
authentication (i.e., PayPal will use the first authentication
credentials presented to it, and if they fail, the connection is
aborted).
# TROUBLESHOOTING
## PayPal Authentication Errors
If you are experiencing PayPal authentication errors (e.g., "Security
header is not valid", "SSL negotiation failed", etc.), you should make
sure:
account).
* you're not trying to use your live username and password for
sandbox testing and vice versa.
* you are using a US Business Sandbox account, you may also need to have
"PayPal Payments Pro" enabled.
* if the sandbox works but "live" does not, make sure you've turned
off the 'sandbox' parameter correctly. Otherwise you'll be
passing your PayPal sandbox credentials to PayPal's live site
(which won't work).
* if you use certificate authentication, your certificate must be
the correct one (live or sandbox) depending on what you're doing.
* if you use 3-Token authentication (i.e., Signature), you don't
have any B<PKCS12*> parameters or B<CertFile> or B<KeyFile>
parameters in your constructor AND that none of the corresponding
B<HTTPS_*> environment variables are set. PayPal prefers
certificate authentication since it occurs at connection time; if
eg/lib/Example/Role/Auth.pm view on Meta::CPAN
package Example::Role::Auth;
use Moo::Role;
use MooX::Options;
use Business::PayPal::API qw( GetTransactionDetails TransactionSearch );
use Types::Standard qw( InstanceOf );
# credentials
option password => (
is => 'ro',
format => 's',
required => 1,
doc => 'password',
);
# defaults to boolean if no format specified
option sandbox => (
is => 'ro',
lib/Business/PayPal/API.pm view on Meta::CPAN
A note about certificate authentication: PayPal (and this module)
support either PKCS#12 certificate authentication or PEM certificate
authentication. See options below.
=over 4
=item B<Username>
Required. This is the PayPal API username, usually in the form of
'my_api1.mydomain.tld'. You can find or create your API credentials by
logging into PayPal (if you want to do testing, as you should, you
should also create a developer sandbox account) and going to:
My Account -> Profile -> API Access -> Request API Credentials
Please see the I<PayPal API Reference> and I<PayPal Sandbox User
Guide> for details on creating a PayPal business account and sandbox
account for testing.
=item B<Password>
lib/Business/PayPal/API.pm view on Meta::CPAN
if( $response{Ack} ne 'Success' ) {
for my $err ( @{$response{Errors}} ) {
warn "Error: " . $err->{LongMessage} . "\n";
}
}
=head1 TESTING
Testing the B<Business::PayPal::API::*> modules requires that you
create a file containing your PayPal Developer Sandbox authentication
credentials (e.g., API certificate authentication or 3-Token
authentication signature, etc.) and setting the B<WPP_TEST>
environment variable to point to this file.
The format for this file is as follows:
Username = your_api.username.com
Password = your_api_password
and then ONE of the following options:
a) supply 3-token authentication signature
Signature = xxxxxxxxxxxxxxxxxxxxxxxx
b) supply PEM certificate credentials
CertFile = /path/to/cert_key_pem.txt
KeyFile = /path/to/cert_key_pem.txt
c) supply PKCS#12 certificate credentials
PKCS12File = /path/to/cert.p12
PKCS12Password = pkcs12_password
You may also set the appropriate HTTPS_* environment variables for b)
and c) above (e.g., HTTPS_CERT_FILE, HTTPS_KEY_FILE,
HTTPS_PKCS12_File, HTTPS_PKCS12_PASSWORD) in lieu of putting this
information in a file.
Then use "WPP_TEST=my_auth.txt make test" (for Bourne shell derivates) or
lib/Business/PayPal/API.pm view on Meta::CPAN
Any of the following variables are recognized:
Username Password Signature Subject
CertFile KeyFile PKCS12File PKCS12Password
BuyerEmail
Note: PayPal authentication may I<fail> if you set the certificate
environment variables and attempt to connect using 3-token
authentication (i.e., PayPal will use the first authentication
credentials presented to it, and if they fail, the connection is
aborted).
=head1 TROUBLESHOOTING
=head2 PayPal Authentication Errors
If you are experiencing PayPal authentication errors (e.g., "Security
header is not valid", "SSL negotiation failed", etc.), you should make
sure:
lib/Business/PayPal/API.pm view on Meta::CPAN
account).
* you're not trying to use your live username and password for
sandbox testing and vice versa.
* you are using a US Business Sandbox account, you may also need to have
"PayPal Payments Pro" enabled.
* if the sandbox works but "live" does not, make sure you've turned
off the 'sandbox' parameter correctly. Otherwise you'll be
passing your PayPal sandbox credentials to PayPal's live site
(which won't work).
* if you use certificate authentication, your certificate must be
the correct one (live or sandbox) depending on what you're doing.
* if you use 3-Token authentication (i.e., Signature), you don't
have any B<PKCS12*> parameters or B<CertFile> or B<KeyFile>
parameters in your constructor AND that none of the corresponding
B<HTTPS_*> environment variables are set. PayPal prefers
certificate authentication since it occurs at connection time; if
( run in 0.261 second using v1.01-cache-2.11-cpan-4d50c553e7e )