LogoLogo
System Status
  • Digital River API
  • Getting started
  • Using our services
    • Local pricing
    • Item classification
    • Subscriptions
    • e-Invoicing
  • Integration options
    • Low-code checkouts
      • Implementing a Prebuilt Checkout
      • Implementing a Components checkout
      • Offering local pricing
      • Using a shipping endpoint
      • Processing subscription acquisitions
      • Adding custom fields
      • Offering store credit
      • Displaying policies and getting consent
      • Collecting e-invoice information
      • Handling completed checkout-sessions
    • Direct integrations
      • Standard flow
      • Building checkouts
        • Checking out guest and registered customers
        • Describing line items
          • Setting the price of an item
          • Managing items with shared SKU identifiers
        • Providing address information
        • Handling shipping choice
        • Tax identifiers
        • Applying a discount
        • Setting the customer type
        • Providing the IP address
        • Selecting a currency
        • Initiating a charge
        • Setting the purchase location
        • Configuring taxes
        • Accessing regulatory fee information
        • Localizing invoices and credit memos
        • Providing an upstream identifier
        • Applying store credit
        • Handling e-invoicing requirements
        • Landed cost
        • Tax calculation inputs
        • Selling entities
        • Payment sessions
        • Applying store credit (legacy)
        • Country specs
      • Building payment workflows
        • Handling redirect payment methods
        • Handling delayed payment methods
      • Subscription acquisitions
        • Handling subscription acquisitions
        • Handling external subscription acquisitions
        • Subscription information
      • Digital River coordinated fulfillments
        • Checking inventory levels
        • Using shipping quotes
        • Reserving inventory items
        • Managing a fulfillment order
        • Cancelling a fulfillment order
    • Connectors
  • Order management
    • Processing orders
    • Handling a rejected order
    • Accessing invoices and credit memos
    • Fulfilling goods and services
    • Capturing and cancelling charges
    • Payment reauthorizations
    • Handling reversals
      • Return basics
        • Digital River coordinated returns
        • Third party coordinated returns
      • Refund basics
        • Issuing refunds
        • Refunding asynchronous payment methods
      • Disputes and chargebacks
    • Customer notifications
    • Responding to events
      • Events
        • Key event types
        • All event types
      • Webhooks
        • Creating a webhook
        • Digital River API safelist
        • Digital River signature
      • Expanding events
      • Preventing webhooks from getting disabled
    • Distributor model
  • Subscription Management
    • Managing a subscription
    • Managing an external subscription
  • Payments
    • Payment solutions
      • Drop-in payments
        • How Drop-in payments work
        • Drop-in payments integration guide
      • DigitalRiver.js with Elements
        • Elements integration guide
        • Configuring payment methods
          • Configuring Afterpay
          • Configuring Alipay+ (cross-border)
          • Configuring Alipay (domestic)
          • Configuring Amazon Pay
          • Configuring Apple Pay
          • Configuring Bancontact
          • Configuring BNP Paribas
          • Configuring BLIK
          • Configuring CCAvenue
          • Configuring Clearpay
          • Configuring Credit Cards
          • Configuring FPX Online Banking
          • Configuring Google Pay
          • Configuring iDEAL
          • Configuring Klarna
          • Configuring Konbini
          • Configuring Online Banking (IBP)
          • Configuring Online Banking (Korea Bank Transfer)
          • Configuring PayCo
          • Configuring PayPal
          • Configuring SEPA Direct Debit
          • Configuring Trustly
          • Configuring Wire Transfer
          • Common payment sources
          • Common payment objects
    • Supported payment methods
      • Afterpay
      • Alipay (domestic)
      • Alipay+ (cross-border)
      • Amazon Pay
      • Apple Pay
      • Bancontact
      • BNP Paribas
      • BLIK
      • CCAvenue
      • Clearpay
      • Credit Cards
      • FPX Online Banking
      • Google Pay
      • iDEAL
      • Klarna
      • Konbini
      • Korea Bank Transfer (Online Banking)
      • Online Banking (IBP)
      • Pay with Installments France
      • PayCo
      • PayPal
      • PayPal Billing Agreement
      • PayPal Credit
      • PayPal Pay in 3
      • PayPal Pay in 4
      • PayPal RatenZahlung (Installment Payment)
      • SEPA Direct Debit
      • Trustly
      • Wire Transfer
    • Source basics
      • Managing sources
      • Handling credit card sources
      • Retrieving sources
    • Authorization declines
    • PSD2 and SCA
      • How to ensure SCA compliance
    • Payment testing scenarios
  • Product management
    • Product basics
    • Managing SKUs
    • Using product details
    • Grouping SKUs
    • SKU-inventory item pairs
    • Managing inventory items
    • Regulatory fees
      • What are regulatory fees?
        • Fees terminology
        • Regulatory fee management
        • European regulatory fees
        • Compliance obligations
        • WEEE directive requirements
        • Copyright directive requirements
        • Compliance challenges
      • Managing regulatory fees
  • Customer management
    • Customer basics
    • Creating and updating customers
    • Setting up tax exemptions
    • Recording a customer's request to be forgotten
  • Financial reporting
    • Financials basics
    • Sales transactions
      • Returning a list of sales transactions
      • Getting a sales transaction by ID
    • Sales summaries
      • Returning a list of sales summaries
      • Getting a sales summary by ID
    • Payouts
      • Returning a list of payouts
      • Getting a payout by ID
      • Get a list of transactions included in payout by ID
  • Developer resources
    • Digital River API reference
    • DigitalRiver.js reference
      • Including DigitalRiver.js
      • Initializing DigitalRiver.js
      • DigitalRiver object
      • Elements
        • Amazon Pay element
        • Apple Pay elements
        • Google Pay elements
        • IBAN element
        • iDEAL element
        • Konbini elements
        • Compliance element
        • Offline Refund elements
        • Online Banking elements
        • Tax Identifier element
        • Invoice attribute element
        • Delayed Payment Instructions element
        • PayPal elements
      • Guidelines for capturing payment details
      • Security
      • Digital River payment objects
      • Error types, codes, and objects
    • DigitalRiverCheckout.js reference
      • Including DigitalRiverCheckout.js
      • Initializing DigitalRiverCheckout.js
        • DigitalRiverCheckout configuration object
      • DigitalRiverCheckout object
        • Configuring Prebuilt Checkout
          • Performing actions
          • Defining experience
        • Components
          • Configuring components
          • Address component
          • Shipping component
          • Tax identifier component
          • Invoice component
          • Wallet component
          • Payment component
          • Compliance component
          • Order summary component
          • Thank you component
        • Rendering a checkout button
          • Performing actions on the checkout button
        • Determining the checkout's status
      • Accessing country and currency
    • DynamicPricing.js reference
    • Postman collection
  • administration
    • Sign in
    • Digital River Dashboard
      • Digital River Dashboard quick start guide
      • Key features
      • Reset your password
      • Test and production environments
      • Account
        • Adding an account
        • Switching accounts
        • Account access
      • Profile settings
        • Viewing your personal information
        • Changing your password
        • Updating your phone number
        • Enabling multi-factor authentication
      • Finance
        • Payouts
          • Viewing your payout details
          • Filtering your payouts
          • Exporting your payouts
        • Sales summaries
          • Viewing your sales summaries details
          • Filtering your sales summaries
          • Exporting your sales summaries
          • Exporting your sales summary details
        • Transactions
          • Viewing your transaction details
          • Filtering your transactions
          • Exporting your transactions
      • Order management
        • Orders
          • Searching for orders
          • Filtering your orders
          • Viewing the order details
          • Cancelling items
          • Fulfilling items
          • Downloading an invoice
          • Downloading a credit memo
          • Creating shipping labels
          • Recording a customer's request to be forgotten
          • Viewing returns and refunds
          • Creating a return
          • Accepting a return
          • Creating a refund
          • Viewing the order's timeline
        • Checkouts
          • Searching for checkouts
          • Filtering your checkouts
          • Viewing the checkout details
        • Prebuilt Checkout links
          • Generate Prebuilt Checkout links
          • View and work with Prebuilt Checkout link details
          • Add a customer during Prebuilt Checkout
          • Add a product during Prebuilt Checkout
      • Customers
        • Viewing customer details
        • Searching for customers
        • Filtering your customers
        • Editing account information
        • Adding a customer
        • Tax IDs and certificates
          • Adding a tax certificate
          • Adding a tax ID
          • Deleting a tax ID
        • Metadata
          • Adding metadata
          • Editing metadata
        • Manage subscriptions from the Customer Details page
        • Disabling a customer
        • Recording a customer's request to be forgotten
        • Deleting a customer
      • Catalog
        • SKUs
          • Viewing the SKU details
          • Searching for SKUs
          • Filtering your SKUs
          • Adding a SKU
          • Editing a SKU
          • Deleting a SKU
          • Adding a fee to a SKU
          • Editing a fee
          • Deleting a fee
          • Viewing product tariff codes
        • Managing customer subscriptions from Digital River Dashboard
      • Developers
        • API keys
          • Updating your API version
          • Getting your API keys
          • Changing the API version for your key
          • Creating a restricted key
          • Editing a restricted key
          • Deleting a restricted key
          • Rotating keys
        • Webhooks
          • Creating a webhook
          • Editing a webhook
          • Deleting a webhook
          • Rotating a webhook's secret
        • API logs
          • Filtering the API log
          • Viewing the API log details
        • Event logs
          • Filtering the events log
          • Viewing the event details
      • Settings
        • Users and roles
          • Roles
          • Searching for a user by name or email
          • Filtering your users and roles
          • Adding a user
          • Editing a user
          • Deleting a user
        • Prebuilt Checkout
        • Payment methods
          • Viewing your payment methods
          • Viewing payment method details
            • Enabling currencies
            • Managing countries
          • Enabling or disabling a payment method
  • General Resources
    • eCompass
    • eCompass documentation
    • Release notes
      • 2024
      • 2023
      • 2022
      • 2021
      • 2020
      • 2019
    • Standards and certifications
      • Certification process
      • Compliance requirements
      • Documentation requirements
      • Integration checklists
        • Admin portal
        • Products and SKUs
        • Customers and tax exemptions
        • Checkouts, payment sources, and orders
        • Disclosures, compliance statements, and emails
        • Fulfillments and cancellations
        • Customer portal
        • Order refund synchronization
        • Reversals
        • Error handling
      • Test and use cases
    • Commerce infrastructure
    • Versioning
    • Glossary
Powered by GitBook
On this page
  • How it works
  • Localizing the invoice attribute element
  • createElement('invoiceAttribute', options)
  • Invoice attribute element configuration object
  • mount()
  • unmount()
  • destroy()
  • on('ready', handler)
  • on('complete', handler)
  • Complete example
  1. Developer resources
  2. DigitalRiver.js reference
  3. Elements

Invoice attribute element

Learn how to use the invoice attribute element

PreviousTax Identifier elementNextDelayed Payment Instructions element

Last updated 2 months ago

The invoice attribute element collects customer data needed for e-invoicing purposes and then uses that data to create an invoice attribute.

For more details on how to use the element with specific , refer to the page.

How it works

To use the element, you'll typically collect enough information from customers during so that Digital River can determine the appropriate . At this point, you can .

This prompts to call to our to get the schemas it needs to build a data collection form. Once the form loads on your front end, customers select the appropriate options, enter their personal information, and click the submit button.

DigitalRiver.js then packages the form's data in a create invoice attribute request sent to our tax service. If that service successfully creates an invoice attribute, you receive the event. That event's payload contains the invoice attribute's unique identifier.

You use this identifier to associate the invoice attribute with the . Our tax service then attempts to validate the invoice attribute, and if that validation proves successful, the object's data is added to the checkout.

At the time of creation, our tax service once again validates the invoice attribute and Digital River's commerce system persists this object data. This allows our reporting services to periodically retrieve this data and transmit it to third-party e-invoicing services integrated with the appropriate tax agencies in each supported country.

Refer to the page for information on using the element to meet invoicing requirements in these countries.

Localizing the invoice attribute element

When for use with the invoice attribute element, you can either set locale to en-US or zh-TW.

let digitalriver = new DigitalRiver("YOUR_PUBLIC_API_KEY", {
     "locale": "zh-TW"
})r

For both localization options, the following shows what the element presents to Taiwan-based customers who use a citizen digital certificate carrier.

Note that the element also helps customers properly format their entries for certain fields.

createElement('invoiceAttribute', options)

let invoiceAttribute = digitalriver.createElement('invoiceAttribute', options)

Invoice attribute element configuration object

const options = {
    invoiceAttribute: {
        sessionId: "e2f7e5ee-4c14-494f-bd14-2a9f3a375da3",
        // country, type and sellingEntity are not needed if sessionId is provided
        // country: "TW",
        // sellingEntity: "DR_TAIWAN-ENTITY"
        // type: "individual",
        // email: "jdoe@digitalriver.com"
    },
    classes: {
        base: "DRElement",
        complete: "invoiceAttribute-complete",
        empty: "invoiceAttribute-empty",
        focus: "invoiceAttribute-focus",
        invalid: "invoiceAttribute-invalid"
    },
    style: {
        base: {
            color: "#495057",
            height: "35px",
            fontSize: "1rem",
            fontFamily: "apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,sans-serif",
            ":hover": {
                color: "#ccc",
            }
        },
        complete: {
            ":hover": {
                color: "#495057",
            },
        },
         empty: {
            ":hover": {
                color: "#dddddd",
            },
        },
        focus: {
            ":hover": {
                color: "#135bef",
            },
        },
        invalid: {
            color: "red"
        }
   }
};

