public final class SetAuthorization extends UpdateActionImpl<Payment>
See also PaymentUpdateCommand.
withPayment(client(), payment -> {
//set authorization
final MonetaryAmount totalAmount = EURO_30;
final ZonedDateTime until = ZonedDateTime.now().plusDays(7);
final Payment updatedPayment = client().executeBlocking(PaymentUpdateCommand.of(payment, SetAuthorization.of(totalAmount, until)));
assertThat(updatedPayment.getAmountAuthorized()).isEqualTo(totalAmount);
assertThat(updatedPayment.getAuthorizedUntil()).isEqualTo(until);
assertThat(updatedPayment.getAmountPaid()).isNull();
//remove authorization, set amount paid
final Payment updatedPayment2 = client().executeBlocking(PaymentUpdateCommand.of(updatedPayment, asList(SetAuthorization.ofRemove(), SetAmountPaid.of(totalAmount))));
assertThat(updatedPayment2.getAmountAuthorized()).isNull();
assertThat(updatedPayment2.getAuthorizedUntil()).isNull();
assertThat(updatedPayment2.getAmountPaid()).isEqualTo(totalAmount);
return updatedPayment2;
});
See the test code.
Payment
Modifier and Type | Method and Description |
---|---|
javax.money.MonetaryAmount |
getAmount()
Deprecated.
|
ZonedDateTime |
getUntil()
Deprecated.
|
static SetAuthorization |
of(javax.money.MonetaryAmount amount)
Deprecated.
|
static SetAuthorization |
of(javax.money.MonetaryAmount amount,
ZonedDateTime until)
Deprecated.
|
static SetAuthorization |
ofRemove()
Deprecated.
|
getAction
public static SetAuthorization of(@Nullable javax.money.MonetaryAmount amount)
public static SetAuthorization of(@Nullable javax.money.MonetaryAmount amount, @Nullable ZonedDateTime until)
@Nullable public javax.money.MonetaryAmount getAmount()
@Nullable public ZonedDateTime getUntil()
public static SetAuthorization ofRemove()