# Merchant side invoicing

{% hint style="info" %}
Implementation is **OPTIONAL**
{% endhint %}

### General Flow

1. Customer scans products to shopping cart.
2. Smarts will send shopping cart to merchant when customer is ready to pay for the purchase.
3. Merchant will response with generated receipt
4. Customer will pay for receipt.
5. Smarts will send receipt payment confirmation to merchant.

### Configuration

Visit your store configuration page in Smarts manager UI. Switch store side invoicing to **ON** position and implement SDK required methods.

### Implementation

You only need to create a new class, implement **`ReceiptAdapter`** interface and fill all required methods.  API endpoints for merchant side invoicing are created automatically and secured with token.&#x20;

It is important to add `@Component` annotation on top of the class. There is no restriction for class name or location in your project. Our SDK will find your implementation based on the interface (DI).

```java
import ee.smarts.common.v1.Entities.receipt.Receipt;
import ee.smarts.common.v1.requests.CreateReceiptRequest;
import ee.smarts.common.v1.requests.ReceiptPaymentConfirmationRequest;
import ee.smarts.starter.adapter.ReceiptAdapter;
import org.springframework.stereotype.Component;
@Component
public class ReceiptAdapterImpl implements ReceiptAdapter {
    @Override
    public Receipt create(CreateReceiptRequest request) {
        // implement this method
        return null;
    }
    @Override
    public void confirmationListener(ReceiptPaymentConfirmationRequest request) {
        // implement this method
    } 
}
```

{% hint style="info" %}
There is **additional step** for customer in payment process when using merchant side invoicing. Smarts shows generated receipt to customer before they are able to pay for the purchase.
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://developer.smarts.ee/integration/spring-boot-starter/merchant-side-invoicing.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
