Skip to content

Commit

Permalink
fix(simple buy): fix issue where order confirmwasnt showing on yodlee…
Browse files Browse the repository at this point in the history
… orders due to yapily
  • Loading branch information
blockdylanb committed Apr 13, 2021
1 parent 9cf1396 commit a3b09d1
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,7 @@ type MessagesType = {
'modals.brokerage.timed_out_sub': 'This happens from time to time. Wait a few minutes and then check the status of your deposit in the transaction list.'
'modals.brokerage.use_phone_camera': 'Use your phone’s camera to scan the QR code.'
'modals.brokerage.waiting_to_hear': 'Waiting to hear from your bank'
'modals.brokerage.this_can_take_a_while': 'This can take a while, hold tight!'
'modals.brokerage.this_can_take_a_while': 'This can take several minutes, hold tight!'
'modals.brokerage.yodlee_description': 'Yodlee securely stores your credentials adhering to leading industry practices for data security, regulatory compliance, and privacy.'
'modals.brokerage.daily_limit': 'Daily Limit'
'modals.brokerage.deposit_methods': 'Select a Deposit Method'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { getFormValues } from 'redux-form'
import { call, put, retry, select, take } from 'redux-saga/effects'
import { call, delay, put, retry, select, take } from 'redux-saga/effects'

import { Remote } from 'blockchain-wallet-v4/src'
import { APIType } from 'blockchain-wallet-v4/src/network/api'
Expand Down Expand Up @@ -322,6 +322,8 @@ export default ({
try {
const data = yield call(api.createFiatDeposit, amount, id, currency)
const { RETRY_AMOUNT, SECONDS } = POLLING
// If yapily we need to transition to another screen and poll for auth
// details before polling for order status
if (partner === 'YAPILY') {
const order = yield retry(
RETRY_AMOUNT,
Expand All @@ -340,25 +342,28 @@ export default ({
dwStep: BankDWStepType.DEPOSIT_CONNECT
})
)
try {
const updatedOrder: SBTransactionType = yield retry(
RETRY_AMOUNT,
SECONDS * 1000,
ClearedStatusCheck,
data.paymentId
)
yield put(actions.form.change('brokerageTx', 'order', updatedOrder))
} catch (error) {
yield put(actions.form.change('brokerageTx', 'retryTimeout', true))
}
}
}
// Poll for order status in order to show success, timed out or failed
try {
const updatedOrder: SBTransactionType = yield retry(
RETRY_AMOUNT,
SECONDS * 1000,
ClearedStatusCheck,
data.paymentId
)
yield put(actions.form.change('brokerageTx', 'order', updatedOrder))
} catch (error) {
yield put(actions.form.change('brokerageTx', 'retryTimeout', true))
}

yield put(
actions.components.brokerage.setDWStep({
dwStep: BankDWStepType.DEPOSIT_STATUS
})
)
// refresh the fiat list so the newest tx shows up right away
// refresh the tx list after small delay so the newest tx shows up right away
yield delay(1000)
yield put(actions.core.data.fiat.fetchTransactions(currency, true))
} catch (e) {
const error = errorHandler(e)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ export const DEFAULT_SB_METHODS = {
methods: []
}

export const POLLING = {
SECONDS: 10,
RETRY_AMOUNT: 30
}

export const LIMIT = { min: '500', max: '10000' } as Limits
export const LIMIT_FACTOR = 100 // we get 10000 from API

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ import {
NO_ORDER_EXISTS,
NO_PAIR_SELECTED,
NO_PAYMENT_TYPE,
POLLING,
SDD_TIER
} from './model'
import * as S from './selectors'
Expand Down Expand Up @@ -479,16 +480,22 @@ export default ({
attributes,
paymentMethodId
)

if (confirmedOrder.state === 'PENDING_DEPOSIT') {
const { RETRY_AMOUNT, SECONDS } = POLLING
const account = selectors.components.brokerage.getAccount(yield select())
if (account?.partner === 'YAPILY') {
// for OB the authorisationUrl isn't in the initial response to confirm
// order. We need to poll the order for it.
const order = yield retry(100, 10000, AuthUrlCheck, confirmedOrder.id)
const order = yield retry(
RETRY_AMOUNT,
SECONDS * 1000,
AuthUrlCheck,
confirmedOrder.id
)
yield put(A.setStep({ step: 'OPEN_BANKING_CONNECT', order }))
// Now we need to poll for the order success
confirmedOrder = yield retry(
100,
10000,
RETRY_AMOUNT,
SECONDS * 1000,
OrderConfirmCheck,
confirmedOrder.id
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ const BankWaitIndicator = ({ qrCode }: { readonly qrCode?: string }) => {
{waitCount > 0 && (
<FormattedMessage
id='modals.brokerage.this_can_take_a_while'
defaultMessage='This can take a while, hold tight!'
defaultMessage='This can take several minutes, hold tight!'
/>
)}
</Text>
Expand Down

0 comments on commit a3b09d1

Please sign in to comment.