public final class RemovePayment extends UpdateActionImpl<Order>
See also OrderUpdateCommand.
withPayment(client(), payment -> {
withOrder(client(), order -> {
//add payment
final OrderUpdateCommand orderUpdateCommand = OrderUpdateCommand.of(order, AddPayment.of(payment))
.withExpansionPaths(m -> m.paymentInfo().payments());
final Order orderWithPayment = client().executeBlocking(orderUpdateCommand);
final Reference<Payment> paymentReference = orderWithPayment.getPaymentInfo().getPayments().get(0);
assertThat(paymentReference).isEqualTo(payment.toReference());
assertThat(paymentReference).is(expanded(payment));
//remove payment
final Order orderWithoutPayment = client().executeBlocking(OrderUpdateCommand.of(orderWithPayment, RemovePayment.of(payment)));
assertThat(orderWithoutPayment.getPaymentInfo()).isNull();
return orderWithoutPayment;
});
return payment;
});
See the test code.
Payment
,
Order.getPaymentInfo()
,
AddPayment
Modifier and Type | Method and Description |
---|---|
Reference<Payment> |
getPayment() |
static RemovePayment |
of(Referenceable<Payment> payment) |
getAction
public static RemovePayment of(Referenceable<Payment> payment)