Online Renewal Invoice API
This document contains five invoice APIs for the frontend in the online renewal process: invoice title query, invoice application submission, single order and batch invoice progress query, and electronic invoice download.
General Conventions
- API prefix:
/v3/console/package-renewal-order - APIs require the existing console login session. User identity and order ownership are obtained by the server from the login session. Do not and must not pass
unionIdin the request. - The
POSTof the request isContent-Typeapplication/json. - Successful response format:
{ "code": 200, "status": "success", "data": ... }. - For failed responses, the
statusiserror, with error details inerror.codeanderror.desc. The frontend should usestatus === "success"to determine business success.
Order List Invoice Eligibility Fields
The following fields are added to each order item in GET /v3/console/package-renewal-order/list:
| Field | Type | Description |
|---|---|---|
canApplyInvoice |
Boolean | Whether an online invoice can be applied. It is true only when the order is a live_console online renewal order, the payment status is successful, and the creation time is not earlier than the launch time configured in ONLINE_INVOICE_LAUNCH_AT. |
invoiceApplicationStatus |
String | Current invoice application status. It is null when canApplyInvoice=false; NOT_APPLIED when eligible but not applied; PROCESSING (processing), ISSUED (invoiced), or FAILED (application failed) when applied. |
The frontend only handles the invoice entry for orders where canApplyInvoice=true: display "Apply for Invoice" for NOT_APPLIED, display "Download Invoice" for ISSUED, and show the application progress for other statuses. The batch query API can be used for partial status refresh.
Server State Synchronization
After a customer submits an application, the application status is initially PROCESSING. The payment service polls PCS/CRM according to the cycle configured in ONLINE_INVOICE_POLL_INTERVAL_SECONDS, and writes ISSUED, FAILED, invoice number, PDF URL, and failure reason back to the application table; polling stops once a final state is reached. Polling uses database leases to prevent multiple instances from updating the same application. The frontend does not need to rely on page refreshes to advance the status.
1. Query Historical Invoice Titles
Query existing invoice titles in CRM by company name to auto-fill the taxpayer identification number. Returns an empty array if no record is found; this does not indicate a request failure.
Request
GET /v3/console/package-renewal-order/invoice-title
| Parameter | Location | Type | Required | Description |
|---|---|---|---|---|
companyName |
Query | String | Yes | Company name; query by exact name. |
Request example:
GET /v3/console/package-renewal-order/invoice-title?companyName=广州保利云科技有限公司
Response Data
data is an array:
| Field | Type | Description |
|---|---|---|
companyName |
String | Invoice title (company name). |
taxpayerId |
String | Taxpayer identification number. |
Response example:
{
"code": 200,
"status": "success",
"data": [
{
"companyName": "广州保利云科技有限公司",
"taxpayerId": "91440101MA5XXXXXXX"
}
]
}
It is recommended that the frontend call this after the user finishes entering the company name; if multiple records are returned, allow the user to select the corresponding taxpayer identification number.
2. Submit Invoice Application
Submit an electronic invoice application for the current logged-in user's online renewal order. The server validates order ownership and eligibility conditions, and handles duplicate submissions for the same order idempotently.
Request
POST /v3/console/package-renewal-order/invoice-application
Request body fields:
| Field | Type | Required | Description |
|---|---|---|---|
orderId |
String | Yes | Online renewal order ID. |
invoiceType |
String | Yes | Invoice type: VAT_SPECIAL (VAT special invoice) or VAT_NORMAL (VAT general invoice). |
companyName |
String | Yes | Invoice title (company name), cannot be empty. |
taxpayerId |
String | Yes | Taxpayer identification number, cannot be empty. |
Request example:
{
"orderId": "renewal_order_123456",
"invoiceType": "VAT_NORMAL",
"companyName": "广州保利云科技有限公司",
"taxpayerId": "91440101MA5XXXXXXX"
}
Response Data
data is the invoice application information:
| Field | Type | Description |
|---|---|---|
orderId |
String | Renewal order ID. |
requestNo |
String | Invoice application serial number, used to associate this application. |
invoiceType |
String | Invoice type, same value as the request parameter. |
companyName |
String | Invoice title. |
taxpayerId |
String | Taxpayer identification number. |
amountCent |
Long | Invoice amount, in cents; divide by 100 for display. |
status |
Integer | Invoice status code; status enumeration is based on server response. |
statusName |
String | Invoice status name, can be directly used by the frontend for display. |
invoiceApplicationStatus |
String | Status enumeration consistent with the order list: NOT_APPLIED, PROCESSING, ISSUED, FAILED. Will not return NOT_APPLIED if there is an application record. |
invoiceNo |
String | Invoice number; may be empty if not yet invoiced. |
pdfUrl |
String | Electronic invoice PDF URL; may be empty if not yet invoiced. |
failureReason |
String | Reason for invoice failure; only returned on failure. |
Response example:
{
"code": 200,
"status": "success",
"data": {
"orderId": "renewal_order_123456",
"requestNo": "invoice_request_123456",
"invoiceType": "VAT_NORMAL",
"companyName": "广州保利云科技有限公司",
"taxpayerId": "91440101MA5XXXXXXX",
"amountCent": 99800
}
}
The example only shows core fields; the actual response will include invoice status and invoice information as per the table above. Disable repeated clicks before submission; even if duplicate submissions occur due to network retries, the server handles idempotency per order. Successful submission only means the application has been accepted.
3. Query Invoice Progress
Query the invoice application status for a specified renewal order of the current logged-in user. This API synchronizes the latest status from CRM and is suitable for calling after application submission or when refreshing the order detail page.
Request
GET /v3/console/package-renewal-order/invoice-application
| Parameter | Location | Type | Required | Description |
|---|---|---|---|---|
orderId |
Query | String | Yes | Online renewal order ID. |
Request example:
GET /v3/console/package-renewal-order/invoice-application?orderId=renewal_order_123456
Response Data
The complete fields of data are consistent with the response data in Section 2 "Submit Invoice Application". Focus on the following fields:
| Field | Type | Description |
|---|---|---|
status |
Integer | Invoice status code; status enumeration is based on server response. |
statusName |
String | Invoice status name, can be directly used for page display. |
invoiceApplicationStatus |
String | Application status consistent with the order list: NOT_APPLIED if not applied, PROCESSING, ISSUED, or FAILED if applied. |
invoiceNo |
String | Returns the invoice number when invoiced. |
pdfUrl |
String | Returns the PDF URL when the electronic invoice is generated. |
failureReason |
String | Returns the failure reason when invoicing fails. |
Response example:
{
"code": 200,
"status": "success",
"data": {
"orderId": "renewal_order_123456",
"requestNo": "invoice_request_123456",
"statusName": "开票中",
"invoiceApplicationStatus": "PROCESSING"
}
}
When the order has not been applied for, the API returns:
{
"code": 200,
"status": "success",
"data": {
"orderId": "renewal_order_123456",
"invoiceApplicationStatus": "NOT_APPLIED"
}
}
4. Batch Query Invoice Progress
Used for batch determination of action items in the order list. This API only accepts paid renewal orders eligible for online invoicing belonging to the current logged-in user; if any order does not meet the conditions, the entire request returns a business failure.
Request
POST /v3/console/package-renewal-order/invoice-application/batch
Request body fields:
| Field | Type | Required | Description |
|---|---|---|---|
orderIds |
String[] | Yes | List of order IDs, cannot be empty, maximum 100 per request; duplicate IDs are automatically deduplicated. |
Request example:
{
"orderIds": [
"renewal_order_123456",
"renewal_order_654321"
]
}
Response Data
data is an object keyed by order ID. Each value contains invoiceApplicationStatus, whose value is consistent with the order list field; orders that have not been applied only return orderId and invoiceApplicationStatus=NOT_APPLIED.
{
"code": 200,
"status": "success",
"data": {
"renewal_order_123456": {
"orderId": "renewal_order_123456",
"statusName": "已开票",
"invoiceApplicationStatus": "ISSUED",
"invoiceNo": "1234567890",
"pdfUrl": "https://example.com/invoices/invoice_request_123456.pdf"
},
"renewal_order_654321": {
"orderId": "renewal_order_654321",
"invoiceApplicationStatus": "NOT_APPLIED"
}
}
}
Order list display rules: Display "Apply for Invoice" when invoiceApplicationStatus=NOT_APPLIED; display "Download Invoice" when ISSUED; show application progress for other statuses. Do not use the status numeric value for frontend branching.
5. Get Electronic Invoice PDF Download URL
Get the electronic invoice PDF URL for an invoiced renewal order of the current logged-in user. If the order has not been invoiced, the server returns a business failure response.
Request
GET /v3/console/package-renewal-order/invoice-download
| Parameter | Location | Type | Required | Description |
|---|---|---|---|---|
orderId |
Query | String | Yes | Online renewal order ID. |
Request example:
GET /v3/console/package-renewal-order/invoice-download?orderId=renewal_order_123456
Response Data
The complete fields of data are consistent with the response data in Section 2 "Submit Invoice Application", where pdfUrl is the core field of this API. After obtaining pdfUrl, the frontend can open it in a new window or handle it according to the existing download strategy.
Response example:
{
"code": 200,
"status": "success",
"data": {
"orderId": "renewal_order_123456",
"requestNo": "invoice_request_123456",
"invoiceNo": "1234567890",
"pdfUrl": "https://example.com/invoices/invoice_request_123456.pdf"
}
}
Recommended Call Sequence
- After the user fills in the company name, call "Query Historical Invoice Titles" to auto-fill or select the taxpayer identification number.
- After the user confirms the invoice information, call "Submit Invoice Application".
- Call "Batch Query Invoice Progress" in the order list; call "Query Invoice Progress" on the order detail page or application result page, and display the status based on
statusNameandfailureReason. - After invoicing, call "Get Electronic Invoice PDF Download URL" and use the returned
pdfUrlto download or preview the invoice.
