Skip to content

Commit 7fb795d

Browse files
committed
simplex debug
1 parent 7c3f338 commit 7fb795d

2 files changed

Lines changed: 56 additions & 49 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
- added: `chooseCaip19Asset` EdgeProvider API for precise wallet selection using CAIP-19 identifiers
66
- added: Pass OS and app version details to core context for v2/coreRollup endpoint
77
- changed: Append chain names to token codes in RampCreateScene
8+
- fixed: Simplex buy/sell success status detection
89

910
## 4.42.0 (staging)
1011

src/plugins/ramps/simplex/simplexRampPlugin.ts

Lines changed: 55 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import {
2727
validateRampQuoteRequest
2828
} from '../utils/constraintUtils'
2929
import { getSettlementRange } from '../utils/getSettlementRange'
30-
import { openExternalWebView } from '../utils/webViewUtils'
30+
// import { openExternalWebView } from '../utils/webViewUtils' // Temporarily using guiPluginWebView for debugging
3131
import {
3232
asInfoJwtSignResponse,
3333
asInitOptions,
@@ -677,57 +677,63 @@ export const simplexRampPlugin: RampPluginFactory = (
677677
}
678678

679679
const token = await fetchJwtToken(state.jwtTokenProvider, data)
680-
const url = `${widgetUrl}/?partner=${state.partner}&t=${token}`
681-
682-
await openExternalWebView({
680+
const returnUrlSuccess = encodeURIComponent(
681+
`https://deep.edge.app/ramp/buy/${pluginId}?status=success`
682+
)
683+
const returnUrlFail = encodeURIComponent(
684+
`https://deep.edge.app/ramp/buy/${pluginId}?status=failure`
685+
)
686+
const url = `${widgetUrl}/?partner=${state.partner}&t=${token}&return_url_success=${returnUrlSuccess}&return_url_fail=${returnUrlFail}`
687+
688+
console.log(`[Simplex DEBUG] Opening webview with URL: ${url}`)
689+
690+
// Using guiPluginWebView for debugging to see URL changes
691+
navigation.navigate('guiPluginWebView', {
683692
url,
684-
deeplink: {
685-
direction: 'buy',
686-
providerId: pluginId,
687-
handler: async link => {
688-
if (link.direction !== 'buy') return
689-
690-
const orderId = link.query.orderId ?? 'unknown'
691-
const status = link.query.status?.replace('?', '')
692-
693-
switch (status) {
694-
case 'success': {
695-
onLogEvent('Buy_Success', {
696-
conversionValues: {
697-
conversionType: 'buy',
698-
sourceFiatCurrencyCode: simplexFiatCode,
699-
sourceFiatAmount:
700-
goodQuote.fiat_money.amount.toString(),
701-
destAmount: new CryptoAmount({
702-
currencyConfig: coreWallet.currencyConfig,
703-
tokenId: request.tokenId,
704-
exchangeAmount:
705-
goodQuote.digital_money.amount.toString()
706-
}),
707-
fiatProviderId: pluginId,
708-
orderId
709-
}
710-
})
711-
navigation.pop()
712-
break
713-
}
714-
case 'failure': {
715-
showToast(
716-
lstrings.fiat_plugin_buy_failed_try_again,
717-
NOT_SUCCESS_TOAST_HIDE_MS
718-
)
719-
navigation.pop()
720-
break
693+
onUrlChange: (newUrl: string) => {
694+
console.log(`[Simplex DEBUG] onUrlChange: ${newUrl}`)
695+
696+
// Check for success indicators
697+
if (
698+
newUrl.includes('transaction-approved') ||
699+
newUrl.includes('status=success') ||
700+
newUrl.includes('deep.edge.app')
701+
) {
702+
console.log(`[Simplex DEBUG] SUCCESS detected in URL!`)
703+
onLogEvent('Buy_Success', {
704+
conversionValues: {
705+
conversionType: 'buy',
706+
sourceFiatCurrencyCode: simplexFiatCode,
707+
sourceFiatAmount: goodQuote.fiat_money.amount.toString(),
708+
destAmount: new CryptoAmount({
709+
currencyConfig: coreWallet.currencyConfig,
710+
tokenId: request.tokenId,
711+
exchangeAmount:
712+
goodQuote.digital_money.amount.toString()
713+
}),
714+
fiatProviderId: pluginId,
715+
orderId: 'debug-order'
721716
}
722-
default: {
723-
showToast(
724-
lstrings.fiat_plugin_buy_unknown_status,
725-
NOT_SUCCESS_TOAST_HIDE_MS
726-
)
727-
navigation.pop()
728-
}
729-
}
717+
})
718+
navigation.pop()
719+
}
720+
721+
// Check for failure indicators
722+
if (
723+
newUrl.includes('status=failure') ||
724+
newUrl.includes('status=fail')
725+
) {
726+
console.log(`[Simplex DEBUG] FAILURE detected in URL!`)
727+
showToast(
728+
lstrings.fiat_plugin_buy_failed_try_again,
729+
NOT_SUCCESS_TOAST_HIDE_MS
730+
)
731+
navigation.pop()
730732
}
733+
},
734+
onClose: () => {
735+
console.log(`[Simplex DEBUG] WebView closed by user`)
736+
return true // Allow close
731737
}
732738
})
733739
},

0 commit comments

Comments
 (0)