satellite/payemnts: Credit coin payments earlier
Apply the coin payments when CoinPayments.net recieves the funds Instead of the when STORJ gets them from CoinPayments.net Based on 7/1/20 User Growth standup guidance by JG Relates to: https://storjlabs.atlassian.net/browse/USR-801 Change-Id: I174ca23a585010f39464c45525e1dfe0179b7c1a
This commit is contained in:
parent
ac716e1514
commit
00ae5ebbab
@ -199,11 +199,9 @@ func (service *Service) updateTransactions(ctx context.Context, ids TransactionA
|
||||
},
|
||||
)
|
||||
|
||||
// moment of transition to completed state, which indicates
|
||||
// that customer funds were accepted and transferred to our
|
||||
// account, so we can apply this amount to customer balance.
|
||||
// Therefore, create intent to update customer balance in the future.
|
||||
if info.Status == coinpayments.StatusCompleted {
|
||||
// moment of CoinPayments receives funds, not when STORJ does
|
||||
// this was a business decision to not wait until StatusCompleted
|
||||
if info.Status >= coinpayments.StatusReceived {
|
||||
//monkit currently does not have a DurationVal
|
||||
mon.IntVal("coinpayment_duration").Observe(int64(time.Since(creationTimes[id])))
|
||||
applies = append(applies, id)
|
||||
|
@ -283,7 +283,7 @@ func (db *coinPaymentsTransactions) ListPending(ctx context.Context, offset int6
|
||||
return page, nil
|
||||
}
|
||||
|
||||
// List Unapplied returns TransactionsPage with transactions completed transaction that should be applied to account balance.
|
||||
// List Unapplied returns TransactionsPage with a pending or completed status, that should be applied to account balance.
|
||||
func (db *coinPaymentsTransactions) ListUnapplied(ctx context.Context, offset int64, limit int, before time.Time) (_ stripecoinpayments.TransactionsPage, err error) {
|
||||
defer mon.Task()(&ctx)(&err)
|
||||
|
||||
@ -299,13 +299,13 @@ func (db *coinPaymentsTransactions) ListUnapplied(ctx context.Context, offset in
|
||||
FROM coinpayments_transactions as txs
|
||||
INNER JOIN stripecoinpayments_apply_balance_intents as ints
|
||||
ON txs.id = ints.tx_id
|
||||
WHERE txs.status = ?
|
||||
WHERE txs.status >= ?
|
||||
AND txs.created_at <= ?
|
||||
AND ints.state = ?
|
||||
ORDER by txs.created_at DESC
|
||||
LIMIT ? OFFSET ?`)
|
||||
|
||||
rows, err := db.db.QueryContext(ctx, query, coinpayments.StatusCompleted, before, applyBalanceIntentStateUnapplied, limit+1, offset)
|
||||
rows, err := db.db.QueryContext(ctx, query, coinpayments.StatusReceived, before, applyBalanceIntentStateUnapplied, limit+1, offset)
|
||||
if err != nil {
|
||||
return stripecoinpayments.TransactionsPage{}, err
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user