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

feat(api): cancel outgoing payment #2694

Merged
merged 22 commits into from
May 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
cff6bf3
feat(localenv): cancel outgoing payment on created webhook
golobitch May 1, 2024
94e585b
feat(graphql): cancel outgoing payment api
golobitch May 1, 2024
9831007
feat(outgoing-payment): cancel outgoing payment service implementation
golobitch May 1, 2024
93983a6
feat(backend): add cancel outgoing payment resolver
golobitch May 2, 2024
f177e97
test(outgoing-payment): cancel outgoing payment tests
golobitch May 2, 2024
e7d0da7
chore(lint): cancel outgoing payment code
golobitch May 2, 2024
283a8d4
feat(frontend): add canceled badge color
golobitch May 2, 2024
a52097e
docs(event-handlers): cancel outgoing payment
golobitch May 2, 2024
1093442
feat(bruno): cancel outgoing payment
golobitch May 2, 2024
9ba6a7d
chore(lint): outgoing payment service
golobitch May 2, 2024
3a0c14b
feat(mase): cancel outgoing payment if pending debit throws error
golobitch May 3, 2024
329555d
test(outgoing-payment): mark cancel state as undefined webhook type
golobitch May 3, 2024
3dec80d
docs(event-handlers): wording
golobitch May 3, 2024
7c9f5c0
docs(event-handlers): merge two diagrams with alt
golobitch May 3, 2024
7a5ec07
feat(graphql): make reason in cancel outgoing payment optional
golobitch May 3, 2024
c6a51b5
test(outgoing-payment): resolver
golobitch May 3, 2024
0cc3727
test(outgoing-payment): add service tests + lint
golobitch May 4, 2024
4476e06
tests(outgoing-payment): remove only call
golobitch May 7, 2024
2d09e58
chore(outgoing-payment): inplace assertion without new variable
golobitch May 7, 2024
4ac8675
chore(outgoing-payment): check if reason is defined before adding to …
golobitch May 7, 2024
0d1b4dd
chore(schema): add more information regarding cancellation reason
golobitch May 7, 2024
33ae554
fix(outgoing-payment): test rename dataCheck variable
golobitch May 7, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
meta {
name: Cancel Outgoing Payment
type: graphql
seq: 43
}

post {
url: {{RafikiGraphqlHost}}/graphql
body: graphql
auth: none
}

body:graphql {
mutation CancelOutgoingPayment($input: CancelOutgoingPaymentInput!) {
cancelOutgoingPayment(input: $input) {
code
message
success
}
}
}

body:graphql:vars {
{
"input": {
"id": "{{outgoingPaymentId}}",
"reason": "Not enough balance"
}
}
}
6 changes: 6 additions & 0 deletions localenv/cloud-nine-wallet/seed.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ accounts:
path: accounts/wbdc
brunoEnvVar: wbdcWalletAddress
assetCode: USD
- name: "Broke Account"
golobitch marked this conversation as resolved.
Show resolved Hide resolved
id: 5a95366f-8cb4-4925-88d9-ae57dcb444bb
initialBalance: 50
path: accounts/broke
brunoEnvVar: brokeWalletAddress
assetCode: USD
rates:
EUR:
MXN: 18.78
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,28 @@ export async function handleOutgoingPaymentCreated(wh: Webhook) {

const amt = parseAmount(payment['debitAmount'] as AmountJSON)

await mockAccounts.pendingDebit(acc.id, amt.value)
try {
await mockAccounts.pendingDebit(acc.id, amt.value)
} catch (err) {
await apolloClient.mutate({
mutation: gql`
mutation CancelOutgoingPayment($input: CancelOutgoingPaymentInput!) {
cancelOutgoingPayment(input: $input) {
code
success
message
}
}
`,
variables: {
input: {
id: payment.id,
reason: 'Account does not have enough balance.'
}
}
})
return
}

// notify rafiki
await apolloClient
Expand Down
19 changes: 19 additions & 0 deletions localenv/mock-account-servicing-entity/generated/graphql.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions localenv/mock-account-servicing-entity/seed.example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ accounts:
assetCode: USD
scale: 2
path: accounts/wbdc
- name: "Broke account"
id: 5a95366f-8cb4-4925-88d9-ae57dcb444bb
initialBalance: 0
assetCode: USD
scale: 2
path: accounts/broke
fees:
- fixed: 100
basisPoints: 200
Expand Down
78 changes: 78 additions & 0 deletions packages/backend/src/graphql/generated/graphql.schema.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions packages/backend/src/graphql/generated/graphql.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion packages/backend/src/graphql/resolvers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ import {
getOutgoingPayment,
createOutgoingPayment,
getWalletAddressOutgoingPayments,
createOutgoingPaymentFromIncomingPayment
createOutgoingPaymentFromIncomingPayment,
cancelOutgoingPayment
} from './outgoing_payment'
import { getPeer, getPeers, createPeer, updatePeer, deletePeer } from './peer'
import {
Expand Down Expand Up @@ -115,6 +116,7 @@ export const resolvers: Resolvers = {
createQuote,
createOutgoingPayment,
createOutgoingPaymentFromIncomingPayment,
cancelOutgoingPayment,
createIncomingPayment,
createReceiver,
createPeer: createPeer,
Expand Down