Multi-Seller Purchase

You can use Tilia to process simple transactions between a buyer and a single seller, such as a user-to-integrator or user-to-user purchase.

You can also build more complex transactions involving multiple sellers. These transactions follow the same basic flow as other transactions, although the invoice is built slightly differently. The example below is an invoice in which the buyer is purchasing an item from one of your sellers, and you are taking a fee for the transaction.

The first line item has a transaction_type of user_to_user and handles information tied to the seller. The recipients array contains the seller's wallet information (destination_wallet_id) along with the publisher wallet you wish to use in processing the transaction (source_wallet_id). This line item also contains information about the seller's product.

The second line item has a transaction_type of user_to_integrator and handles information tied to your transaction fee.

Request body

Copy
Copied
{
  "account_id": "<buyer_account_id>",
  "reference_type": "<your_reference_type>",
  "reference_id": "<your_reference_id>",
  "description": "<your_product_description>",
  "payment_methods": [
  {
    "payment_method_id": "<buyer_payment_method_id>"
  }
  ],
  "line_items": [
    {
      "amount": 550,
      "currency": "USD",
      "transaction_type": "user_to_user",
      "reference_type": "<seller_product_info>",
      "reference_id": "<seller_product_id>",
      "recipients": [
        {
          "amount": 500,
          "currency": "USD",
          "source_wallet_id":"<your_integrator_wallet_id>",
          "destination_wallet_id": "<seller_USD_wallet_id>"
        }
      ]
    },
  {
      "amount": 50,
      "currency": "USD",
      "transaction_type": "user_to_integrator",
      "reference_type": "<your_reference_info>",
      "reference_id": "<your_reference_id>"
    },
  ]
}

For detailed information about each of these properties, refer to the Invoicing API reference documentation.

Sample response

A successful request returns the HTTP 201 Created status code along with a JSON response body containing the invoice details.

View Response
Copy
Copied
{
    "status": "Success",
    "message": [],
    "codes": [],
    "payload": {
        "invoice_id": "6672ace6-c3bc-468a-8b3f-16c0ee9d1ed9",
        "account_id": "08ef3dc4-e760-4570-b13a-0f9dbdb472b2",
        "reference_type": "product_purchase_id",
        "reference_id": "purchase_id123",
        "state": "open",
        "description": "A description of the product",
        "metadata": null,
        "summary": {
            "total_amount": 550,
            "currency": "USD",
            "display_amount": "USD 5.50"
        },
        "created": "0001-01-01T00:00:00Z",
        "updated": "0001-01-01T00:00:00Z",
        "payment_methods": {
            "36ad2d23-ad8d-4264-be68-2e9eb19c4f96": {
                "payment_method_id": "36ad2d23-ad8d-4264-be68-2e9eb19c4f96",
                "authorized_amount": 550,
                "currency": "USD",
                "display_amount": "USD 5.50",
                "subitems": {}
            }
        },
        "line_items": {
            "67982820-187c-4157-b966-113353e4bfec": {
                "line_item_id": "67982820-187c-4157-b966-113353e4bfec",
                "product_sku": "",
                "amount": 500,
                "currency": "USD",
                "display_amount": "USD 5.00",
                "reference_type": "user_product_id",
                "reference_id": "product123",
                "transaction_type": "user_to_user",
                "description": "",
                "metadata": null,
                "subitems": {
                    "54a7fc29-bf5f-40d3-ac47-1426d96891f0": {
                        "subitem_id": "54a7fc29-bf5f-40d3-ac47-1426d96891f0",
                        "amount": 500,
                        "currency": "USD",
                        "display_amount": "USD 5.00",
                        "reference_type": "invoicing.invoice_line_item_v2.line_item_id",
                        "reference_id": "67982820-187c-4157-b966-113353e4bfec",
                        "subitem_type": "user_recipient",
                        "description": "",
                        "metadata": null,
                        "source_account_id": "bd1ae1e9-e857-4acb-af0a-ec0d1b2bcd62",
                        "source_payment_method_id": "",
                        "source_wallet_id": "73f450d4-0f5d-4a9f-93f6-3be0631d7389",
                        "destination_account_id": "682c8d3e-75ad-4d10-8b1a-1e15768e5d61",
                        "destination_payment_method_id": "",
                        "destination_wallet_id": "9e369d95-deba-4c5f-b8b8-83719e62f335"
                    }
                }
            },
            "85f3cbfc-23e7-421a-8870-9bded0752bad": {
                "line_item_id": "85f3cbfc-23e7-421a-8870-9bded0752bad",
                "product_sku": "",
                "amount": 50,
                "currency": "USD",
                "display_amount": "USD 0.50",
                "reference_type": "transaction_fee",
                "reference_id": "fee_id",
                "transaction_type": "user_to_integrator",
                "description": "",
                "metadata": null,
                "subitems": {}
            }
        },
        "subitems": {}
    }
}