> ## Documentation Index
> Fetch the complete documentation index at: https://docs.fexco.com/llms.txt
> Use this file to discover all available pages before exploring further.

# DCC service methods

> Reference for all methods available through the IRemoteDCCService interface in the Fexco DCC Android app.

The `IRemoteDCCService` interface provides seven methods for managing
the DCC transaction lifecycle. The following table summarizes the
available methods.

| Method | Description |
| :- | :- |
| `init()` | Initializes the SDK with the DHS base URL. |
| `getDccOffer()` | Checks whether DCC is available for a transaction. |
| `getDccRate()` | Requests the current DCC rate for a specified currency. |
| `getDccChoice()` | Displays the cardholder choice screen and captures input. |
| `notifyPaymentComplete()` | Sends the transaction result to Fexco analytics. |
| `getDccReceiptString()` | Returns the DCC receipt string for printing or display. |
| `cancel()` | Cancels the current interaction with the DCC app. |

Expand each method below for a full description and code example.

> [accordion] init()
>
> Call `init()` with the DHS base URL before calling any other method.
> The DCC app establishes the connection to the Fexco DHS and returns
> the result via `DccInitCallback`. See
> [Environments](https://docs.fexco.com/dcc/api-reference/environments.md) for the correct URL
> for your environment.
>
> ```kotlin theme={null}
> dccService.init(
>     "YOUR_DHS_BASE_URL",
>     object : DccInitCallback {
>         override fun onSuccess() {
>             // Proceed with getDccOffer() or getDccRate().
>         }
>         override fun onFailure(error: DccError) {
>             // Check the DHS URL and device network connectivity.
>         }
>     }
> )
> ```

> [accordion] getDccOffer()
>
> Use `getDccOffer()` to check DCC eligibility before displaying the
> cardholder choice screen. If the call succeeds and a DCC offer is
> available, pass the returned `DccOffer` to `getDccChoice()`.
>
> The `timeoutInMilliseconds` parameter controls how long the SDK waits
> for a network response. The example uses 10,000 milliseconds (10
> seconds).
>
> ```kotlin theme={null}
> dccService.getDccOffer(
>     DccTransaction(
>         "YOUR_DCC_ACQUIRER_ID",
>         "UNIQUE_TRANSACTION_ID",
>         "YOUR_TERMINAL_ID",
>         "YOUR_MERCHANT_ID",
>         "CARD_BIN",
>         "BASE_AMOUNT",
>         10000L
>     ),
>     object : DccOfferCallback {
>         override fun onNoOfferAvailable() {
>             // No DCC offer available. Proceed with local currency.
>         }
>         override fun onOfferAvailable(dccOffer: DccOffer) {
>             // DCC offer available. Call getDccChoice() next.
>         }
>         override fun onError(error: DccError) {
>             // Handle the error.
>         }
>     }
> )
> ```

> [accordion] getDccRate()
>
> Use `getDccRate()` for top-up and completion transactions where the
> latest exchange rate for a known foreign currency is required. Provide
> the [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) three-letter
> currency code in the transaction object (for example, `USD` or `EUR`).
> See [Currency codes](https://docs.fexco.com/dcc/developer-resources/codes/currency.md) for a
> reference.
>
> ```kotlin theme={null}
> dccService.getDccRate(
>     DccTransaction(
>         "YOUR_DCC_ACQUIRER_ID",
>         "UNIQUE_TRANSACTION_ID",
>         "YOUR_TERMINAL_ID",
>         "YOUR_MERCHANT_ID",
>         "ISO_CURRENCY_CODE",
>         "BASE_AMOUNT",
>         10000L
>     ),
>     object : DccRateCallback {
>         override fun onNoRateAvailable() {
>             // No rate available for the specified currency.
>         }
>         override fun onRateAvailable(dccOffer: DccOffer) {
>             // Rate available. Proceed with authorization.
>         }
>         override fun onError(error: DccError) {
>             // Handle the error.
>         }
>     }
> )
> ```

> [accordion] getDccChoice()
>
> Use `getDccChoice()` after a successful `getDccOffer()` call. Pass the
> `DccOffer` from the offer callback and a timeout, in milliseconds, that
> controls how long the choice screen stays open before it closes
> automatically.
>
> ```kotlin theme={null}
> dccService.getDccChoice(
>     DccChoiceConfiguration(
>         1,         // Screen set identifier.
>         dccOffer,  // DccOffer from getDccOffer() callback.
>         30000L     // Timeout in milliseconds before auto-close.
>     ),
>     object : DccChoiceCallback {
>         override fun onDCCOfferAccept(dccChoice: DccChoice) {
>             // Cardholder accepted DCC. Proceed with authorization.
>         }
>         override fun onDCCOfferReject() {
>             // Cardholder declined. Proceed with local currency.
>         }
>         override fun onError(error: DccError) {
>             // Handle the error. Check DccError.reason for "On timeout".
>         }
>     }
> )
> ```

> [accordion] notifyPaymentComplete()
>
> Call `notifyPaymentComplete()` after every transaction, regardless of
> the authorization result. This method sends analytics data to Fexco and
> does not affect the payment outcome.
>
> ```kotlin theme={null}
> dccService.notifyPaymentComplete(
>     TransactionResult(
>         "UNIQUE_TRANSACTION_ID",
>         dccTransactionType,
>         cardEntryMode,
>         authResult,
>         "AUTH_CODE",
>         "YOUR_SOFTWARE_NAME",
>         "YOUR_SOFTWARE_VERSION",
>         "CASHIER_ID"
>     ),
>     object : NotifyPaymentCompleteCallback {
>         override fun onSuccess() {
>             // Analytics data sent.
>         }
>         override fun onFailure(error: DccError) {
>             // Analytics failed. The transaction result is not affected.
>         }
>     }
> )
> ```

> [accordion] getDccReceiptString()
>
> Use `getDccReceiptString()` to get the DCC receipt text after a
> transaction. Pass the transaction type as a string using
> `TransactionType.name` and the foreign currency alpha code.
>
> Supported transaction types are `SALE`, `REFUND`, `COMPLETION`, and
> `PREAUTH`. All other transaction types return an empty string.
>
> ```kotlin theme={null}
> val receiptString = dccService.getDccReceiptString(
>     TransactionType.SALE.name,              // e.g. "SALE", "REFUND"
>     dccChoice.dccForeignCurrencyAlphaCode   // e.g. "USD", "EUR"
> )
>
> if (receiptString.isNotEmpty()) {
>     // Display or print the receipt string.
> }
> ```
>
> > [!NOTE]
> >
> > The `dccReceiptString` field on `DccChoice` is still populated for
> > backward compatibility, but it always returns sale receipt text
> > regardless of transaction type. Use `getDccReceiptString()` for all
> > new integrations.

> [accordion] cancel()
>
> Use `cancel()` to stop the current interaction with the DCC app at any
> point. Any active callback receives an error with the reason `"Canceled"`.
>
> ```kotlin theme={null}
> dccService.cancel()
> ```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.