Skip to content
This repository was archived by the owner on Jan 22, 2026. It is now read-only.

Commit 981d5b3

Browse files
authored
Merge pull request #1709 from blockchain/hotfix/coinify-payment-page
Hotfix/coinify payment page
2 parents 64b0c09 + 43ad62e commit 981d5b3

13 files changed

Lines changed: 210 additions & 1123 deletions

File tree

config/env/production.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
module.exports = {
22
API_DOMAIN: 'https://api.blockchain.info',
33
COINIFY_URL: 'https://app-api.coinify.com',
4+
COINIFY_PAYMENT_DOMAIN: 'https://pay.coinify.com',
45
COM_WALLET_APP: 'https://login.blockchain.com',
56
COM_ROOT: 'https://blockchain.com',
67
HORIZON_URL: 'https://horizon.stellar.org',

config/env/testnet.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
module.exports = {
22
API_DOMAIN: 'https://api-testnet.blockchain.info',
33
COINIFY_URL: 'https://app-api.coinify.com',
4+
COINIFY_PAYMENT_DOMAIN: 'https://pay.sandbox.coinify.com',
45
HORIZON_URL: 'https://horizon-testnet.stellar.org',
56
LEDGER_SOCKET_URL: 'wss://api.ledgerwallet.com',
67
LEDGER_URL: 'https://manager.api.live.ledger.com',

config/mocks/wallet-options-v4.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -242,8 +242,7 @@
242242
"config": {
243243
"partnerId": 24,
244244
"production": false,
245-
"iSignThisDomain": "https://stage-coinify-verify.isignthis.com",
246-
"coinifyPaymentDomain": "https://pay.coinify.com"
245+
"iSignThisDomain": "https://stage-coinify-verify.isignthis.com"
247246
}
248247
},
249248
"sfox": {
@@ -338,16 +337,17 @@
338337
"android": {}
339338
},
340339
"domains": {
341-
"root": "https://blockchain.info",
342340
"api": "https://api.blockchain.info",
343-
"webSocket": "wss://ws.blockchain.info",
344-
"walletHelper": "https://wallet-helper.blockchain.com",
345-
"comWalletApp": "https://login.blockchain.com",
341+
"coinify": "https://app-api.coinify.com",
342+
"coinifyPaymentDomain": "https://pay.coinify.com",
346343
"comRoot": "https://www.blockchain.com",
344+
"comWalletApp": "https://login.blockchain.com",
345+
"horizon": "https://horizon.stellar.org",
347346
"ledger": "https://manager.api.live.ledger.com",
348347
"ledgerSocket": "wss://api.ledgerwallet.com",
349-
"horizon": "https://horizon.stellar.org",
348+
"root": "https://blockchain.info",
350349
"veriff": "https://magic.veriff.me",
351-
"coinify": "https://app-api.coinify.com"
350+
"walletHelper": "https://wallet-helper.blockchain.com",
351+
"webSocket": "wss://ws.blockchain.info"
352352
}
353353
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "blockchain-wallet-v4",
3-
"version": "4.19.7",
3+
"version": "4.19.9",
44
"license": "AGPL-3.0-or-later",
55
"private": true,
66
"author": {

packages/blockchain-wallet-v4-frontend/src/components/BuySell/Coinify/ISignThis/index.js

Lines changed: 157 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import styled from 'styled-components'
33
import { connect } from 'react-redux'
44
import { bindActionCreators } from 'redux'
55
import { actions } from 'data'
6-
import { prop } from 'ramda'
6+
import { path, prop } from 'ramda'
77
import { Button, Text, TooltipHost, Icon } from 'blockchain-info-components'
88
import { FormattedMessage } from 'react-intl'
99

@@ -83,6 +83,162 @@ class ISignThisContainer extends PureComponent {
8383
quoteExpired: false
8484
}
8585

86+
componentDidMount () {
87+
window.addEventListener('message', function (e) {})
88+
89+
const onComplete = e => {
90+
// eslint-disable-next-line
91+
console.log(e)
92+
this.props.coinifyActions.fromISX(e)
93+
}
94+
95+
var e = document.getElementById('isx-iframe')
96+
const iSignThisDomain = this.props.walletOptions
97+
.map(path(['platforms', 'web', 'coinify', 'config', 'iSignThisDomain']))
98+
.getOrElse(null)
99+
const coinifyPaymentDomain = this.props.walletOptions
100+
.map(path(['domains', 'coinifyPaymentDomain']))
101+
.getOrElse(null)
102+
103+
var _isx = {
104+
transactionId: '',
105+
version: '1.0.0',
106+
configOptions: null
107+
}
108+
109+
_isx.applyContainerStyles = function (c) {
110+
c.style['width'] = '100%'
111+
if (this.configOptions.height) {
112+
c.style['height'] = this.configOptions.height
113+
} else {
114+
c.style['height'] = '700px'
115+
}
116+
c.style['overflow'] = 'hidden'
117+
}
118+
119+
_isx.setup = function (setup) {
120+
this.transactionId = setup.transaction_id
121+
this.configOptions = setup
122+
123+
return this
124+
}
125+
126+
_isx.done = function (_completeListener) {
127+
this.completeListener = _completeListener
128+
return this
129+
}
130+
131+
_isx.fail = function (_errorListener) {
132+
this.errorListener = _errorListener
133+
return this
134+
}
135+
136+
_isx.route = function (_routeListener) {
137+
this.routeListener = _routeListener
138+
return this
139+
}
140+
141+
_isx.resized = function (_resizeListener) {
142+
this.resizeListener = _resizeListener
143+
return this
144+
}
145+
146+
_isx.publish = function () {
147+
this.iframe = e
148+
// Create IE + others compatible event handler
149+
let eventMethod = window.addEventListener
150+
? 'addEventListener'
151+
: 'attachEvent'
152+
let eventer = window[eventMethod]
153+
let messageEvent = eventMethod === 'attachEvent' ? 'onmessage' : 'message'
154+
let self = this
155+
// Listen to message from child window
156+
eventer(
157+
messageEvent,
158+
function (e) {
159+
// Check for the domain who sent the messageEvent
160+
let origin = e.origin || e.originalEvent.origin
161+
// eslint-disable-next-line
162+
console.log(e)
163+
if (![iSignThisDomain, coinifyPaymentDomain].includes(origin)) {
164+
// Event not generated from ISX or coinifyPaymentDomain, simply return
165+
return
166+
}
167+
168+
let frame = document.getElementById('isx-iframe')
169+
if (e.source !== prop('contentWindow', frame)) {
170+
// Source of message isn't from the iframe
171+
return
172+
}
173+
174+
try {
175+
let d = JSON.parse(e.data.split('[ISX-Embed]')[1])
176+
// eslint-disable-next-line
177+
console.log(d)
178+
179+
if (d.event.toLowerCase() === 'complete') {
180+
if (self.completeListener) {
181+
self.completeListener(d)
182+
}
183+
} else if (d.event.toLowerCase() === 'route') {
184+
if (self.routeListener) {
185+
self.routeListener(d)
186+
}
187+
} else if (d.event.toLowerCase() === 'error') {
188+
if (self.errorListener) {
189+
self.errorListener(d)
190+
}
191+
} else if (d.event.toLowerCase() === 'resized') {
192+
if (self.resizeListener) {
193+
self.resizeListener(d)
194+
}
195+
}
196+
} catch (err) {}
197+
},
198+
false
199+
)
200+
201+
return this
202+
}
203+
var widget = {
204+
transaction_id: this.props.iSignThisId,
205+
container_id: 'isx-iframe'
206+
}
207+
208+
var setState = state => {
209+
// console.log('V4 ISX_COMPONENT: setState', state)
210+
switch (state) {
211+
case 'SUCCESS':
212+
onComplete('processing')
213+
break
214+
case 'CANCELLED':
215+
onComplete('cancelled')
216+
break
217+
case 'EXPIRED':
218+
onComplete('expired')
219+
break
220+
case 'DECLINED':
221+
case 'FAILED':
222+
case 'REJECTED':
223+
onComplete('rejected')
224+
break
225+
case 'PENDING':
226+
onComplete('reviewing')
227+
break
228+
}
229+
}
230+
231+
_isx
232+
.setup(widget)
233+
.done(function (e) {
234+
setState(e.state)
235+
})
236+
.fail(function (e) {})
237+
.resized(function (e) {})
238+
.route(function (e) {})
239+
.publish()
240+
}
241+
86242
onQuoteExpiration = () => {
87243
this.setState({ quoteExpired: true })
88244
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
import { path } from 'ramda'
12
import { selectors } from 'data'
23

34
export const getData = state => ({
5+
walletOptions: path(['walletOptionsPath'], state),
46
quoteR: selectors.core.data.coinify.getQuote(state),
57
trade: selectors.core.data.coinify.getTrade(state)
68
})

packages/blockchain-wallet-v4-frontend/src/data/components/coinify/actionTypes.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ export const COINIFY_SET_CHECKOUT_ERROR =
2323
export const COINIFY_CLEAR_CHECKOUT_ERROR =
2424
'@COMPONENT.COINIFY_CLEAR_CHECKOUT_ERROR'
2525

26+
export const COINIFY_FROM_ISX = '@COMPONENT.COINIFY_FROM_ISX'
27+
2628
export const COINIFY_LOADING = '@COMPONENT.COINIFY_LOADING'
2729
export const COINIFY_SUCCESS = '@COMPONENT.COINIFY_SUCCESS'
2830
export const COINIFY_FAILURE = '@COMPONENT.COINIFY_FAILURE'

packages/blockchain-wallet-v4-frontend/src/data/components/coinify/actions.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ export const clearCoinifyCheckoutError = () => ({
3636
type: AT.COINIFY_CLEAR_CHECKOUT_ERROR
3737
})
3838

39+
export const fromISX = state => ({ type: AT.COINIFY_FROM_ISX, payload: state })
40+
3941
export const coinifyNotAsked = () => ({ type: AT.COINIFY_NOT_ASKED })
4042
export const coinifyLoading = () => ({ type: AT.COINIFY_LOADING })
4143
export const coinifySuccess = () => ({ type: AT.COINIFY_SUCCESS })

packages/blockchain-wallet-v4-frontend/src/data/components/coinify/sagaRegister.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export default ({ api, coreSagas, networks }) => {
1616
AT.COINIFY_DELETE_BANK_ACCOUNT,
1717
coinifySagas.deleteBankAccount
1818
)
19+
yield takeLatest(AT.COINIFY_FROM_ISX, coinifySagas.fromISX)
1920
yield takeLatest(AT.FINISH_TRADE, coinifySagas.finishTrade)
2021
yield takeLatest(AT.CANCEL_TRADE, coinifySagas.cancelTrade)
2122
yield takeLatest(AT.CANCEL_SUBSCRIPTION, coinifySagas.cancelSubscription)

packages/blockchain-wallet-v4-frontend/src/data/components/coinify/sagas.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,29 @@ export default ({ api, coreSagas, networks }) => {
429429
}
430430
}
431431

432+
const fromISX = function * (action) {
433+
const status = action.payload
434+
try {
435+
const tradeR = yield select(selectors.core.data.coinify.getTrade)
436+
const trade = tradeR.getOrElse({})
437+
// eslint-disable-next-line
438+
console.log('fromISX', trade)
439+
440+
yield put(
441+
actions.form.change('buySellTabStatus', 'status', 'order_history')
442+
)
443+
yield put(A.coinifyNextCheckoutStep('checkout'))
444+
yield put(
445+
actions.modals.showModal('CoinifyTradeDetails', {
446+
trade: trade,
447+
status: status
448+
})
449+
)
450+
} catch (e) {
451+
yield put(actions.logs.logErrorMessage(logLocation, 'fromISX', e))
452+
}
453+
}
454+
432455
const deleteBankAccount = function * (payload) {
433456
try {
434457
yield call(coreSagas.data.coinify.deleteBankAccount, payload)
@@ -580,6 +603,7 @@ export default ({ api, coreSagas, networks }) => {
580603
deleteBankAccount,
581604
fetchCoinifyData,
582605
finishTrade,
606+
fromISX,
583607
handleChange,
584608
initialized,
585609
initializePayment,

0 commit comments

Comments
 (0)