let invoiceAttribute = digitalriver.createElement('invoiceAttribute', options)

invoiceAttribute

The configuration object's invoiceAttribute contains the following properties:

  • country: The shipping or billing address country of the customer getting the invoice. This value is only required if you don't specify sessionId.

on ready event
{
    "hasInvoices": true,
    "invoiceRequired": true,
    "individual": [
        {
            "type": "tw_individual_mobile_barcode",
            "attributes": [
                {
                    "attributeName": "MOBILE_BARCODE",
                    "isRequired": true
                }
            ]
        },
        {
            "type": "tw_individual_citizen_cert",
            "attributes": [
                {
                    "attributeName": "CITIZEN_DIGITAL_CERT",
                    "isRequired": true
                }
            ]
        },
        {
            "type": "tw_individual_member_carrier",
            "attributes": [
                {
                    "attributeName": "MEMBER_CARRIER",
                    "isRequired": true
                }
            ]
        },
        {
            "type": "tw_individual_donate",
            "attributes": [
                {
                    "attributeName": "CHARITY_NAME",
                    "isRequired": true
                }
            ]
        }
    ],
    "hasIndividualInvoiceTypes": true,
    "elementType": "invoiceattribute"
}
on ready event
{
    "hasInvoices": false,
    "elementType": "invoiceattribute"
}

classes

style

mount()

The mount() method displays the invoice attribute element in the container you designate. The method has one required parameter: the id of the div that should hold the element.

...
<div id="invoice-attribute"></div>
...
invoiceAttribute.mount('invoice-attribute');
...

unmount()

...
invoiceAttribute.unmount();
...

destroy()

...
invoiceAttribute.destroy();
...

on('ready', handler)

When the element opens and can accept user input, the on ready event is triggered. This version of on() has two required parameters: 'ready' and an event handler.

invoiceAttribute.on('ready', function(event) {
  // element is ready and can accept user input
})

