# Multi-payment
URL: /docs/a2a/multi-payment

Create a product-based order and pay it with one or more transactions.

`startMultiPayment` creates an order from a list of products and settles it with
one or more transactions (e.g. part cash, part card). It returns a rich
[`PPMultiPaymentResponseModel`](/docs/a2a/reference#ppmultipaymentresponsemodel)
with computed totals, taxes, customer and document info.

## Request

| Parameter             | Type                                                               | Required | Description                                   |
| --------------------- | ------------------------------------------------------------------ | -------- | --------------------------------------------- |
| `changePaymentStatus` | bool                                                               | yes      | Whether POS+ updates the order payment status |
| `orderCode`           | String                                                             | yes      | Your unique order code                        |
| `orderDate`           | DateTime                                                           | yes      | Order date/time                               |
| `products`            | List\<ProductModel>                                                | yes      | Order line items                              |
| `transactions`        | List\<TransactionModel>                                            | yes      | Payments that settle the order                |
| `billingInformation`  | PPBillingInfo                                                      | no       | Invoice / billing details                     |
| `groupCode`           | String                                                             | no       | Group code                                    |
| `note`                | String                                                             | no       | Free-text note                                |
| `discountAmount`      | double                                                             | no       | Order discount (default `0`)                  |
| `currency`            | [`PPCurrencyType`](/docs/a2a/reference#ppcurrencytype)             | no       | Default `TRY`                                 |
| `deliveryType`        | [`PPDeliveryTypeEnum`](/docs/a2a/reference#ppdeliverytypeenum)     | no       | Default `CASH_ORDER`                          |
| `deliveryStatus`      | [`PPDeliveryStatusEnum`](/docs/a2a/reference#ppdeliverystatusenum) | no       | Delivery status                               |
| `installment`         | int                                                                | no       | Number of installments                        |

### `ProductModel`

`id` (int), `sku` (String), `title` (String), `unit`
([`PPQtyEnums`](/docs/a2a/reference#ppqtyenums)), `price` (double), `quantity`
(double), `taxRate` (int), `vatInclude` (bool), `productType`
([`PPProductTypeEnum`](/docs/a2a/reference#ppproducttypeenum)), `discountValue`
(double), and optional `description`, `categoryCode`, `categoryName`,
`discountType`, `exemptionCode`.

### `TransactionModel`

`paymentType` ([`PPPaymentType`](/docs/a2a/reference#pppaymenttype)), `totalAmount`
(double), optional `paymentMethod`
([`PPPaymentMethod`](/docs/a2a/reference#pppaymentmethod)).

## Example

<CodeBlockTabs defaultValue="flutter" groupId="pp-platform" persist>
  <CodeBlockTabsList>
    <CodeBlockTabsTrigger value="flutter">
      Flutter
    </CodeBlockTabsTrigger>

    <CodeBlockTabsTrigger value="kotlin">
      Kotlin
    </CodeBlockTabsTrigger>

    <CodeBlockTabsTrigger value="java">
      Java
    </CodeBlockTabsTrigger>

    <CodeBlockTabsTrigger value="react-native">
      React Native
    </CodeBlockTabsTrigger>
  </CodeBlockTabsList>

  <CodeBlockTab value="flutter">
    ```dart
    final result = await _pluspay.startMultiPayment(
      PPMultiPaymentRequest.toRequest(
        changePaymentStatus: true,
        orderCode: 'ORD-001',
        orderDate: DateTime.now(),
        products: [
          ProductModel(
            id: 1,
            sku: 'SKU001',
            unit: PPQtyEnums.ADET,
            price: 100.0,
            title: 'Product 1',
            quantity: 1,
            taxRate: 20,
            vatInclude: true,
            productType: PPProductTypeEnum.PHYSICALLY,
            discountValue: 0,
          ),
        ],
        transactions: [
          TransactionModel(
            paymentType: PPPaymentType.BANK_TRANSFER,
            totalAmount: 100.0,
            paymentMethod: PPPaymentMethod.NONE,
          ),
        ],
      ),
    );

    print(result.grandTotal);
    print(result.status);   // PPOrderStatusEnum
    ```
  </CodeBlockTab>

  <CodeBlockTab value="kotlin">
    ```kotlin
    val request = PPMultiPaymentRequest.toRequest(
        change_payment_status = true,
        order_code = "ORD-001",
        order_date = Date(),
        products = listOf(
            ProductModel(
                id = 1,
                sku = "SKU001",
                unit = PPQtyEnums.ADET,
                price = 100.0,
                title = "Product 1",
                quantity = 1.0,
                tax_rate = 20,
                vat_include = true,
                product_type = PPProductTypeEnum.PHYSICALLY,
                discount_value = 0.0,
            )
        ),
        transactions = listOf(
            TransactionModel(
                payment_type = PPPaymentType.BANK_TRANSFER,
                total_amount = 100.0,
                payment_method = PPPaymentMethod.NONE,
            )
        ),
    )

    val result = client.startMultiPayment(request)
    ```
  </CodeBlockTab>

  <CodeBlockTab value="java">
    ```java
    String request = PPMultiPaymentRequest.toRequest(
        true,                       // change_payment_status
        "ORD-001",
        new Date(),
        Collections.singletonList(
            new ProductModel(1, "SKU001", PPQtyEnums.ADET, 100.0,
                "Product 1", 1.0, 20, true,
                PPProductTypeEnum.PHYSICALLY, 0.0)
        ),
        Collections.singletonList(
            new TransactionModel(PPPaymentType.BANK_TRANSFER, 100.0,
                PPPaymentMethod.NONE)
        )
    );

    client.startMultiPayment(request, new PPA2ACallback<PPMultiPaymentResponseModel>() {
        @Override public void onSuccess(PPMultiPaymentResponseModel r) {}
        @Override public void onError(PlusPayException e) {}
    });
    ```
  </CodeBlockTab>

  <CodeBlockTab value="react-native">
    ```ts
    const result = await client.startMultiPayment(
      PPMultiPaymentRequest.toRequest({
        changePaymentStatus: true,
        orderCode: 'ORD-001',
        orderDate: new Date(),
        products: [
          {
            id: 1,
            sku: 'SKU001',
            unit: PPQtyEnums.ADET,
            price: 100.0,
            title: 'Product 1',
            quantity: 1,
            taxRate: 20,
            vatInclude: true,
            productType: PPProductTypeEnum.PHYSICALLY,
            discountValue: 0,
          },
        ],
        transactions: [
          {
            paymentType: PPPaymentType.BANK_TRANSFER,
            totalAmount: 100.0,
            paymentMethod: PPPaymentMethod.NONE,
          },
        ],
      })
    );

    console.log(result.grand_total);
    console.log(result.status);
    ```
  </CodeBlockTab>
</CodeBlockTabs>

<Callout>
  You don't pass a device serial number or an auth token — POS+ uses its
  own registered device identity for the order.
</Callout>

## Response highlights

`PPMultiPaymentResponseModel` includes `id`, `orderCode`, the computed
`grandTotal`, `subTotal`, `taxAmount`, `totalPaid`, `amountDue`, `status`
([`PPOrderStatusEnum`](/docs/a2a/reference#pporderstatusenum)), the resolved
`products` and `transactions`, tax breakdown `taxs`, optional `customer`,
`document` and `webhook` info. See the full field list in the
[Reference](/docs/a2a/reference#ppmultipaymentresponsemodel).

## Create an order without payment

`createOrder` (`ORDER_CREATE`) creates the order in POS+ but does not start a
payment. Collect it later with
[`startOrderPayment`](/docs/a2a/payments#pay-an-existing-order) using the same
`orderCode`. If the `orderCode` already exists in POS+, the order is updated
instead.

The request takes the same fields as `startMultiPayment`, except
`transactions`, `changePaymentStatus`, `canTryAgain` and `startTime`. The
response, `PPOrderCreateResponseModel`, is the same order detail as
[`PPMultiPaymentResponseModel`](/docs/a2a/reference#ppmultipaymentresponsemodel).
Available from Flutter 0.7.0 and React Native 0.3.0; not available in the
native package.

<CodeBlockTabs defaultValue="flutter" groupId="pp-platform" persist>
  <CodeBlockTabsList>
    <CodeBlockTabsTrigger value="flutter">
      Flutter
    </CodeBlockTabsTrigger>

    <CodeBlockTabsTrigger value="kotlin">
      Kotlin
    </CodeBlockTabsTrigger>

    <CodeBlockTabsTrigger value="java">
      Java
    </CodeBlockTabsTrigger>

    <CodeBlockTabsTrigger value="react-native">
      React Native
    </CodeBlockTabsTrigger>
  </CodeBlockTabsList>

  <CodeBlockTab value="flutter">
    ```dart
    await _pluspay.createOrder(
      PPOrderCreateRequest.toRequest(
        orderCode: 'ORD001',
        orderDate: DateTime.now(),
        products: [
          ProductModel(
            id: 1,
            sku: 'SKU-001',
            title: 'Product 1',
            price: 100.0,
            quantity: 1,
            taxRate: 10,
            unit: PPQtyEnums.ADET,
            vatInclude: true,
            productType: PPProductTypeEnum.PHYSICALLY,
            discountValue: 0,
          ),
        ],
      ),
    );

    // Collect it later:
    await _pluspay.startOrderPayment(
      PPOrderPaymentRequestModel.toRequest(orderCode: 'ORD001'),
    );
    ```
  </CodeBlockTab>

  <CodeBlockTab value="kotlin">
    ```kotlin
    // Not available in pluspay_a2a_native yet.
    ```
  </CodeBlockTab>

  <CodeBlockTab value="java">
    ```java
    // Not available in pluspay_a2a_native yet.
    ```
  </CodeBlockTab>

  <CodeBlockTab value="react-native">
    ```ts
    await client.createOrder(
      PPOrderCreateRequest.toRequest({
        orderCode: 'ORD001',
        orderDate: new Date(),
        products: [
          {
            id: 1,
            sku: 'SKU-001',
            title: 'Product 1',
            price: 100,
            quantity: 1,
            taxRate: 10,
            unit: PPQtyEnums.ADET,
            vatInclude: true,
            productType: PPProductTypeEnum.PHYSICALLY,
            discountValue: 0,
          },
        ],
      })
    );

    // Collect it later:
    await client.startOrderPayment(
      PPOrderPaymentRequestModel.toRequest({ orderCode: 'ORD001' })
    );
    ```
  </CodeBlockTab>
</CodeBlockTabs>