NAME

WWW::PayPal::API::Orders - PayPal Checkout / Orders v2 API

VERSION

version 0.002

SYNOPSIS

my $order = $pp->orders->create(
    intent         => 'CAPTURE',
    purchase_units => [{
        amount => { currency_code => 'EUR', value => '42.00' },
    }],
    return_url => 'https://example.com/paypal/return',
    cancel_url => 'https://example.com/paypal/cancel',
);

my $same = $pp->orders->get($order->id);
my $done = $pp->orders->capture($order->id);

DESCRIPTION

Controller for PayPal's Checkout / Orders v2 API. Dispatches via cached OpenAPI operationId entries.

client

The parent WWW::PayPal client providing HTTP transport.

openapi_operations

Pre-computed operation table (operationId{method, path}).

checkout

my $order = $pp->orders->checkout(
    amount     => '9.99',
    currency   => 'EUR',
    return_url => 'https://example.com/paypal/return',
    cancel_url => 'https://example.com/paypal/cancel',

    # optional
    intent              => 'CAPTURE',       # or 'AUTHORIZE'
    brand_name          => 'Amiga Event',
    locale              => 'de-DE',
    user_action         => 'PAY_NOW',       # default
    shipping_preference => 'NO_SHIPPING',   # or GET_FROM_FILE / SET_PROVIDED_ADDRESS
    description         => 'Ticket XYZ',
    invoice_id          => 'INV-2026-0042',
    custom_id           => 'user-123',
    soft_descriptor     => 'AMIGAEVENT',
    reference_id        => 'cart-42',
    items => [
        { name => 'Ticket', quantity => 1, unit_amount => '9.99', sku => 'T1' },
    ],
    shipping => {
        name    => { full_name => 'Jane Doe' },
        address => { country_code => 'DE', postal_code => '10115', ... },
    },
);

$c->redirect_to($order->approve_url);

High-level convenience wrapper around "create" — the modern replacement for the NVP ExpressCheckout flow. Builds the purchase_units and application_context structures for the common single-item checkout so callers don't have to.

When items is given, the amount breakdown.item_total is filled in automatically (PayPal requires it as soon as items are present).

For multi-unit orders, multi-seller orders, or anything else outside this happy path, use "create" directly.

create

my $order = $pp->orders->create(
    intent         => 'CAPTURE',
    purchase_units => [ ... ],
    return_url     => '...',
    cancel_url     => '...',
);

Creates an order and returns a WWW::PayPal::Order. The buyer must be redirected to $order->approve_url to approve the payment.

get

my $order = $pp->orders->get($id);

Fetches an order by ID.

capture

my $order = $pp->orders->capture($id);

Captures an approved order. Returns the updated WWW::PayPal::Order with a completed capture attached.

authorize

my $order = $pp->orders->authorize($id);

Places an authorization on an approved order (alternative to immediate capture).

SUPPORT

Issues

Please report bugs and feature requests on GitHub at https://github.com/Getty/p5-www-paypal/issues.

CONTRIBUTING

Contributions are welcome! Please fork the repository and submit a pull request.

AUTHOR

Torsten Raudssus <torsten@raudssus.de> https://raudssus.de/

COPYRIGHT AND LICENSE

This software is copyright (c) 2026 by Torsten Raudssus.

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