Busine...ayments(3pm)

πŸ“¦
version 0.77 Β· 5 versions
, in ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– Business::PayPal::API::DirectPayments β€” the 3pm manual, but make it cute ✨

okay so bestie, you found the Business::PayPal::API::DirectPayments page β€” it's one of the user-contributed Perl docs, and it's literally the ✨PayPal DirectPayments API✨ wrapper. Yeah. We're doing payments. In Perl. In 2006 energy. But it still slaps, so let's go πŸ’…


πŸŽ€ VERSION

version 0.77 β€” that's the one, no cap.


✨ SYNOPSIS

okay so here's the whole vibe. First you use it (and grab DirectPayments in the import list, don't forget that part, it's giving necessary):

use Business::PayPal::API qw(DirectPayments);

## see Business::PayPal::API documentation for parameters

my $pp = Business::PayPal::API->new(
                    Username => 'name_api1.example.org',
                    Password => 'somepass',
                    CertFile => '/path/to/tester1.cert_key_pem.txt',
                    KeyFile  => '/path/to/tester1.cert_key_pem.txt',
                    sandbox  => 1,
                    );

my %response = $pp->DoDirectPaymentRequest (
                    PaymentAction      => 'Sale',
                    OrderTotal         => 13.59,
                    TaxTotal           => 0.0,
                    ShippingTotal      => 0.0,
                    ItemTotal          => 0.0,
                    HandlingTotal      => 0.0,
                    InvoiceID          => 'your-tracking-number',
                    CreditCardType     => 'Visa',
                    CreditCardNumber   => '4561435600988217',
                    ExpMonth           => '01',
                    ExpYear            => '2007',
                    CVV2               => '123',
                    FirstName          => 'James',
                    LastName           => 'PuffDaddy',
                    Street1            => '1st Street LaCausa',
                    Street2            => '',
                    CityName           => 'La',
                    StateOrProvince    => 'Ca',
                    PostalCode         => '90210',
                    Country            => 'US',
                    Payer              => 'Joe@Example.org',
                    ShipToName         => 'Jane Doe',
                    ShipToStreet1      => '1234 S. Pleasant St.',
                    ShipToStreet2      => 'Suite #992',
                    ShipToCityName     => 'Vacation Town',
                    ShipToStateOrProvince => 'FL',
                    ShipToCountry      => 'US',
                    ShipToPostalCode   => '12345',
                    CurrencyID         => 'USD',
                    IPAddress          => '10.0.0.1',
                    MerchantSessionID  => '10113301',
                    );

the way that LastName => 'PuffDaddy' is just sitting there in the official docs?? iconic. we love a legacy codebase 🫢


🌸 DESCRIPTION

so like, Business::PayPal::API::DirectPayments implements PayPal's DirectPayments API using SOAP::Lite to make direct API calls to PayPal's SOAP API server. It also implements support for testing via PayPal's sandbox 🧚 β€” and if you want the details on using that PayPal sandbox, go read Business::PayPal::API, that's where the tea is.

πŸ’³ DoDirectPaymentRequest

This bad boy implements PayPal's DoDirectPaymentRequest API call. Supported parameters include:

  • PaymentAction β€” (Sale|Authorize, Sale is default)
  • OrderTotal
  • TaxTotal
  • ShippingTotal
  • ItemTotal
  • HandlingTotal
  • InvoiceID
  • CreditCardType
  • CreditCardNumber
  • ExpMonth β€” (two digits, leading zero)
  • ExpYear β€” (four digits, 20XX)
  • CVV2
  • FirstName
  • LastName
  • Street1
  • Street2
  • CityName
  • StateOrProvince
  • PostalCode
  • Country
  • Payer
  • ShipToName
  • ShipToStreet1
  • ShipToStreet2
  • ShipToCityName
  • ShipToStateOrProvince
  • ShipToCountry
  • ShipToPostalCode
  • CurrencyID β€” (USD is default)
  • IPAddress
  • MerchantSessionID

…and these are all, like, described in the PayPal "Web Services API Reference" document. That's where you go for the deep lore πŸ“–

It returns a hash containing the results of the transaction. And the two most useful return values? The Ack element and TransactionID. Those are the main characters of your return hash, fr fr πŸ‘‘

Example β€” here's how it actually looks in the wild:

my %resp = $pp->DoDirectPaymentRequest(
                  PaymentAction => 'Sale',
                  OrderTotal    => '10.99',
                  ...
           );

unless( $resp{Ack} !~ /Success/ ) {
    for my $error ( @{$response{Errors}} ) {
        warn "Error: " . $error->{LongMessage} . "\n";
    }
}

😭 ERROR HANDLING

stuff went wrong? don't spiral, bestie. Go see the ERROR HANDLING section of Business::PayPal::API for all the info on handling errors. that's the whole assignment.

πŸ“¦ EXPORT

None by default. yeah. nothing. zero. nada. you have to ask for what you want, which honestly? boundaries. we respect it πŸŽ€


πŸ‘€ SEE ALSO


πŸ‘‘ AUTHORS

  • Scott Wiersdorf <scott@perlcode.org>
  • Danny Hembree <danny@dynamical.org>
  • Bradley M. Kuhn <bkuhn@ebb.org>

three absolute legends, honestly πŸ™Œ


This software is copyright (c) 2006-2017 by Scott Wiersdorf, Danny Hembree, Bradley M. Kuhn.

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

okay so like β€” that's the legal bit, and it's genuinely permissive, so rest easy 🌈

and that's the whole page, bestie! this one shipped with perl v5.36.0, dated 2022-08-28, under the title Busine...ayments(3pm) πŸ’– slay, go charge some credit cards responsibly, and remember: Sale is the default but Authorize is always an option 😌✨

πŸ“¦ where this page comes from