public final class AddPayment extends UpdateActionImpl<Cart>
See also CartInStoreUpdateCommand.
withPayment(client(), payment -> { withCart(client(), cart -> { //add payment final CartUpdateCommand command = CartUpdateCommand.of(cart, AddPayment.of(payment)) .withExpansionPaths(m -> m.paymentInfo().payments()); final Cart cartWithPayment = client().executeBlocking(command); final Reference<Payment> paymentReference = cartWithPayment.getPaymentInfo().getPayments().get(0); assertThat(paymentReference).isEqualTo(payment.toReference()); assertThat(paymentReference).is(expanded(payment)); //query cart by payment final CartQuery cartQuery = CartQuery.of() .withPredicates(m -> m.paymentInfo().payments().isIn(singletonList(payment))); assertThat(client().executeBlocking(cartQuery).head()).contains(cartWithPayment); //remove payment final Cart cartWithoutPayment = client().executeBlocking(CartUpdateCommand.of(cartWithPayment, RemovePayment.of(payment))); assertThat(cartWithoutPayment.getPaymentInfo()).isNull(); return cartWithoutPayment; }); return payment; });
See the test code.
Payment
,
Cart.getPaymentInfo()
,
RemovePayment
Modifier and Type | Method and Description |
---|---|
Reference<Payment> |
getPayment() |
static AddPayment |
of(Referenceable<Payment> payment) |
getAction
public static AddPayment of(Referenceable<Payment> payment)