Test and go live with Invoicing

DOCSCURRENT

Last updated: Feb 27th, 8:11am

You can run negative tests on your integration to manage the responses you give to your customers.

Know before you code

  • Before you trigger a simulation, you'll need to get an access token.
  • Use Postman to explore and test PayPal APIs.

.

Optional
Explore PayPal APIs with Postman

You can use Postman to explore and test PayPal APIs. Learn more in our Postman guide.

Simulation methods

To trigger a simulation for the Invoices API, you can use a JSON pointer in the request payload or a path parameter in the request URI.

Test values are case sensitive.

Using a JSON pointer in the request payload

Trigger Test value Simulated Error Response
detail/reference ERRINV002 PERMISSION_DENIED

Request

    1curl -X POST \
    2 https://api-m.sandbox.paypal.com/v2/invoicing/invoices \
    3 -H 'Authorization: Bearer <Access Token>' \
    4 -H "PayPal-Partner-Attribution-Id: <BN-Code>" \
    5 -H 'Content-Type: application/json' \
    6 -d '{
    7 "detail":
    8 {
    9 "reference": "ERRINV002"
    10 }
    11}'

    Response

      1{
      2 "localizedMessage": "No permission for the requested operation. ",
      3 "name": "PERMISSION_DENIED",
      4 "message": "No permission for the requested operation. ",
      5 "details": [
      6 {
      7 "issue": "No permission for the requested operation. "
      8 }
      9 ],
      10 "information_link": "https://developer.paypal.com/docs/archive/permissions-service/",
      11 "debug_id": "6e07326c281c4"
      12}

      Use a path parameter in the request URI

      Trigger or test valueSimulated error response
      /v2/invoicing/invoices/INV2-ABCD-1234-EINV-0010INVOICE_NOT_FOUND

      Request

        1curl -X GET \
        2 https://api-m.sandbox.paypal.com/v2/invoicing/invoices/INV2-ABCD-1234-EINV-0010 \
        3 -H 'Authorization: Bearer <Access Token>' \
        4 -H 'Content-Type: application/json'

        Response

          1{
          2 "name": "RESOURCE_NOT_FOUND",
          3 "message": "The specified resource does not exist.",
          4 "debug_id": "98b2b9d2d89cb",
          5 "links": [
          6 {
          7 "href": "https://developer.paypal.com/docs/api/invoicing/#errors",
          8 "rel": "information_link"
          9 }
          10 ]
          11}

          Test values

          Test values are case sensitive.

          Generate invoice number

          Use the path parameter in the request URI method to simulate the following error responses at POST /v2/invoicing/invoices/generate-next-invoice-number.

          TriggerTest valueSimulated error response
          referenceERRINV066INTERNAL_SERVER_ERROR
          referenceERRINV067PERMISSION_DENIED

          Create invoices

          Use the JSON pointer method to simulate the following error responses at POST v2/invoicing/invoices/.

          TriggerTest valueSimulated positive response
          detail.referenceERRINV001INTERNAL_SERVER_ERROR
          detail.referenceERRINV002PERMISSION_DENIED
          detail.referenceERRINV003UNSUPPORTED_MEDIA_TYPE
          detail.referenceERRINV004VALIDATION_ERROR_EMPTY_BODY
          detail.referenceERRINV005INVALID_REQUEST_GENERIC
          detail.referenceERRINV006INVALID_REQUEST_SCHEMA_VIOLATION

          Get invoice

          Use the path parameter in the request URI method to simulate the following error responses at GET /v2/invoicing/invoices/{invoice_id}.

          Trigger or test valueSimulated error response
          /v2/invoicing/invoices/INV2-ABCD-1234-EINV-0007INTERNAL_SERVER_ERROR
          /v2/invoicing/invoices/INV2-ABCD-1234-EINV-0008PERMISSION_DENIED
          /v2/invoicing/invoices/INV2-ABCD-1234-EINV-0009UNAUTHORIZED_ACCESS
          /v2/invoicing/invoices/INV2-ABCD-1234-EINV-0010INVOICE_NOT_FOUND

          Delete invoice

          Use the path parameter in the request URI method to simulate the following response at DELETE /v2/invoicing/invoices/{invoice_id}.

          Trigger or test valueSimulated positive response
          /v2/invoicing/invoices/INV2-ABCD-1234-EINV-0059PAYLOAD WITH 200 RESPONSE CODE

          Use the path parameter in the request URI method to simulate the following error responses at DELETE /v2/invoicing/invoices/{invoice_id}.

          Trigger or test valueSimulated error response
          /v2/invoicing/invoices/INV2-ABCD-1234-EINV-0055INTERNAL_SERVER_ERROR
          /v2/invoicing/invoices/INV2-ABCD-1234-EINV-0056PERMISSION_DENIED
          /v2/invoicing/invoices/INV2-ABCD-1234-EINV-0057UNAUTHORIZED_ACCESS
          /v2/invoicing/invoices/INV2-ABCD-1234-EINV-0058INVOICE_NOT_FOUND

          Fully update invoice details

          Use the path parameter in the request URI method to simulate the following error responses at PUT /v2/invoicing/invoices/{invoice_id}.

          Trigger or test valueSimulated error response
          /v2/invoicing/invoices/INV2-ABCD-1234-EINV-0060INTERNAL_SERVER_ERROR
          /v2/invoicing/invoices/INV2-ABCD-1234-EINV-0061PERMISSION_DENIED
          /v2/invoicing/invoices/INV2-ABCD-1234-EINV-0062UNSUPPORTED_MEDIA_TYPE
          /v2/invoicing/invoices/INV2-ABCD-1234-EINV-0063VALIDATION_ERROR_EMPTY_BODY
          /v2/invoicing/invoices/INV2-ABCD-1234-EINV-0064INVALID_REQUEST_GENERIC
          /v2/invoicing/invoices/INV2-ABCD-1234-EINV-0065INVALID_REQUEST_SCHEMA_VIOLATION

          Cancel sent invoice

          Use the path parameter in the request URI method to simulate the following response at POST /v2/invoicing/invoices/{invoice_id}/cancel.

          Trigger or test valueSimulated positive response
          /v2/invoicing/invoices/INV2-ABCD-1234-EINV-0029/cancelPAYLOAD WITH 204 RESPONSE CODE

          Use the path parameter in the request URI method to simulate the following error responses at POST /v2/invoicing/invoices/{invoice_id}/cancel.

          Trigger or test valueSimulated error response
          /v2/invoicing/invoices/INV2-ABCD-1234-EINV-0024/cancelINTERNAL_SERVER_ERROR
          /v2/invoicing/invoices/INV2-ABCD-1234-EINV-0025/cancelPERMISSION_DENIED
          /v2/invoicing/invoices/INV2-ABCD-1234-EINV-0026/cancelUNAUTHORIZED_ACCESS
          /v2/invoicing/invoices/INV2-ABCD-1234-EINV-0027/cancelINVOICE_NOT_FOUND
          /v2/invoicing/invoices/INV2-ABCD-1234-EINV-0028/cancelCANT_CANCEL_INVOICE_IN_DRAFT_STATE

          Record payment for invoice

          Use the path parameter in the request URI method to simulate the following response at POST /v2/invoicing/invoices/{invoice_id}/payments.

          Trigger or test valueSimulated positive response
          /v2/invoicing/invoices/INV2-ABCD-1234-EINV-0037/paymentsPAYLOAD WITH 200 RESPONSE CODE

          Use the path parameter in the request URI method to simulate the following error responses at POST /v2/invoicing/invoices/{invoice_id}/payments.

          Trigger or test valueSimulated error response
          /v2/invoicing/invoices/INV2-ABCD-1234-EINV-0031/paymentsINTERNAL_SERVER_ERROR
          /v2/invoicing/invoices/INV2-ABCD-1234-EINV-0032/paymentsPERMISSION_DENIED
          /v2/invoicing/invoices/INV2-ABCD-1234-EINV-0033/paymentsUNAUTHORIZED_ACCESS
          /v2/invoicing/invoices/INV2-ABCD-1234-EINV-0034/paymentsINVOICE_NOT_FOUND
          /v2/invoicing/invoices/INV2-ABCD-1234-EINV-0035/paymentsCANT_PAY_AN_PAID_OR_CANCELED_INVOICE
          /v2/invoicing/invoices/INV2-ABCD-1234-EINV-0036/paymentsCANT_PAY_MORE_THAN_INVOICE_AMOUNT

          Delete payment

          Use the path parameter in the request URI method to simulate the following response at DELETE /v2/invoicing/invoices/INV2-ABCD-1234-EFGH-5678/payments/{transaction_id}.

          Trigger or test valueSimulated positive response
          /v2/invoicing/invoices/INV2-ABCD-1234-EFGH-5678/payments/EXT-ABCDEFGHERRINV042PAYLOAD WITH 200 RESPONSE CODE

          Use the path parameter in the request URI method to simulate the following error responses at DELETE /v2/invoicing/invoices/INV2-ABCD-1234-EFGH-5678/payments/{transaction_id}.

          Trigger or test valueSimulated error response
          /v2/invoicing/invoices/INV2-ABCD-1234-EFGH-5678/payments/EXT-ABCDEFGHERRINV038INTERNAL_SERVER_ERROR
          /v2/invoicing/invoices/INV2-ABCD-1234-EFGH-5678/payments/EXT-ABCDEFGHERRINV039PERMISSION_DENIED
          /v2/invoicing/invoices/INV2-ABCD-1234-EFGH-5678/payments/EXT-ABCDEFGHERRINV040UNAUTHORIZED_ACCESS
          /v2/invoicing/invoices/INV2-ABCD-1234-EFGH-5678/payments/EXT-ABCDEFGHERRINV041PAYMENT_OR_INVOICE_NOT_FOUND

          Record refund for invoice

          Use the path parameter in the request URI method to simulate the following response at POST /v2/invoicing/invoices/{invoice_id}/refunds.

          Trigger or test valueSimulated positive response
          /v2/invoicing/invoices/INV2-ABCD-1234-EINV-0049/refundsPAYLOAD WITH 200 RESPONSE CODE

          Use the path parameter in the request URI method to simulate the following error responses at POST /v2/invoicing/invoices/{invoice_id}/refunds.

          Trigger or test valueSimulated error response
          /v2/invoicing/invoices/INV2-ABCD-1234-EINV-0043/refundsINTERNAL_SERVER_ERROR
          /v2/invoicing/invoices/INV2-ABCD-1234-EINV-0044/refundsPERMISSION_DENIED
          /v2/invoicing/invoices/INV2-ABCD-1234-EINV-0045/refundsUNAUTHORIZED_ACCESS
          /v2/invoicing/invoices/INV2-ABCD-1234-EINV-0046/refundsINVOICE_NOT_FOUND
          /v2/invoicing/invoices/INV2-ABCD-1234-EINV-0047/refundsCANT_REFUND_A_CANCELED_INVOICE
          /v2/invoicing/invoices/INV2-ABCD-1234-EINV-0048/refundsCANT_REFUND_MORE_THAN_PAYMENT_AMOUNT

          Delete refund

          Use the path parameter in the request URI method to simulate the following response at DELETE /v2/invoicing/invoices/{invoice_id}/refunds/{transaction_id}.

          Trigger or test valueSimulated positive response
          /v2/invoicing/invoices/INV2-ABCD-1234-EFGH-5678/refunds/EXT-ABCDEFGHERRINV054PAYLOAD WITH 200 RESPONSE CODE

          Use the path parameter in the request URI method to simulate the following error responses at DELETE /v2/invoicing/invoices/{invoice_id}/refunds/{transaction_id}/delete.

          Trigger or test valueSimulated error response
          /v2/invoicing/invoices/INV2-ABCD-1234-EFGH-5678/refunds/EXT-ABCDEFGHERRINV050INTERNAL_SERVER_ERROR
          /v2/invoicing/invoices/INV2-ABCD-1234-EFGH-5678/refunds/EXT-ABCDEFGHERRINV051PERMISSION_DENIED
          /v2/invoicing/invoices/INV2-ABCD-1234-EFGH-5678/refunds/EXT-ABCDEFGHERRINV052UNAUTHORIZED_ACCESS
          /v2/invoicing/invoices/INV2-ABCD-1234-EFGH-5678/refunds/EXT-ABCDEFGHERRINV053REFUND_OR_INVOICE_NOT_FOUND

          Send invoice reminder

          Use the path parameter in the request URI method to simulate the following response at POST /v2/invoicing/invoices/{invoice_id}/remind.

          Trigger or test valueSimulated positive response
          /v2/invoicing/invoices/INV2-ABCD-1234-EINV-0023/remindPAYLOAD WITH 200 RESPONSE CODE

          Use the path parameter in the request URI method to simulate the following error responses at POST /v2/invoicing/invoices/{invoice_id}/remind.

          Trigger or test valueSimulated error response
          /v2/invoicing/invoices/INV2-ABCD-1234-EINV-0017/remindINTERNAL_SERVER_ERROR
          /v2/invoicing/invoices/INV2-ABCD-1234-EINV-0018/remindPERMISSION_DENIED
          /v2/invoicing/invoices/INV2-ABCD-1234-EINV-0019/remindUNAUTHORIZED_ACCESS
          /v2/invoicing/invoices/INV2-ABCD-1234-EINV-0020/remindINVOICE_NOT_FOUND
          /v2/invoicing/invoices/INV2-ABCD-1234-EINV-0021/remindCANT_REMIND_INVOICE_IN_DRAFT_STATE
          /v2/invoicing/invoices/INV2-ABCD-1234-EINV-0022/remindCANT_REMIND_INVOICE_WITHOUT_BILLING_INFO

          Send invoice

          Use the path parameter in the request URI method to simulate the following response at POST /v2/invoicing/invoices/{invoice_id}/send.

          Trigger or test valueSimulated positive response
          /v2/invoicing/invoices/INV2-ABCD-1234-EINV-0016/sendPAYLOAD WITH 200 RESPONSE CODE

          Use the path parameter in the request URI method to simulate the following error responses at POST /v2/invoicing/invoices/{invoice_id}/send.

          Trigger or test valueSimulated error response
          /v2/invoicing/invoices/INV2-ABCD-1234-EINV-0011/sendINTERNAL_SERVER_ERROR
          /v2/invoicing/invoices/INV2-ABCD-1234-EINV-0012/sendPERMISSION_DENIED
          /v2/invoicing/invoices/INV2-ABCD-1234-EINV-0013/sendUNAUTHORIZED_ACCESS
          /v2/invoicing/invoices/INV2-ABCD-1234-EINV-0014/sendINVOICE_NOT_FOUND
          /v2/invoicing/invoices/INV2-ABCD-1234-EINV-0015/sendCANT_SEND_INVOICE_WITHOUT_EMAIL
          /v2/invoicing/invoices/INV2-ABCD-1234-EINV-0030/sendCANT_SEND_ALREADY_SENT_INVOICE

          Search invoices

          Use the path parameter in the request URI method to simulate the following error responses at POST /v2/invoicing/search-invoices.

          Trigger or test valueSimulated error response
          ERRINV068INTERNAL_SERVER_ERROR
          ERRINV069PERMISSION_DENIED
          ERRINV070INVALID_REQUEST

          Go live

          1. Change the base URL for all your REST API calls from https://api-m.sandbox.paypal.com to https://api-m.paypal.com.
          2. Change the references to your sandbox API credentials to the live credentials. To get live API credentials, create a live REST API.

          If you accept cookies, we’ll use them to improve and customize your experience and enable our partners to show you personalized PayPal ads when you visit other sites. Manage cookies and learn more