$120 tested Claude codes · real before/after data · Full tier $15 one-timebuy --sheet=15 →
$Free 40-page Claude guide — setup, 120 prompt codes, MCP servers, AI agents. download --free →
clskills.sh — terminal v2.4 — 2,347 skills indexed● online
[CL]Skills_
PaymentsintermediateNew

PayPal Integration

Share

Integrate PayPal payments and checkout

Works with OpenClaude

You are a backend payment systems developer. The user wants to integrate PayPal payments and checkout into their application using the PayPal REST API.

What to check first

  • Install the official PayPal SDK: npm install @paypal/checkout-server-sdk
  • Verify you have PayPal Client ID and Secret from the PayPal Developer Dashboard
  • Check your Node.js version supports async/await (v7.6+)

Steps

  1. Create a PayPal client configuration using your Client ID and Secret from the sandbox or live environment
  2. Set up environment detection (sandbox vs. live) via environment variables PAYPAL_CLIENT_ID and PAYPAL_CLIENT_SECRET
  3. Create an order endpoint that accepts item details and returns a PayPal order ID to the frontend
  4. Implement capture endpoint that finalizes payment after user approves on PayPal
  5. Add error handling for declined payments, expired orders, and network failures
  6. Store order reference and PayPal transaction ID in your database for reconciliation
  7. Implement webhook listener for PAYMENT.CAPTURE.COMPLETED events for async confirmation
  8. Test in sandbox mode before switching to live credentials

Code

const paypal = require('@paypal/checkout-server-sdk');

// Initialize PayPal client
function initPayPalClient() {
  const clientId = process.env.PAYPAL_CLIENT_ID;
  const clientSecret = process.env.PAYPAL_CLIENT_SECRET;
  
  const environment = process.env.NODE_ENV === 'production'
    ? new paypal.core.LiveEnvironment(clientId, clientSecret)
    : new paypal.core.SandboxEnvironment(clientId, clientSecret);
  
  return new paypal.core.PayPalHttpClient(environment);
}

// Create PayPal order
async function createOrder(items, returnUrl, cancelUrl) {
  const client = initPayPalClient();
  
  const request = new paypal.orders.OrdersCreateRequest();
  request.prefer('return=representation');
  request.requestBody({
    intent: 'CAPTURE',
    purchase_units: [
      {
        amount: {
          currency_code: 'USD',
          value: calculateTotal(items),
          breakdown: {
            item_total: {
              currency_code: 'USD',
              value: calculateSubtotal(items)
            },
            tax_total: {
              currency_code: 'USD',
              value: calculateTax(items)
            }
          }
        },
        items: items.map(item => ({
          name: item.name,
          unit_amount: {
            currency_code: 'USD',
            value: item.price
          },
          quantity: item.quantity
        }))
      }
    ],
    application_context: {
      return_url: returnUrl,
      cancel_url: cancelUrl,
      brand_name: '

Note: this example was truncated in the source. See the GitHub repo for the latest full version.

Common Pitfalls

  • Treating this skill as a one-shot solution — most workflows need iteration and verification
  • Skipping the verification steps — you don't know it worked until you measure
  • Applying this skill without understanding the underlying problem — read the related docs first

When NOT to Use This Skill

  • When a simpler manual approach would take less than 10 minutes
  • On critical production systems without testing in staging first
  • When you don't have permission or authorization to make these changes

How to Verify It Worked

  • Run the verification steps documented above
  • Compare the output against your expected baseline
  • Check logs for any warnings or errors — silent failures are the worst kind

Production Considerations

  • Test in staging before deploying to production
  • Have a rollback plan — every change should be reversible
  • Monitor the affected systems for at least 24 hours after the change

Quick Info

CategoryPayments
Difficultyintermediate
Version1.0.0
AuthorClaude Skills Hub
paymentspaypalcheckout

Install command:

curl -o ~/.claude/skills/paypal-integration.md https://claude-skills-hub.vercel.app/skills/payments/paypal-integration.md

Related Payments Skills

Other Claude Code skills in the same category — free to download.

Want a Payments skill personalized to YOUR project?

This is a generic skill that works for everyone. Our AI can generate one tailored to your exact tech stack, naming conventions, folder structure, and coding patterns — with 3x more detail.