Driver FixRecommendedSound, Wi-Fi or graphics acting up? Check drivers firstFind missing or outdated drivers fast.Check DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run Scan×
Skip to content
World desk6 min

PHP cURL for PayPal Payments Standard: Legacy IPN and REST Migration

Payments Standard and NVP/SOAP are legacy PayPal patterns. See how to validate an existing IPN listener safely and why new PHP integrations should use REST Checkout with OAuth 2.0 and cURL.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

PayPal Payments Standard is a legacy hosted-checkout integration, not the pattern to choose for a new PHP project. If you are maintaining an existing Standard integration, keep its IPN listener isolated, validate each notification with PayPal before acting on it, and make fulfillment idempotent. For new work, use PayPal’s REST APIs with OAuth 2.0: obtain an access token, create an order, let the payer approve it, then capture the order from your server.

What “PHP cURL to PayPal Website Payments Standard” means

Payments Standard sends the buyer through a PayPal-hosted payment flow. A merchant can use Instant Payment Notification (IPN) to receive server-to-server notices about a payment or a later event. The notification is asynchronous: it is not the same thing as an immediate response to the buyer’s browser, and it must be validated before it is trusted.

As an Amazon Associate I earn from qualifying purchases.

PayPal labels the NVP/SOAP integration method legacy and says it accepts new integrations and supports existing ones, while recommending newer solutions for new integrations. That makes the title’s older PHP cURL pattern mainly relevant to maintaining or migrating an existing integration.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

IPN and the customer’s return page do different jobs

The return page is part of the buyer-facing flow; an IPN listener is a separate server endpoint that PayPal calls. A customer returning to your site is not, by itself, reliable proof that payment completed. Conversely, IPN may arrive after the buyer has left, so it should not be the only mechanism for displaying an immediate transaction result.

#1 Best Overall
Sale
Square Reader for contactless and chip (2nd Generation)
  • Use the, easy-to-use, and customizable POS to get started.
  • Accept contactless payments, chip cards, Apple Pay, and Google Pay from anywhere, with improved connectivity, extended battery life, and enhanced security. Pay one low rate for every tap or dip.
  • No long-term commitments or contracts, no monthly fees- and with offline payments, keep taking payments for up to 24 hours.
  • Safely and securely accepts payments anywhere. Plus, get data security, 24/7 fraud prevention, and payment-dispute management at no extra cost.
  • Use the, easy-to-use, and customizable POS to get started.

Choose the flow that matches the work

Choice Best fit What to account for
Payments Standard with IPN Maintaining an existing hosted-checkout integration while it remains in use. IPN is asynchronous. Read and validate the notification with PayPal before fulfillment, and handle repeated events safely.
REST Checkout with cURL Building a new integration or moving away from the legacy flow. Use OAuth 2.0 and JSON. The server creates an order, the payer approves it in checkout, and the server captures it.
IPN versus an immediate API result IPN for server notifications about payment or later events; an API response when the application needs an immediate result from its own request. Do not treat an asynchronous notification as a synchronous checkout response.
Hand-written cURL versus a server SDK cURL when the team wants to implement the HTTP requests directly; a maintained server SDK when it supports the REST operations the application needs. Whichever approach you use, retain the same environment separation, error handling, and safe fulfillment behavior.

Build a current PHP cURL flow with REST

PayPal’s current server-side sequence is to request an OAuth access token, create an order with POST /v2/checkout/orders, have the payer approve that order through checkout, and capture it with POST /v2/checkout/orders/{ORDER_ID}/capture. REST requests use JSON and a Bearer access token. The order request includes the intent and purchase-unit amount data; use the values your application actually intends to charge.

Keep the environment consistent

For development, use sandbox credentials and the sandbox API base URL https://api-m.sandbox.paypal.com. For live payments, use live credentials and https://api-m.paypal.com. The endpoint, credentials, and notification configuration must belong to the same environment. PayPal says a Business account is needed to go live.

