Skip to the content

DoRoutes API · version 1

Payments

GET/v1/pay/{token}

The invoice a pay link names

The firm's website calls this for /pay/{token}, the link in an invoice's email. Answers while the invoice is owed and the business takes payments online; otherwise 404. Limited to 30 calls a minute per address (429).

Parameters

  • tokenstring, in the path, required

Response 200 · object

The invoice.

  • invoicePayPage, required

    An invoice as its customer sees it on a pay link.

    • numberstring, required
    • issued_onstring (date), required
    • due_onstring (date), required
    • linesarray of InvoiceLine, required
      • idinteger (int64), required
      • descriptionstring, required
      • quantitystring, required
      • unit_penceinteger (int64), required
      • vat_ratestring, required

        One of: standard reduced zero exempt none

      • net_penceinteger (int64), required
    • totalsobject, required
    • paid_penceinteger (int64), required
    • owed_penceinteger (int64), required
    • pay_witharray of string, required

      The providers the invoice can be paid with, in the order to offer them.

      One of: stripe paypal

Example response 200
{
  "invoice": {
    "number": "string",
    "issued_on": "date",
    "due_on": "date",
    "lines": [
      {
        "id": 0,
        "description": "string",
        "quantity": "string",
        "unit_pence": 0,
        "vat_rate": "standard",
        "net_pence": 0
      }
    ],
    "totals": {},
    "paid_pence": 0,
    "owed_pence": 0,
    "pay_with": [
      "stripe"
    ]
  }
}

Response 401 · Error

No tenant key, or no valid session.

  • errorobject, required
    • codestring, required

      A short machine-readable name, such as not_found.

    • messagestring, required

      What went wrong, for people.

  • request_idstring, required

    Matches the X-Request-ID response header.

Example response 401
{
  "error": {
    "code": "string",
    "message": "string"
  },
  "request_id": "string"
}

Response 404 · Error

Not found, or not yours.

Fields as in The invoice a pay link names

Response 429 · Error

Too many attempts; see Retry-After.

Fields as in The invoice a pay link names

Response 500 · Error

Something failed on our side.

Fields as in The invoice a pay link names

POST/v1/pay/{token}

Pay the invoice a pay link names