The event contains all the possible data fields that might be displayed to customers in the element. The fields that are displayed depend on what options customers select.

The ready event is useful for information and testing purposes, but your integration doesn't necessarily have to implement any code to handle it.

For example, the payload of the following on ready event indicates that the customer's country (Taiwan) has an e-invoicing system for individual customers, and they must provide invoice information.

The element will ask customers whether to select the mobile barcode carrier, citizen digital certificate carrier, or member carrier option. It also allows customers to bypass the carrier option entirely and instead designate a charity. Whatever option customers select, the event indicates that the element won't allow them to submit the form until they've specified a value.

{
    "hasInvoices": true,
    "invoiceRequired": true,
    "individual": [
        {
            "type": "tw_individual_mobile_barcode",
            "attributes": [
                {
                    "attributeName": "MOBILE_BARCODE",
                    "isRequired": true
                }
            ]
        },
        {
            "type": "tw_individual_citizen_cert",
            "attributes": [
                {
                    "attributeName": "CITIZEN_DIGITAL_CERT",
                    "isRequired": true
                }
            ]
        },
        {
            "type": "tw_individual_member_carrier",
            "attributes": [
                {
                    "attributeName": "MEMBER_CARRIER",
                    "isRequired": true
                }
            ]
        },
        {
            "type": "tw_individual_donate",
            "attributes": [
                {
                    "attributeName": "CHARITY_NAME",
                    "isRequired": true
                }
            ]
        }
    ],
    "hasIndividualInvoiceTypes": true,
    "elementType": "invoiceattribute"
}

on('complete', handler)

Once customers enter properly formatted data in all of the element's required fields and then submit the form, the on complete event is triggered. This version of on() requires two parameters: 'complete' and an event handler.

invoiceAttribute.on('complete', function(event) {
     if(event.error) {
        //handle error
     } else {
        console.log('invoice attribute success', event);
        //send the invoice attribute's id to your back-end and attach it to the checkout
     }
});

If Digital River successfully creates an invoice attribute, then event contains that object.

Ready event (success)
{
    "id": "94fe7ed9-f570-4049-aa37-979a50f0097d",
    "type": "tw_individual_donate",
    "attributes": {
        "CHARITY_NAME": "財團法人瑪利亞社會福利基金會",
        "CHARITY_CODE": "880"
    },
    "createdTime": "2022-06-06T21:17:41Z",
    "updatedTime": "2022-06-06T21:17:41Z",
    "liveMode": false,
    "elementType": "invoiceattribute"
}
curl --location --request POST 'https://api.digitalriver.com/checkouts/7da8bcbc-a139-440e-a684-5eb5f1804995' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <Secret API Key>' \
...
--data-raw '{
    "invoiceAttributeId": "de2c8ced-b788-463f-93fb-0b274bc7f9bf"
}'

If the create invoice attribute request fails, then event contains an error.

Ready event (fail)
{
    "error": {
        "type": "no_network",
        "errors": [
            {
                "message": "Please check your network connection."
            }
        ]
    },
    "elementType": "invoiceattribute"
}

Since the element validates the format of customer-entered data, errors are typically only returned when the invoice attribute service is unreachable, or customers are experiencing connection issues. In these cases, we recommend displaying a message such as “Something went wrong. Try again later” to customers.

Complete example

<html>
    <head>
        <link href="https://js.digitalriverws.com/v1/css/DigitalRiver.css" rel="stylesheet">
        <script src="https://js.digitalriverws.com/v1/DigitalRiver.js"></script>
    </head>
    <body>
        <div id="invoice-attribute"></div>

        <script>
            window.addEventListener('load', function() {
                const options = {
                    locale: 'zh-TW'
                }
                const digitalriver = new DigitalRiver(options);

                const invoiceAttributeOptions = {
                    invoiceAttribute: {
                        sessionId: "e2f7e5ee-4c14-494f-bd14-2a9f3a375da3",
                        // country and sellingEntity are not needed if sessionId is provided
                        // country: "CN",
                        // sellingEntity: "DR_CHINA-ENTITY"
                        // optional properties:
                        // type: "individual"
                        // email: "someone@somewhere.com"
                    },
                    classes: {
                        base: "DRElement",
                        complete: "invoiceAttribute-complete",
                        empty: "invoiceAttribute-empty",
                        focus: "invoiceAttribute-focus",
                        invalid: "invoiceAttribute-invalid"
                    },
                    style: {
                        base: {
                            color: "#495057",
                            height: "35px",
                            fontSize: "1rem",
                            fontFamily: "apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,sans-serif",
                            ":hover": {
                                color: "#ccc",
                            }
                        }
                    }
                };

                let invoiceAttribute = digitalriver.createElement('invoiceAttribute', invoiceAttributeOptions);
                invoiceAttribute.mount('invoice-attribute');

                invoiceAttribute.on('ready', function(details) {
                    console.log(details);
                });

                invoiceAttribute.on('complete', function(details) {
                    if(event.error) {
        //handle error
     } else {
        if(event.error) {
        //handle error
     } else {
        console.log('invoice attribute success', event);
        //send the invoice attribute's id to your back-end and attach it to the checkout
     }
     }
                });
            });
        </script>
    </body>

Once you , you can use it to create an invoice attribute element.

This version of the createElement() method has two required parameters: 'invoiceAttribute' and a .

The element's configuration object consists of a required and an optional and .

sessionId: The transaction's identifier. This value is required if you don't specify country and sellingEntity. However, if you do pass sessionId, then your integration must have already collected the customer's shipping and/or billing information and used it to update the with a shipTo.address.country and/or billTo.address.country. Once this is done, Digital River will have the data it needs to calculate the checkout's . When you fetch the checkout's , pass that value to sessionId, and create the element, DigitalRiver.js looks up the transaction's country and selling entity in the payment session and calls to the to retrieve the schemas needed to build the invoice attribute element's data entry forms.

sellingEntity: The of the transaction. This value is only required if you don't specify sessionId.

type: This optional parameter represents the type of customer requesting the invoice. The acceptable values are individual or business. You can either set type or set the and then pass sessionId. This feature allows you to use the to determine, based on the customer's type, whether an invoice attribute is required. In the following example, the sellingEntity.id is DR_TAIWAN-ENTITY. For individual customers, the indicates that an invoicing system exists and that customer's must supply their invoice information. The same event type indicates that no invoice attribute requirements exist for business customers

email: The element won't prompt a customer for their email address if specified. This is useful if your integration collects a customer's email address before creating the invoice attribute element. If this is the case, you can pass email and prevent customers from having to enter the same information twice during the checkout process. For example, if invoiceAttribute contains email and a customer getting a selects the member carrier option (which requires an email address), the element won't display that data collection field.

For details, refer to .

For details, refer to .

If this method is successful, then the is triggered.

The unmount() method removes the invoice attribute element from the page. Once called, the element is no longer visible to customers. However, you can later re-add the element to div by invoking .

The destroy() method removes the invoice attribute element from the page and deactivates the element's functionality. Once the method is invoked, you can't call to reactivate the element and make it visible.

You should handle on complete by passing the event's id to your backend and using that value to set invoiceAttributeId in the body of a request. This associates the invoice attribute with the .

You can also respond to the event by calling or to close the element and make it no longer visible to customers.

instantiate a Digital River object
selling entity
configuration object
invoiceAttribute
classes
style
on ready event
mount()
mount()
unmount()
destroy()
selling entities
Handling e-invoicing requirements
checkouts
selling entity
DigitalRiver.js
country specification service
Handling e-invoicing requirements
instantiating a DigitalRiver object
create an invoice attribute element
on complete
payment session
sellingEntity
customerType
on ready event
on ready event
Custom classes
Custom styles
payment.session.id
checkout
order
checkout
Country Specs API
checkout's
checkout's
POST /checkouts/{id}
checkout
Taiwanese eGUI