Rank #2
Square Reader for magstripe (USB-C)
  • Get your money as soon as the next business day.
  • Get set up quickly with no long-term commitments. Download the Square Point of Sale app for free, create an account, and start taking payments anywhere.
  • Run your business all in one place with the free Square Point of Sale app. Track your sales, manage inventory, accept tips, send receipts digitally, and more.
  • Works with Apple devices with a Lightning connector.

Use a shared cURL helper for JSON requests

The following helper illustrates the common request mechanics for the create-order and capture calls. Supply a valid access token, the appropriate endpoint path, and a JSON payload for the operation. It deliberately treats HTTP errors as failures rather than assuming that a completed cURL transfer means a successful payment.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
<?php
function paypalRequest(string $baseUrl, string $path, string $accessToken, ?array $payload = null): array
{
    $ch = curl_init(rtrim($baseUrl, '/') . $path);
    $headers = [
        'Authorization: Bearer ' . $accessToken,
        'Content-Type: application/json',
        'Accept: application/json',
    ];

    $options = [
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_HTTPHEADER => $headers,
        CURLOPT_CONNECTTIMEOUT => 10,
        CURLOPT_TIMEOUT => 30,
        CURLOPT_SSL_VERIFYPEER => true,
    ];

    if ($payload !== null) {
        $json = json_encode($payload, JSON_THROW_ON_ERROR);
        $options[CURLOPT_POST] = true;
        $options[CURLOPT_POSTFIELDS] = $json;
    }

    curl_setopt_array($ch, $options);
    $body = curl_exec($ch);
    $curlError = curl_error($ch);
    $status = (int) curl_getinfo($ch, CURLINFO_HTTP_CODE);
    curl_close($ch);

    if ($body === false) {
        throw new RuntimeException('PayPal request failed: ' . $curlError);
    }

    $decoded = json_decode($body, true);
    if ($status < 200 || $status >= 300) {
        throw new RuntimeException('PayPal returned HTTP ' . $status . ': ' . $body);
    }
    if (!is_array($decoded)) {
        throw new RuntimeException('PayPal returned an unreadable JSON response.');
    }

    return $decoded;
}

$baseUrl = 'https://api-m.sandbox.paypal.com';
// Obtain this token through PayPal OAuth using the sandbox app credentials.
$accessToken = $tokenFromOAuth;

$order = paypalRequest($baseUrl, '/v2/checkout/orders', $accessToken, $orderPayload);
// After the payer approves the order in checkout:
$orderId = $order['id'];
$capture = paypalRequest(
    $baseUrl,
    '/v2/checkout/orders/' . rawurlencode($orderId) . '/capture',
    $accessToken,
    []
);

$orderPayload should contain the intent and purchase-unit amount data required for the order, and $tokenFromOAuth represents the access token acquired from PayPal’s OAuth flow; neither value should be hard-coded as a secret in source control. Use the approval experience for the order before attempting capture. Check the capture response and your order state before fulfilling; make the capture/fulfillment path safe to retry so a repeated request does not cause duplicate fulfillment.

Rank #3
Square Terminal - Credit Card Machine to Accept All Payments | Mobile POS
  • With Square Terminal, you can ring up sales, accept payments, and print receipts, all with one device. Use it at the counter or ring up customers anywhere in your store.
  • Accept all major credit and debit cards and pay one low rate with no hidden fees and no long-term contracts.
  • Process chip cards in just two seconds.
  • Get your money as soon as the next business day.
  • Use it cordlessly with the built-in battery, designed to last all day.

Handle failures and operational records

  • Keep certificate verification enabled and set explicit connection and total timeouts; do not disable TLS verification to work around a connection problem.
  • Treat every non-2xx HTTP response as an error that needs handling. Record useful request and response identifiers for support and reconciliation, but never log client secrets or access tokens.
  • Keep sandbox and live credentials separate, and switch both the credentials and base URL together only after end-to-end sandbox testing.
  • Design capture and fulfillment to be idempotent. A timeout can leave the caller uncertain whether a request completed, so retry logic must not blindly create a second fulfillment.

Maintain a legacy IPN listener safely

