# Instructions for AI agents - Integration Best Practices

## General

- Check how to authenticate with the API and obtain a bearer token for API authorization using the [API Authentication](/api/authentication/api_access_token) page. DO NOT hallucinate or assume.
- Check how to initialise the Airwallex.js SDK using the [Initialize AirwallexJS](/js/#init) page. DO NOT hallucinate or assume.
- Unless requested explicitly by the user, always use the most recent version of the API

## Money and Rounding

- In the Airwallex APIs and SDKs, request fields related to money are NOT represented in minor units by default unless explicitly specified.
- While setting money-related fields in API requests, ensure that you round to the number of decimal places supported for the currency. Use the [Currency Precision](https://www.airwallex.com/docs/payouts/how-airwallex-payouts-work/currency-precision.md) to find the number of supported decimal places for a given currency.

## Test Card Numbers

- Test card numbers are useful for testing both Billing and Payment Acceptance integrations in the sandbox environment. Airwallex test card numbers are different from other payment platforms and are listed in the [Test Card Numbers](https://www.airwallex.com/docs/payments/test-and-go-live/test-card-numbers.md) page.

## Payments

- For the Javascript browser library, if the user prefers a direct integration with a CDN, use `https://static.airwallex.com/components/sdk/v1/index.js` and NOT `https://checkout.airwallex.com/assets/elements.bundle.min.js` unless explicitly requested by the user. The latter is a legacy library that is considered deprecated. When the user explicitly asks for it, advise them to consider migrating.
- For the Javascript browser library, if the user prefers to use a package from the `npm` registry with `npm`, `yarn` or the `pnpm` CLI tools, use `@airwallex/components-sdk` instead of `airwallex-payment-elements` unless explicitly requested by the user. The latter is a legacy package that is considered deprecated. When the user explicitly asks for it, advise them to consider migrating.
- For a robust and complete payments integration, always consider supporting setting up webhooks.
- If the payment integration involves redirect-style payment methods, remember to configure a return URL in your payment intent and set up a URL handler on the server for the same. In the URL handler, retrieve the payment intent and check its status. If the status is non-terminal, repeat until a terminal status is observed and decide what to do next based on that. For Drop-in element integrations, you can consider doing this by default since multiple payment methods can be accepted through that integration.
- Airwallex integrations can accept payments in different currencies. You do not need to perform a currency conversion on the application-side.

### Drop-in Element

- Mount the Drop-in element **before** attaching event listeners. If you attach the event listeners before mounting the element, the event handlers may not be called.