Cleans up some code samples in docs.

This commit is contained in:
Olaf Alders 2014-07-14 12:58:51 -04:00
parent 2d5812cf10
commit dd9a1c6ab7

View file

@ -304,27 +304,31 @@ Business::PayPal::API - PayPal API
use Business::PayPal::API qw( ExpressCheckout GetTransactionDetails ); use Business::PayPal::API qw( ExpressCheckout GetTransactionDetails );
## certificate authentication ## certificate authentication
my $pp = new Business::PayPal::API my $pp = Business::PayPal::API->new(
( Username => 'my_api1.domain.tld', Username => 'my_api1.domain.tld',
Password => 'this_is_my_password', Password => 'this_is_my_password',
PKCS12File => '/path/to/cert.pkcs12', PKCS12File => '/path/to/cert.pkcs12',
PKCS12Password => '(pkcs12 password)', PKCS12Password => '(pkcs12 password)',
sandbox => 1 ); sandbox => 1,
);
## PEM cert authentication ## PEM cert authentication
my $pp = new Business::PayPal::API my $pp = Business::PayPal::API->new(
( Username => 'my_api1.domain.tld', Username => 'my_api1.domain.tld',
Password => 'this_is_my_password', Password => 'this_is_my_password',
CertFile => '/path/to/cert.pem', CertFile => '/path/to/cert.pem',
KeyFile => '/path/to/cert.pem', KeyFile => '/path/to/cert.pem',
sandbox => 1 ); sandbox => 1,
);
## 3-token (Signature) authentication ## 3-token (Signature) authentication
my $pp = new Business::PayPal::API my $pp = Business::PayPal::API->new(
( Username => 'my_api1.domain.tld', Username => 'my_api1.domain.tld',
Password => 'Xdkis9k3jDFk39fj29sD9', ## supplied by PayPal Password => 'Xdkis9k3jDFk39fj29sD9', ## supplied by PayPal
Signature => 'f7d03YCpEjIF3s9Dk23F2V1C1vbYYR3ALqc7jm0UrCcYm-3ksdiDwjfSeii', ## ditto Signature =>
sandbox => 1 ); 'f7d03YCpEjIF3s9Dk23F2V1C1vbYYR3ALqc7jm0UrCcYm-3ksdiDwjfSeii', ## ditto
sandbox => 1,
);
my %response = $pp->SetExpressCheckout( ... ); my %response = $pp->SetExpressCheckout( ... );
@ -345,13 +349,13 @@ This allows for much more concise and intuitive usage. For example,
these two statements are equivalent: these two statements are equivalent:
use Business::PayPal::API::RefundTransaction; use Business::PayPal::API::RefundTransaction;
my $pp = new Business::PayPal::API::RefundTransaction( ... ); my $pp = Business::PayPal::API::RefundTransaction->new( ... );
$pp->RefundTransaction( ... ); $pp->RefundTransaction( ... );
and more concisely: and more concisely:
use Business::PayPal::API qw( RefundTransaction ); use Business::PayPal::API qw( RefundTransaction );
my $pp = new Business::PayPal::API( ... ); my $pp = Business::PayPal::API->new( ... );
$pp->RefundTransaction( ... ); $pp->RefundTransaction( ... );
The advantage of this becomes clear when you need to use multiple API The advantage of this becomes clear when you need to use multiple API
@ -363,7 +367,7 @@ PayPal APIs with the same object:
use Business::PayPal::API qw( GetTransactionDetails use Business::PayPal::API qw( GetTransactionDetails
TransactionSearch TransactionSearch
RefundTransaction ); RefundTransaction );
my $pp = new Business::PayPal::API( ... ); my $pp = Business::PayPal::API->new( ... );
my $records = $pp->TransactionSearch( ... ); my $records = $pp->TransactionSearch( ... );
my %details = $pp->GetTransactionDetails( ... ); my %details = $pp->GetTransactionDetails( ... );
@ -604,7 +608,7 @@ sure:
$ENV{HTTPS_CERT_FILE} = '/var/path/to/cert.pem'; $ENV{HTTPS_CERT_FILE} = '/var/path/to/cert.pem';
## create our paypal object ## create our paypal object
my $pp = new Business::PayPal::API... my $pp = Business::PayPal::API->new(...)
* if you have already loaded Net::SSLeay (or IO::Socket::SSL), then * if you have already loaded Net::SSLeay (or IO::Socket::SSL), then
Net::HTTPS will prefer to use IO::Socket::SSL. I don't know how Net::HTTPS will prefer to use IO::Socket::SSL. I don't know how
@ -709,14 +713,14 @@ That is, B<Business::PayPal::API> will import any subroutine into its
own namespace from the B<@EXPORT_OK> array. Now it can be used like this: own namespace from the B<@EXPORT_OK> array. Now it can be used like this:
use Business::PayPal::API qw( SomeAPI ); use Business::PayPal::API qw( SomeAPI );
my $pp = new Business::PayPal::API( ... ); my $pp = Business::PayPal::API->new( ... );
$pp->SomeAPIMethod( ... ); $pp->SomeAPIMethod( ... );
Of course, we also do a 'use Business::PayPal::API' in the module so Of course, we also do a 'use Business::PayPal::API' in the module so
that it can be used as a standalone module, if necessary: that it can be used as a standalone module, if necessary:
use Business::PayPal::API::SomeAPI; use Business::PayPal::API::SomeAPI;
my $pp = new Business::PayPal::API::SomeAPI( ... ); ## same args as superclass my $pp = Business::PayPal::API::SomeAPI->new( ... ); ## same args as superclass
$pp->SomeAPIMethod( ... ); $pp->SomeAPIMethod( ... );
Adding the B<@EXPORT_OK> array in your module allows your module to be Adding the B<@EXPORT_OK> array in your module allows your module to be