If an existing Payments Standard integration still depends on IPN, treat the listener as a verification endpoint, not as a public form that can directly mark an order paid. PayPal’s legacy IPN guidance describes reading the incoming POST, sending the message back to PayPal for validation over HTTPS, and acting only on PayPal’s documented validation result.

  1. Read the raw POST body as received by the listener. Do not reconstruct the notification from selected form fields.
  2. Append PayPal’s validation command to the received message and POST it over HTTPS to the validation endpoint for the matching sandbox or live environment.
  3. Accept the notification only when PayPal returns the documented validation result. Reject invalid or unverified messages without fulfilling the order.
  4. Acknowledge valid notifications promptly with HTTP 200, then process fulfillment safely and idempotently. Store enough event and order state to recognize an event you have already handled.

IPN is asynchronous, so keep the buyer-facing response separate from the listener’s work. If the page must show transaction information immediately, use an appropriate immediate response such as a response from your API flow rather than waiting for IPN.

Rank #4
Square Reader for magstripe (with Lightning connector)
  • Pay one transparent rate per swipe for Visa, Mastercard, Discover and American Express.
  • Works in conjunction with most downloadable Square point-of-sale apps on your device. Customers can pay, tip and sign directly on your device. Track payments in cash, gift cards and more. Also lets you send receipts via e-mail or text message, makes it easy to apply discounts, keeps a data and sales history log and more.
  • Accepts magstripe credit card payments, including those from Visa, Mastercard, Discover and American Express (fees apply).
  • App sends deposits to your bank account within 1 to 2 business days, or enjoy instant deposits (fees apply).
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Plan the migration away from deprecated PHP SDKs

The PayPal-PHP-SDK and merchant-sdk-php repositories are deprecated. Their older documentation may still help explain a legacy codebase, but those libraries should not be the foundation of a new integration. For a migration, isolate the existing listener and legacy payment handling while existing transactions are retired, then move new checkout work to the current REST Orders and Payments APIs.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Quick Recap

SaleBestseller No. 1
Square Reader for contactless and chip (2nd Generation)
Square Reader for contactless and chip (2nd Generation)
Use the, easy-to-use, and customizable POS to get started.; Use the, easy-to-use, and customizable POS to get started.
$47.20
Bestseller No. 2
Square Reader for magstripe (USB-C)
Square Reader for magstripe (USB-C)
Get your money as soon as the next business day.; Works with Apple devices with a Lightning connector.
$9.88
Bestseller No. 3
Square Terminal - Credit Card Machine to Accept All Payments | Mobile POS
Square Terminal - Credit Card Machine to Accept All Payments | Mobile POS
Process chip cards in just two seconds.; Get your money as soon as the next business day.; Use it cordlessly with the built-in battery, designed to last all day.
$298.99
Bestseller No. 4
Square Reader for magstripe (with Lightning connector)
Square Reader for magstripe (with Lightning connector)
Pay one transparent rate per swipe for Visa, Mastercard, Discover and American Express.
$9.88
Best Value
Protective Bumper Case for PayPal Card Reader (Black)
  • COMPATIBILITY: Custom-designed protective case specifically made to fit PayPal card reader devices securely
  • PROTECTION: Durable bumper design shields against drops, scratches, and daily wear while maintaining full device functionality
  • ACCESS: Precisely cut openings ensure unrestricted access to all ports, buttons, and card slot without removing the case
  • GRIP ENHANCEMENT: Textured exterior surface provides improved handling and prevents slipping during transactions
  • PORTABLE DESIGN: Lightweight and slim profile allows for easy storage in pockets or bags while maintaining complete protection
  • Inventory where the application creates payments, handles buyer returns, processes IPN, and marks orders fulfilled.
  • Keep the legacy listener in place only for the existing flow that still needs it; do not mix its notification handling into the new REST order path.
  • Implement the REST order, payer-approval, and capture sequence against sandbox credentials first.
  • Test successful payment, failed requests, delayed notifications where applicable, and safe retries before switching live traffic.

PayPal documentation

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.