We use essential cookies for the website to function, as well as analytics cookies for analyzing and creating statistics of the website performance. To agree to the use of analytics cookies, click "Accept All". You can manage your preferences at any time by clicking "Cookie Settings" on the footer. More Information.

Only Essential Cookies
Accept All
ReferencesApplication ServicesAccount KitArkTS APIsinvoiceAssistant (Invoice Assistant Service)

invoiceAssistant (Invoice Assistant Service)

This module provides the invoice assistant capability of Account Kit.

Since: 5.0.0(12)

Modules to Import

Collapse
Word wrap
Dark theme
Copy code
  1. import { invoiceAssistant } from '@kit.AccountKit';

InvoiceAssistantErrorCode

Enumeration that defines error codes of APIs related to the invoice assistant service of Account Kit.

Model restriction: This API can be used only in the stage model.

Atomic service API: This API can be used in atomic services since API version 5.0.0(12).

System capability: SystemCapability.HuaweiID.InvoiceAssistant

Since: 5.0.0(12)

Expand
Name Value Description
USER_CANCELED 1010060001 The user cancels the invoice assistant service.
SYSTEM_ERROR 1010060002 Internal system error.
APP_NOT_AUTHORIZED 1010060003 The certificate fingerprint of the app fails to be verified.
FREQUENT_CALLS 1010060004 The API is called too frequently.
NETWORK_ERROR 1010060005 Network connection error.
ACCOUNT_NOT_LOGGED_IN 1010060006 The user has not signed in with their HUAWEI ID.
INVOICE_TITLE_EXISTS 1010060007 The invoice title already exists.
UNSUPPORTED 1010060008 The invoice assistant service is unavailable for the HUAWEI ID signed in.

InvoiceTitle

Invoice title data object returned by the invoice assistant service.

Model restriction: This API can be used only in the stage model.

Atomic service API: This API can be used in atomic services since API version 5.0.0(12).

System capability: SystemCapability.HuaweiID.InvoiceAssistant

Since: 5.0.0(12)

Expand
Name Type Read-Only Optional Description
type string No No Title type. The options are 0 (individual) and 1 (enterprise).
title string No No Title name.
taxNumber string No No Taxpayer identification number. For a title of the enterprise type, the actual value is returned. For a title of the individual type, an empty string is returned.
companyAddress string No No Company address. For a title of the enterprise type, the actual value is returned. For a title of the individual type, an empty string is returned.
telephone string No No Phone number of a company. For a title of the enterprise type, the actual value is returned. For a title of the individual type, an empty string is returned.
bankName string No No Bank name of a company. For a title of the enterprise type, the actual value is returned. For a title of the individual type, an empty string is returned.
bankAccount string No No Bank account of a company. For a title of the enterprise type, the actual value is returned. For a title of the individual type, an empty string is returned.

selectInvoiceTitle

selectInvoiceTitle(context: common.Context): Promise<InvoiceTitle>

Shows the invoice title selection screen and returns the invoice title selected by a user. This API uses a promise to return the result.

Model restriction: This API can be used only in the stage model.

Atomic service API: This API can be used in atomic services since API version 5.0.0(12).

System capability: SystemCapability.HuaweiID.InvoiceAssistant

Since: 5.0.0(12)

Parameters:

Expand
Parameter Type Mandatory Description
context common.Context Yes

Context.

The following contexts are supported for apps: UIAbilityContext and UIExtensionContext. Apps cannot use UIExtensionContext in non-full-screen components such as semi-modal, pop-up, and sub-window components.

The following context is supported for atomic services: UIAbilityContext.

Returns:

Expand
Type Description
Promise<InvoiceTitle> InvoiceTitle object returned through a promise.

Error codes:

For details about the error codes, please refer to ArkTS Error Codes.

Expand
ID Error Message
401 Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.
1010060001 The operation was canceled by the user.
1010060002 System internal error.
1010060003 Failed to check the fingerprint of the app bundle.
1010060004 Too frequent API calls.
1010060005 Network connection error.
1010060006 The HUAWEI ID is not signed in.
1010060007 Failed to create a invoice title because the title already exists.
1010060008 The invoice service does not support the logged HUAWEI ID.

Example:

Collapse
Word wrap
Dark theme
Copy code
  1. import { invoiceAssistant } from '@kit.AccountKit';
  2. import { hilog } from '@kit.PerformanceAnalysisKit';
  3. import { BusinessError } from '@kit.BasicServicesKit';
  4. // Execute the request.
  5. if (canIUse('SystemCapability.HuaweiID.InvoiceAssistant')) {
  6. try {
  7. // The following provides only code snippets. Use it in the custom component instance and pass a valid context object.
  8. invoiceAssistant.selectInvoiceTitle(this.getUIContext().getHostContext())
  9. .then((data: invoiceAssistant.InvoiceTitle) => {
  10. hilog.info(0x0000, 'testTag', 'Succeeded in selecting invoice title');
  11. const type: string = data.type;
  12. const title: string = data.title;
  13. const taxNumber: string = data.taxNumber;
  14. const companyAddress: string = data.companyAddress;
  15. const telephone: string = data.telephone;
  16. const bankName: string = data.bankName;
  17. const bankAccount: string = data.bankAccount;
  18. // Process type, title, taxNumber, companyAddress, telephone, bankName, and bankAccount.
  19. // ...
  20. })
  21. .catch((error: BusinessError<Object>) => {
  22. dealAllError(error);
  23. });
  24. } catch (error) {
  25. dealAllError(error);
  26. }
  27. } else {
  28. hilog.info(0x0000, 'testTag',
  29. 'The current device does not support the invoking of the selectInvoiceTitle interface.');
  30. }
  31. // Handle the error.
  32. function dealAllError(error: BusinessError<Object>): void {
  33. hilog.error(0x0000, 'testTag', `Failed to authorize. Code: ${error.code}, message: ${error.message}`);
  34. }
Search in References
Enter a keyword.