How to Get Invoice Details Using the Invoicing Service

Important: The NVP/SOAP integration method for Invoicing is Deprecated. For new integrations, see the REST Invoicing Overview.

This guide describes how to obtain status information on your PayPal invoices using the GetInvoiceDetails operation.

For information on creating invoices, see How to Send an Invoice Using the Invoicing Service.

1. Set up the Headers

Set up the HTTP headers and the endpoint:

# GetInvoiceDetails HTTP headers (-H)
-H "X-PAYPAL-SECURITY-USERID: caller_UID"     # UserID from the Caller account
-H "X-PAYPAL-SECURITY-PASSWORD: caller_PSWD"  # Password from the Caller account
-H "X-PAYPAL-SECURITY-SIGNATURE: caller_Sig"  # Signature from the Caller account
-H "X-PAYPAL-REQUEST-DATA-FORMAT: JSON"
-H "X-PAYPAL-RESPONSE-DATA-FORMAT: JSON"
-H "X-PAYPAL-APPLICATION-ID: APP-80W284485P519543T"    # Sandbox AppID

# Endpoint (Sandbox in the example)
https://svcs.sandbox.paypal.com/Invoice/GetInvoiceDetails

2. Set Up the Payload

Set up the call payload using the invoiceID associated with the invoice in question. This value is generated and returned when the invoice is created.

{
  "requestEnvelope": {
    "errorLanguage": "en_US",       # Language of returned errors
    "detailLevel": "ReturnAll"
  },
  "invoiceID": "idOfInvoice"
}

Send the Request

Here's the complete example formatted in cURL notation that's wrapped for readability. Add your API credentials and remove the line breaks to run the example on a command line.

curl https://svcs.sandbox.paypal.com/Invoice/GetInvoiceDetails \
  -s \
  --insecure \
  -H "X-PAYPAL-SECURITY-USERID: caller_UID" \
  -H "X-PAYPAL-SECURITY-PASSWORD: caller_Pswd" \
  -H "X-PAYPAL-SECURITY-SIGNATURE: caller_Sig" \
  -H "X-PAYPAL-REQUEST-DATA-FORMAT: JSON" \
  -H "X-PAYPAL-RESPONSE-DATA-FORMAT: JSON" \
  -H "X-PAYPAL-APPLICATION-ID: appID" \
  -d '{
        "requestEnvelope": {
          "errorLanguage":"en_US",
          "detailLevel":"ReturnAll"
        },
        "invoiceID":"idOfInvoice"
      }'

If successful, the call response will be similar to the following output. This example shows the details from the invoice that was created in the How to Send an Invoice Using the Invoicing Service guide.

{
  "responseEnvelope": {
    "ack": "Success",
    #...
  },
  "invoice": {
    "merchantEmail": "caller_1334790960_biz@yourdomain.com",
    "payerEmail": "sender_1334790586_per@yourdomain.com",
    "number": "1192",
    "itemList": {
      "item": [{
        "name": "BananaPlant",
        "quantity": "1.000",
        "unitPrice": "12.00"
      }, {
        "name": "PeachPlant",
        "quantity": "2.000",
        "unitPrice": "14.00"
      }]
    },
    "currencyCode": "USD",
    "invoiceDate": "2012-04-24T12:00:00.000-07:00",
    "dueDate": "2012-04-24T12:00:00.000-07:00",
    "paymentTerms": "DueOnReceipt",
    "discountAmount": "0.00",
    "shippingAmount": "0.00"
  },
  "invoiceDetails": { "status":"Paid",
    "totalAmount": "40.00",
    "origin": "API",
    "createdDate": "2012-04-24T16:19:16.000-07:00",
    "createdBy": "caller_1334790960_biz@yourdomain.com",
    "lastUpdatedDate": "2012-04-24T16:19:16.000-07:00",
    "firstSentDate": "2012-04-24T16:19:17.000-07:00",
    "lastSentDate": "2012-04-24T16:19:17.000-07:00",
    "lastSentBy": "caller_1334790960_biz@yourdomain.com",
    "paidDate": "2012-04-24T16:36:14.000-07:00"
  },
  "paymentDetails": {
    "viaPayPal": "true",
    "paypalPayment": {
      "transactionID": "04H79913MT186660J",
      "date": "2012-04-24T16:36:14.000-07:00"
    }
  },
  "invoiceURL": "https://www.sandbox.paypal.com/us/cgi-bin/?cmd=_inv-details&id=invoiceId"
}

You can see the status of this invoice is Paid, making for a happy merchant.

Learn More

For more information about the Invoicing service, see the following resources:

Note: For instructions on using the PayPal APIs, how to use the Sandbox for testing, and how to move your app into production, see Apps 101.

Feedback

Have feedback?

Let us know.