Skip to content

[Feature Request] Send an itemised cart at checkout, not just a total #277

Description

@WonkyTappet

I'd like to be able to send a list of line items to the SDK when starting a checkout, rather than just a single total, so the resulting transaction is itemised.

Right now SumUpPayment.builder() only takes a single total and a free-text title, so a sale (e.g. a round at a bar) lands in SumUp as a lump sum with no breakdown. The item-level detail is effectively lost and can't be used for reporting, receipts etc. within SumUp as products[] doesn't get populated.

The fields currently available don't get there:

  • title is a single string, no structure.
  • addAdditionalInfo(key, value) isn't shown to the buyer or on the receipt, and doesn't populate products[].

I suspect this is also a prerequisite for #275 (printing itemised receipts to the Solo printer) - you can't print line items that were never attached to the sale. This issue is about getting the items onto the transaction; #275 is about printing them.

Suggested SDK API:

Add a cart(...) to the builder. total becomes optional when a cart is supplied.

(Based off the Android SDK docs)

SumUpPayment payment = SumUpPayment.builder()
        // total optional when a cart is supplied:
        //   omitted  -> SDK computes it from the cart
        //   supplied -> SDK checks it matches the cart sum
        .currency(SumUpPayment.Currency.EUR)

        .cart(SumUpCart.builder()
            .addItem(SumUpCartItem.builder()
                .name("BigItem")
                .unitPrice(new BigDecimal("5.00"))
                .vatRate(new BigDecimal("0.20"))
                .quantity(2)
                .build())
            .addItem(SumUpCartItem.builder()
                .name("SmallItem")
                .unitPrice(new BigDecimal("2.50"))
                .vatRate(new BigDecimal("0.20"))
                .quantity(1)
                .build())
            .build())
        [...]
        .build();

SumUpAPI.checkout(MainActivity.this, payment, 2);

Each line carries at minimum its own name, price, VAT, quantity - the rest of products[] can be calculated from there.

Cloud / REST equivalent

{
  "currency": "EUR",
  "cart": {
    "line_items": [
      { "name": "BigItem", "unit_price": 5.00, "vat_rate": 0.20, "quantity": 2 },
      { "name": "SmallItem", "unit_price": 2.50, "vat_rate": 0.20, "quantity": 1 }
    ]
  }
}

So in theory:

  • If a cart is supplied, total is worked out from it; if I also pass total, the SDK checks the two match and errors if not.
  • VAT comes from the rate supplied on each line.
  • The line items show on the reader and on SumUp's own receipt - not just in some hidden field.
  • The same line items come back in the products[] array from the transactions API

(In an ideal world, it'd be possible to build a cart using existing catalogue items configured within SumUp, but as there's no SDK/API support for getting this info that I'm awre of I suspect this is well out of scope here.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions