Skip to content

Commit

Permalink
#1761 - [Bug] Dismissing a payment and resending it doesn't clear it …
Browse files Browse the repository at this point in the history
…as being sent (#1772)

* correct the check for payment status

* fix the issue where dismissing payment works incorrectly
  • Loading branch information
SebinSong authored Oct 18, 2023
1 parent 5694fd7 commit e12a939
Showing 1 changed file with 35 additions and 18 deletions.
53 changes: 35 additions & 18 deletions frontend/views/containers/payments/RecordPayment.vue
Original file line number Diff line number Diff line change
Expand Up @@ -131,16 +131,16 @@ export default ({
]),
paymentsList () {
return this.todoItems.map(item => {
return item.status === PAYMENT_NOT_RECEIVED // if not received item, re-format the obj
return item.data && item.data.status === PAYMENT_NOT_RECEIVED // if not received item, re-format the obj
? {
hash: item.hash,
data: item.data,
meta: item.meta,
username: item.toUser,
displayName: this.userDisplayName(item.toUser),
username: item.data.toUser,
displayName: this.userDisplayName(item.data.toUser),
date: item.meta.createdDate,
monthstamp: dateToMonthstamp(item.createdDate),
amount: item.amount
monthstamp: dateToMonthstamp(item.meta.createdDate),
amount: item.data.amount
}
: item
})
Expand Down Expand Up @@ -172,6 +172,7 @@ export default ({
for (const pRecord of paymentsToRecord) {
const payment = this.paymentsList[pRecord.index]
const isStatusNotReceived = payment.data && payment.data.status === PAYMENT_NOT_RECEIVED
if (pRecord.amount > payment.amount) {
// TODO/REVIEW - Should we show a warning?
Expand Down Expand Up @@ -199,20 +200,36 @@ export default ({
paymentType: PAYMENT_TYPE_MANUAL,
...(memo ? { memo } : {}) // TODO/BUG with flowTyper validation. Empty string '' fails.
}
const msg = await sbp('gi.actions/group/payment', {
contractID: this.currentGroupId, data: paymentInfo
})
// TODO: hack until /payment supports sending completed payment
// (and "uncompleting" a payment)
await sbp('gi.actions/group/paymentUpdate', {
contractID: this.currentGroupId,
data: {
paymentHash: msg.hash(),
updatedProperties: {
status: PAYMENT_COMPLETED
if (isStatusNotReceived) {
// If it's re-sending the payment that has been marked as 'not-recieved' by the receiver,
// only update the details of the existing payment item so that it doesn't lead to duplication bug in the payment UI.
await sbp('gi.actions/group/paymentUpdate', {
contractID: this.currentGroupId,
data: {
paymentHash: payment.hash,
updatedProperties: {
...paymentInfo,
status: PAYMENT_COMPLETED
}
}
}
})
})
} else {
const msg = await sbp('gi.actions/group/payment', {
contractID: this.currentGroupId, data: paymentInfo
})
// TODO: hack until /payment supports sending completed payment
// (and "uncompleting" a payment)
await sbp('gi.actions/group/paymentUpdate', {
contractID: this.currentGroupId,
data: {
paymentHash: msg.hash(),
updatedProperties: {
status: PAYMENT_COMPLETED
}
}
})
}
} catch (e) {
hasError = true
console.error('RecordPayment submit() error:', e)
Expand Down

0 comments on commit e12a939

Please sign in to comment.