Skip to content

Commit

Permalink
feat(open banking): add callback url to api requests and fix broken l…
Browse files Browse the repository at this point in the history
…ink in earn popup modal
  • Loading branch information
blockdylanb committed Apr 15, 2021
1 parent 7f8690c commit 387b8bb
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 9 deletions.
3 changes: 2 additions & 1 deletion config/env/production.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ module.exports = {
ROOT_URL: 'https://blockchain.info',
VERIFF_URL: 'https://magic.veriff.me',
WALLET_HELPER_DOMAIN: 'https://wallet-helper.blockchain.com',
WEB_SOCKET_URL: 'wss://ws.blockchain.info'
WEB_SOCKET_URL: 'wss://ws.blockchain.info',
YAPILY_CALLBACK_URL: 'https://www.blockchain.com/brokerage-link-success'
}
3 changes: 2 additions & 1 deletion config/mocks/wallet-options-v4.json
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,7 @@
"root": "https://blockchain.info",
"veriff": "https://magic.veriff.me",
"walletHelper": "https://wallet-helper.blockchain.com",
"webSocket": "wss://ws.blockchain.info"
"webSocket": "wss://ws.blockchain.info",
"yapilyCallbackUrl": "https://staging.blockchain.com/brokerage-link-success"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,11 @@ export default ({

if (typeof account === 'string' && bankCredentials) {
// Yapily
const domainsR = yield select(selectors.core.walletOptions.getDomains)
const { yapilyCallbackUrl } = domainsR.getOrElse({})
const callback = yapilyCallbackUrl || undefined
bankId = bankCredentials.id
attributes = { institutionId: account }
attributes = { institutionId: account, callback }
} else if (typeof account === 'object' && fastLink) {
// Yodlee
bankId = fastLink.id
Expand Down Expand Up @@ -319,8 +322,17 @@ export default ({
const { id, partner } = yield select(
selectors.components.brokerage.getAccount
)
const domainsR = yield select(selectors.core.walletOptions.getDomains)
const { yapilyCallbackUrl } = domainsR.getOrElse({})
const callback = partner === 'YAPILY' ? yapilyCallbackUrl : undefined
try {
const data = yield call(api.createFiatDeposit, amount, id, currency)
const data = yield call(
api.createFiatDeposit,
amount,
id,
currency,
callback
)
const { RETRY_AMOUNT, SECONDS } = POLLING
// If yapily we need to transition to another screen and poll for auth
// details before polling for order status
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -552,10 +552,10 @@ export default ({
const stopShowingInterestModal = function * () {
try {
yield call(api.stopInterestCtaAfterTransaction, false)
yield put(actions.modals.closeModal('InterestPromo'))
} catch (e) {
yield put(actions.logs.logErrorMessage(logLocation, 'InterestPromo', e))
}
yield put(actions.modals.closeModal('InterestPromo'))
}

return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,7 @@ export default ({
try {
if (!order) throw new Error(NO_ORDER_EXISTS)
yield put(actions.form.startSubmit('sbCheckoutConfirm'))
const account = selectors.components.brokerage.getAccount(yield select())
const domainsR = selectors.core.walletOptions.getDomains(yield select())
const domains = domainsR.getOrElse({
walletHelper: 'https://wallet-helper.blockchain.com'
Expand All @@ -472,6 +473,8 @@ export default ({
}
}
: undefined
} else if (account?.partner === 'YAPILY') {
attributes = { callback: domains.yapilyCallbackUrl || undefined }
}

let confirmedOrder: SBOrderType = yield call(
Expand All @@ -481,7 +484,6 @@ export default ({
paymentMethodId
)
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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,8 @@ const buildDevServerConfig = (
root: envConfig.ROOT_URL,
veriff: envConfig.VERIFF_URL,
walletHelper: envConfig.WALLET_HELPER_DOMAIN,
webSocket: envConfig.WEB_SOCKET_URL
webSocket: envConfig.WEB_SOCKET_URL,
yapilyCallbackUrl: envConfig.YAPILY_CALLBACK_URL
}

res.json(mockWalletOptions)
Expand Down
10 changes: 8 additions & 2 deletions packages/blockchain-wallet-v4/src/network/api/simpleBuy/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,19 @@ export default ({
amount: number,
bankId: string,
currency: FiatType,
product: 'SIMPLEBUY' = 'SIMPLEBUY'
callback: string | undefined
) =>
authorizedPost({
url: nabuUrl,
contentType: 'application/json',
endPoint: `/payments/banktransfer/${bankId}/payment`,
data: { amount, currency, product, orderId: uuidv4() }
data: {
amount,
currency,
product: 'SIMPLEBUY',
orderId: uuidv4(),
callback
}
})

const createSBOrder = (
Expand Down

0 comments on commit 387b8bb

Please sign in to comment.