support deleting payment accounts #1136

This commit is contained in:
woodser 2024-07-16 16:11:50 -04:00 committed by GitHub
parent 0a469db8f6
commit 9c359b5e29
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 38 additions and 0 deletions

View file

@ -496,6 +496,10 @@ public class CoreApi {
tradeInstant);
}
public void deletePaymentAccount(String paymentAccountId) {
paymentAccountsService.deletePaymentAccount(paymentAccountId);
}
public List<PaymentMethod> getCryptoCurrencyPaymentMethods() {
return paymentAccountsService.getCryptoCurrencyPaymentMethods();
}

View file

@ -145,6 +145,16 @@ class CorePaymentAccountsService {
return cryptoCurrencyAccount;
}
synchronized void deletePaymentAccount(String paymentAccountId) {
accountService.checkAccountOpen();
PaymentAccount paymentAccount = getPaymentAccount(paymentAccountId);
if (paymentAccount == null) throw new IllegalArgumentException(format("Payment account with id %s not found", paymentAccountId));
user.removePaymentAccount(paymentAccount);
log.info("Deleted payment account with id {} and payment method {}.",
paymentAccount.getId(),
paymentAccount.getPaymentAccountPayload().getPaymentMethodId());
}
// TODO Support all alt coin payment methods supported by UI.
// The getCryptoCurrencyPaymentMethods method below will be
// callable from the CLI when more are supported.