Opens the payment page of the provider the body names (one of the pay page's pay_with; the first when none) for what the invoice still owes, coming back to the website's /pay/done?attempt={ref}. 404 as for GET; 409 for a provider the business doesn't take payments with. Limited to 30 calls a minute per address (429).

Parameters

  • tokenstring, in the path, required

Request body · object

  • providerstring

    One of: stripe paypal

Example request
{
  "provider": "stripe"
}

Response 200 · object

The payment page.

  • checkout_urlstring, required
Example response 200
{
  "checkout_url": "string"
}

Response 401 · Error

No tenant key, or no valid session.

Fields as in The invoice a pay link names

Response 404 · Error

Not found, or not yours.

Fields as in The invoice a pay link names

Response 429 · Error

Too many attempts; see Retry-After.

Fields as in The invoice a pay link names

Response 500 · Error

Something failed on our side.

Fields as in The invoice a pay link names

GET/v1/pay/attempts/{ref}

How a payment went

The status of the payment the website's return page names by its ref, and nothing else. Only the provider's webhook changes it, so the page asks again while it is "open". Limited to 30 calls a minute per address (429).

Parameters

  • refstring, in the path, required

Response 200 · object

The status.

  • paymentobject, required
    • statusstring, required

      One of: open held succeeded failed expired released refunded

Example response 200
{
  "payment": {
    "status": "open"
  }
}

Response 401 · Error

No tenant key, or no valid session.

Fields as in The invoice a pay link names

Response 404 · Error

Not found, or not yours.

Fields as in The invoice a pay link names

Response 429 · Error

Too many attempts; see Retry-After.

Fields as in The invoice a pay link names

Response 500 · Error

Something failed on our side.

Fields as in The invoice a pay link names

GET/v1/payments/{provider}/return

Finish connecting a payment provider

Where the provider sends the browser after the firm signs in; no tenant key or session, as the sealed state names the firm (Stripe sends it as state, PayPal as merchantId, the partner referral's tracking ID, with merchantIdInPayPal, permissionsGranted and consentStatus). Redirects to the admin UI's Settings → Payments with connected={provider}, or with error saying why (an account another firm holds, or a second account while one is connected, is refused).

Parameters

  • providerstring, in the path, required
  • codestring, in the query
  • statestring, in the query
  • merchantIdstring, in the query
  • merchantIdInPayPalstring, in the query
  • permissionsGrantedstring, in the query
  • consentStatusstring, in the query
  • errorstring, in the query

Response 302

To the admin UI.

POST/v1/webhooks/{provider}

A payment provider's webhook

For the provider only; no tenant key or session. The body is checked against the provider's signature (Stripe-Signature; PayPal's checked by PayPal, a 500 while PayPal can't be reached) and the firm found by the event's connected account. Each event is applied once. An event for an account no active firm holds is answered and ignored.

Parameters

  • providerstring, in the path, required

Request body · object

Example request
{}

Response 200 · object

Received.

  • receivedboolean, required
Example response 200
{
  "received": true
}

Response 400 · Error

The request is not valid.

Fields as in The invoice a pay link names

Response 404 · Error

Not found, or not yours.

Fields as in The invoice a pay link names

Response 500 · Error

Something failed on our side.

Fields as in The invoice a pay link names

GET/v1/admin/payments/connections

The payment connections

Needs the payments.manage permission. The firm's connections that aren't disconnected and the providers offered.

Response 200 · object

The connections.

  • paymentsPaymentsOverview, required
    • connectionsarray of PaymentConnection, required
      • idinteger (int64), required
      • providerstring, required

        One of: stripe paypal

      • account_idstring, required

        The firm's account with the provider.

      • statusstring, required

        "onboarding" until the firm has given the provider its details; "active" while the provider lets it take payments; "restricted" when it has stopped them.

        One of: onboarding active restricted disconnected

      • connected_atstring, required

        UTC, YYYY-MM-DD HH:MM:SS.

    • providersarray of string, required
Example response 200
{
  "payments": {
    "connections": [
      {
        "id": 0,
        "provider": "stripe",
        "account_id": "string",
        "status": "onboarding",
        "connected_at": "string"
      }
    ],
    "providers": [
      "string"
    ]
  }
}

Response 401 · Error

No tenant key, or no valid session.

Fields as in The invoice a pay link names

Response 403 · Error

The session may not do this.

Fields as in The invoice a pay link names

Response 500 · Error

Something failed on our side.

Fields as in The invoice a pay link names

POST/v1/admin/payments/connections/{provider}

Where to connect a payment provider

Needs the payments.manage permission. The provider's sign-in address, carrying a sealed state that names the firm, the staff member and the provider, good for 10 minutes. The provider sends the browser back to /v1/payments/{provider}/return.

Parameters

  • providerstring, in the path, required

Response 200 · object

The address.

  • connectobject, required
    • urlstring, required
Example response 200
{
  "connect": {
    "url": "string"
  }
}

Response 401 · Error

No tenant key, or no valid session.

Fields as in The invoice a pay link names

Response 403 · Error

The session may not do this.

Fields as in The invoice a pay link names

Response 404 · Error

Not found, or not yours.

Fields as in The invoice a pay link names

Response 500 · Error

Something failed on our side.

Fields as in The invoice a pay link names

DELETE/v1/admin/payments/connections/{provider}

Disconnect a payment provider

Needs the payments.manage permission. Tells the provider DoRoutes no longer acts for the firm's account and marks the connection disconnected; customers can't pay online through it. 404 when the firm has no connection with the provider.

Parameters

  • providerstring, in the path, required

Response 200 · object

The connections.

  • paymentsPaymentsOverview, required
    • connectionsarray of PaymentConnection, required
      • idinteger (int64), required
      • providerstring, required

        One of: stripe paypal

      • account_idstring, required

        The firm's account with the provider.

      • statusstring, required

        "onboarding" until the firm has given the provider its details; "active" while the provider lets it take payments; "restricted" when it has stopped them.

        One of: onboarding active restricted disconnected

      • connected_atstring, required

        UTC, YYYY-MM-DD HH:MM:SS.

    • providersarray of string, required
Example response 200
{
  "payments": {
    "connections": [
      {
        "id": 0,
        "provider": "stripe",
        "account_id": "string",
        "status": "onboarding",
        "connected_at": "string"
      }
    ],
    "providers": [
      "string"
    ]
  }
}

Response 401 · Error

No tenant key, or no valid session.

Fields as in The invoice a pay link names

Response 403 · Error

The session may not do this.

Fields as in The invoice a pay link names

Response 404 · Error

Not found, or not yours.

Fields as in The invoice a pay link names

Response 500 · Error

Something failed on our side.

Fields as in The invoice a pay link names