Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add cancelOutgoingPayment GraphQL API #2688

Closed
4 tasks
mkurapov opened this issue Apr 30, 2024 · 2 comments · Fixed by #2694
Closed
4 tasks

Add cancelOutgoingPayment GraphQL API #2688

mkurapov opened this issue Apr 30, 2024 · 2 comments · Fixed by #2694
Assignees
Labels
pkg: backend Changes in the backend package.

Comments

@mkurapov
Copy link
Contributor

mkurapov commented Apr 30, 2024

Context

Currently, when we create an outgoing payment, we send a outgoing_payment.created webhook to the ASE such that the ASE can check the user account, place a hold on the account for the payment amount, and then call fundOutgoingPayment, to deposit liquidity into the payment. Then, the ILP payment starts sending into the incoming payment.

Sometimes, however, the sending user account may not have enough balance to fulfill the outgoing payment amount. Rafiki does not provide a way for the ASE to notify about this possibility, and as a result, the outgoing payment will indefinitely stay in a FUNDING state.

We should allow the ASE to notify Rafiki about this possibility through a new Admin API, cancelOutgoingPayment (name always up for discussion). cancelOutgoingPayment will take in the outgoingPaymentId and update the state of the outgoing payment to a new state CANCELLED.

The only time an outgoing payment can be marked CANCELLED is if it is in a FUNDING state.
Make sure to also update the OutgoingPayment.failed getter in the model to include this state, so that we properly return failed: true when it is fetched via Open Payments.
Also, there is no need to send a webhook when an outgoing payment has been cancelled.

Todos

  • Create cancelOutgoingPayment mutation
  • Update the OutgoingPaymentState enum in the GraphQL API
  • Update the mock ASE to call this mutation when a user does not have enough balance.
  • Make sure to add description to the mutation
@mkurapov mkurapov added the pkg: backend Changes in the backend package. label Apr 30, 2024
@golobitch
Copy link
Collaborator

@mkurapov how do you imagine flow here? So when should ASE perform balance check and call cancelOutgoingPayment in case there is not enough balance?

I assume that this check needs to be performed when ASE receives outgoing_payment.created webhook right?

@golobitch golobitch self-assigned this May 1, 2024
@mkurapov
Copy link
Contributor Author

mkurapov commented May 1, 2024

@golobitch exactly,

  1. Receive outgoing_payment.created webhook
  2. If enough balance on user account, call fundOutgoingPayment
  3. If not enough balance (or some other system error), call cancelOutgoingPayment
  4. Reply 200

@golobitch golobitch linked a pull request May 1, 2024 that will close this issue
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg: backend Changes in the backend package.
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants