Skip to content

Commit

Permalink
Add Buy_Success conversion tracking for Banxa
Browse files Browse the repository at this point in the history
  • Loading branch information
samholmes committed Dec 2, 2024
1 parent 0106690 commit 785cb58
Show file tree
Hide file tree
Showing 13 changed files with 66 additions and 16 deletions.
4 changes: 3 additions & 1 deletion src/locales/en_US.ts
Original file line number Diff line number Diff line change
Expand Up @@ -735,7 +735,7 @@ const strings = {
transaction_details_fee_warning: 'High Network Fees',
transaction_details_swap: 'Swap Funds',
transaction_details_swap_network_fee: 'Swap Network Fee',
transaction_details_swap_order_cancel: 'Swap Order Canceled',
transaction_details_swap_order_cancel: 'Swap Order Cancelled',
transaction_details_swap_order_post: 'Swap Order Opened',
transaction_details_swap_order_fill: 'Swap Order Filled',
transaction_details_claim: 'Claim Staked Funds',
Expand Down Expand Up @@ -1464,11 +1464,13 @@ const strings = {
fiat_plugin_fetching_assets: 'Fetching supported assets',
fiat_plugin_sell_cancelled: 'Sell order cancelled',
fiat_plugin_finalizing_quote: 'Finalizing your exchange quote. Please wait as this may take up to a minute',
fiat_plugin_buy_cancelled: 'Buy order cancelled',
fiat_plugin_buy_complete_title: 'Buy Order Complete',
fiat_plugin_buy_complete_message_s: 'Your buy order of %1$s %2$s with %3$s %4$s has been completed.',
fiat_plugin_buy_complete_message_2_hour_s: 'Please allow up to %1$s hour for the funds to appear in your wallet.',
fiat_plugin_buy_complete_message_2_hours_s: 'Please allow up to %1$s hours for the funds to appear in your wallet.',
fiat_plugin_buy_failed_try_again: 'Buy order failed. Please try again',
fiat_plugin_buy_unknown_status: 'Unknown order status upon completion. Please contact support for assistence.',
fiat_plugin_sell_complete_title: 'Sell Order Complete',
fiat_plugin_sell_complete_message_s: 'Your sell order of %1$s %2$s for %3$s %4$s has been completed.',
fiat_plugin_sell_complete_message_2_hour_s: 'Please allow up to %1$s hour for the funds to appear in your account.',
Expand Down
2 changes: 1 addition & 1 deletion src/locales/strings/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,7 @@
"transaction_details_fee_warning": "Hohe Netzwerkgebühren",
"transaction_details_swap": "Swap Funds",
"transaction_details_swap_network_fee": "Swap Network Fee",
"transaction_details_swap_order_cancel": "Swap Order Canceled",
"transaction_details_swap_order_cancel": "Swap Order Cancelled",
"transaction_details_swap_order_post": "Swap Order Opened",
"transaction_details_swap_order_fill": "Swap Order Filled",
"transaction_details_claim": "Claim Staked Funds",
Expand Down
4 changes: 3 additions & 1 deletion src/locales/strings/enUS.json
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,7 @@
"transaction_details_fee_warning": "High Network Fees",
"transaction_details_swap": "Swap Funds",
"transaction_details_swap_network_fee": "Swap Network Fee",
"transaction_details_swap_order_cancel": "Swap Order Canceled",
"transaction_details_swap_order_cancel": "Swap Order Cancelled",
"transaction_details_swap_order_post": "Swap Order Opened",
"transaction_details_swap_order_fill": "Swap Order Filled",
"transaction_details_claim": "Claim Staked Funds",
Expand Down Expand Up @@ -1295,11 +1295,13 @@
"fiat_plugin_fetching_assets": "Fetching supported assets",
"fiat_plugin_sell_cancelled": "Sell order cancelled",
"fiat_plugin_finalizing_quote": "Finalizing your exchange quote. Please wait as this may take up to a minute",
"fiat_plugin_buy_cancelled": "Buy order cancelled",
"fiat_plugin_buy_complete_title": "Buy Order Complete",
"fiat_plugin_buy_complete_message_s": "Your buy order of %1$s %2$s with %3$s %4$s has been completed.",
"fiat_plugin_buy_complete_message_2_hour_s": "Please allow up to %1$s hour for the funds to appear in your wallet.",
"fiat_plugin_buy_complete_message_2_hours_s": "Please allow up to %1$s hours for the funds to appear in your wallet.",
"fiat_plugin_buy_failed_try_again": "Buy order failed. Please try again",
"fiat_plugin_buy_unknown_status": "Unknown order status upon completion. Please contact support for assistence.",
"fiat_plugin_sell_complete_title": "Sell Order Complete",
"fiat_plugin_sell_complete_message_s": "Your sell order of %1$s %2$s for %3$s %4$s has been completed.",
"fiat_plugin_sell_complete_message_2_hour_s": "Please allow up to %1$s hour for the funds to appear in your account.",
Expand Down
2 changes: 1 addition & 1 deletion src/locales/strings/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,7 @@
"transaction_details_fee_warning": "Tarifas de red altas",
"transaction_details_swap": "Swap Funds",
"transaction_details_swap_network_fee": "Swap Network Fee",
"transaction_details_swap_order_cancel": "Swap Order Canceled",
"transaction_details_swap_order_cancel": "Swap Order Cancelled",
"transaction_details_swap_order_post": "Swap Order Opened",
"transaction_details_swap_order_fill": "Swap Order Filled",
"transaction_details_claim": "Claim Staked Funds",
Expand Down
2 changes: 1 addition & 1 deletion src/locales/strings/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,7 @@
"transaction_details_fee_warning": "High Network Fees",
"transaction_details_swap": "Swap Funds",
"transaction_details_swap_network_fee": "Swap Network Fee",
"transaction_details_swap_order_cancel": "Swap Order Canceled",
"transaction_details_swap_order_cancel": "Swap Order Cancelled",
"transaction_details_swap_order_post": "Swap Order Opened",
"transaction_details_swap_order_fill": "Swap Order Filled",
"transaction_details_claim": "Claim Staked Funds",
Expand Down
2 changes: 1 addition & 1 deletion src/locales/strings/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,7 @@
"transaction_details_fee_warning": "高いネットワーク手数料",
"transaction_details_swap": "Swap Funds",
"transaction_details_swap_network_fee": "Swap Network Fee",
"transaction_details_swap_order_cancel": "Swap Order Canceled",
"transaction_details_swap_order_cancel": "Swap Order Cancelled",
"transaction_details_swap_order_post": "Swap Order Opened",
"transaction_details_swap_order_fill": "Swap Order Filled",
"transaction_details_claim": "Claim Staked Funds",
Expand Down
2 changes: 1 addition & 1 deletion src/locales/strings/kaa.json
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,7 @@
"transaction_details_fee_warning": "High Network Fees",
"transaction_details_swap": "Swap Funds",
"transaction_details_swap_network_fee": "Swap Network Fee",
"transaction_details_swap_order_cancel": "Swap Order Canceled",
"transaction_details_swap_order_cancel": "Swap Order Cancelled",
"transaction_details_swap_order_post": "Swap Order Opened",
"transaction_details_swap_order_fill": "Swap Order Filled",
"transaction_details_claim": "Claim Staked Funds",
Expand Down
2 changes: 1 addition & 1 deletion src/locales/strings/ko.json
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,7 @@
"transaction_details_fee_warning": "High Network Fees",
"transaction_details_swap": "Swap Funds",
"transaction_details_swap_network_fee": "Swap Network Fee",
"transaction_details_swap_order_cancel": "Swap Order Canceled",
"transaction_details_swap_order_cancel": "Swap Order Cancelled",
"transaction_details_swap_order_post": "Swap Order Opened",
"transaction_details_swap_order_fill": "Swap Order Filled",
"transaction_details_claim": "Claim Staked Funds",
Expand Down
2 changes: 1 addition & 1 deletion src/locales/strings/pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,7 @@
"transaction_details_fee_warning": "Altas taxas de rede",
"transaction_details_swap": "Swap Funds",
"transaction_details_swap_network_fee": "Swap Network Fee",
"transaction_details_swap_order_cancel": "Swap Order Canceled",
"transaction_details_swap_order_cancel": "Swap Order Cancelled",
"transaction_details_swap_order_post": "Swap Order Opened",
"transaction_details_swap_order_fill": "Swap Order Filled",
"transaction_details_claim": "Claim Staked Funds",
Expand Down
2 changes: 1 addition & 1 deletion src/locales/strings/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,7 @@
"transaction_details_fee_warning": "High Network Fees",
"transaction_details_swap": "Swap Funds",
"transaction_details_swap_network_fee": "Swap Network Fee",
"transaction_details_swap_order_cancel": "Swap Order Canceled",
"transaction_details_swap_order_cancel": "Swap Order Cancelled",
"transaction_details_swap_order_post": "Swap Order Opened",
"transaction_details_swap_order_fill": "Swap Order Filled",
"transaction_details_claim": "Claim Staked Funds",
Expand Down
2 changes: 1 addition & 1 deletion src/locales/strings/vi.json
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,7 @@
"transaction_details_fee_warning": "High Network Fees",
"transaction_details_swap": "Swap Funds",
"transaction_details_swap_network_fee": "Swap Network Fee",
"transaction_details_swap_order_cancel": "Swap Order Canceled",
"transaction_details_swap_order_cancel": "Swap Order Cancelled",
"transaction_details_swap_order_post": "Swap Order Opened",
"transaction_details_swap_order_fill": "Swap Order Filled",
"transaction_details_claim": "Claim Staked Funds",
Expand Down
2 changes: 1 addition & 1 deletion src/locales/strings/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,7 @@
"transaction_details_fee_warning": "High Network Fees",
"transaction_details_swap": "Swap Funds",
"transaction_details_swap_network_fee": "Swap Network Fee",
"transaction_details_swap_order_cancel": "Swap Order Canceled",
"transaction_details_swap_order_cancel": "Swap Order Cancelled",
"transaction_details_swap_order_post": "Swap Order Opened",
"transaction_details_swap_order_fill": "Swap Order Filled",
"transaction_details_claim": "Claim Staked Funds",
Expand Down
54 changes: 50 additions & 4 deletions src/plugins/gui/providers/banxaProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -560,9 +560,9 @@ export const banxaProvider: FiatProviderFactory = {
source: queryParams.source,
target: queryParams.target,
blockchain: banxaChain,
return_url_on_success: RETURN_URL_SUCCESS,
return_url_on_cancelled: RETURN_URL_CANCEL,
return_url_on_failure: RETURN_URL_FAIL
return_url_on_success: direction === 'buy' ? `https://deep.edge.app/fiatprovider/buy/banxa?status=success` : RETURN_URL_SUCCESS,
return_url_on_cancelled: direction === 'buy' ? `https://deep.edge.app/fiatprovider/buy/banxa?status=cancelled` : RETURN_URL_CANCEL,
return_url_on_failure: direction === 'buy' ? `https://deep.edge.app/fiatprovider/buy/banxa?status=failure` : RETURN_URL_FAIL
}
if (direction === 'buy') {
if (testnet && banxaChain === 'BTC') {
Expand Down Expand Up @@ -594,7 +594,53 @@ export const banxaProvider: FiatProviderFactory = {
let insideInterval = false

if (direction === 'buy') {
await showUi.openExternalWebView({ url: banxaQuote.data.order.checkout_url })
await showUi.openExternalWebView({
providerId,
url: banxaQuote.data.order.checkout_url,
deeplinkHandler: async link => {
if (link.direction !== 'buy') return

const orderResponse = await banxaFetch({ method: 'GET', url, hmacUser, path: `api/orders/${banxaQuote.data.order.id}`, apiKey })
const order = asBanxaOrderResponse(orderResponse)

switch (link.query.status) {
case 'success': {
await showUi.trackConversion('Buy_Success', {
conversionValues: {
conversionType: 'buy',
sourceFiatCurrencyCode: fiatCurrencyCode,
sourceFiatAmount: priceQuote.fiat_amount,
destAmount: new CryptoAmount({
currencyConfig: coreWallet.currencyConfig,
currencyCode: displayCurrencyCode,
exchangeAmount: order.data.order.coin_amount
}),
fiatProviderId: providerId,
orderId: banxaQuote.data.order.id
}
})
await showUi.exitScene()
break
}
case 'cancelled': {
console.log('Banxa WebView launch buy cancelled: ' + link.uri)
await showUi.showToast(lstrings.fiat_plugin_buy_cancelled, NOT_SUCCESS_TOAST_HIDE_MS)
await showUi.exitScene()
break
}
case 'failure': {
console.log('Banxa WebView launch buy failure: ' + link.uri)
await showUi.showToast(lstrings.fiat_plugin_buy_failed_try_again, NOT_SUCCESS_TOAST_HIDE_MS)
await showUi.exitScene()
break
}
default: {
await showUi.showToast(lstrings.fiat_plugin_buy_unknown_status, NOT_SUCCESS_TOAST_HIDE_MS)
await showUi.exitScene()
}
}
}
})
} else {
const { checkout_url: checkoutUrl, id } = banxaQuote.data.order
const banxaUrl = new URL(checkoutUrl)
Expand Down

0 comments on commit 785cb58

Please sign in to comment.