Skip to content

Commit

Permalink
Add buy tracking for paybis
Browse files Browse the repository at this point in the history
  • Loading branch information
paullinator committed Sep 30, 2024
1 parent c770023 commit af0ef8b
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@
- added: Re-enable Piratechain on iOS
- added: Battery Saver warning message for Android
- added: Buy conversion tracking for Moonpay
- added: Buy conversion tracking for Paybis
- added: Support for return.edge.app deeplinks
- added: Error tracking for failure to report conversions to referral server
- changed: Remove whitespaces from custom token contract address input
- changed: Use unique ENV configs for thorchain and thorchainda swap plugins
- fixed: Correctly tag `tokenApproval` `actionType` in `getTxActionDisplayInfo`
- fixed: URI encoding in Paybis return URIs
- fixed: AddressTile2 touchable area states
- fixed: Cases where it was possible to create duplicate custom tokens
- fixed: Clear previous swap errors when new amounts are entered or swap assets are changed in `SwapCreateScene`
Expand Down
1 change: 1 addition & 0 deletions src/locales/en_US.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1450,6 +1450,7 @@ const strings = {
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_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
1 change: 1 addition & 0 deletions src/locales/strings/enUS.json
Original file line number Diff line number Diff line change
Expand Up @@ -1281,6 +1281,7 @@
"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_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
44 changes: 43 additions & 1 deletion src/plugins/gui/providers/paybisProvider.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { eq, lte, mul, round } from 'biggystring'
import { asArray, asBoolean, asDate, asMaybe, asObject, asOptional, asString, asValue } from 'cleaners'
import { EdgeAssetAction, EdgeFetchOptions, EdgeSpendInfo, EdgeTxActionFiat, JsonObject } from 'edge-core-js'
import { sprintf } from 'sprintf-js'
import URL from 'url-parse'

import { SendScene2Params } from '../../../components/scenes/SendScene2'
Expand Down Expand Up @@ -584,8 +585,49 @@ export const paybisProvider: FiatProviderFactory = {
const promoCodeParam = promoCode != null ? `&promoCode=${promoCode}` : ''

if (direction === 'buy') {
const successReturnURL = encodeURIComponent('https://return.edge.app/fiatprovider/buy/paybis?transactionStatus=success')
const failureReturnURL = encodeURIComponent('https://return.edge.app/fiatprovider/buy/paybis?transactionStatus=fail')
await showUi.openExternalWebView({
url: `${widgetUrl}?requestId=${requestId}${ott}${promoCodeParam}`
url: `${widgetUrl}?requestId=${requestId}${ott}${promoCodeParam}&successReturnURL=${successReturnURL}&failureReturnURL=${failureReturnURL}`,
providerId,
deeplinkHandler: async link => {
const { query, uri } = link
console.log('Paybis WebView launch buy success: ' + uri)
const { transactionStatus } = query
if (transactionStatus === 'success') {
await showUi.trackConversion('Buy_Success', {
conversionValues: {
conversionType: 'buy',
sourceFiatCurrencyCode: fiatCurrencyCode,
sourceFiatAmount: fiatAmount,
destAmount: new CryptoAmount({
currencyConfig: coreWallet.currencyConfig,
currencyCode: displayCurrencyCode,
exchangeAmount: cryptoAmount
}),
fiatProviderId: providerId,
orderId: requestId
}
})
const message =
sprintf(lstrings.fiat_plugin_buy_complete_message_s, cryptoAmount, displayCurrencyCode, fiatAmount, fiat, '1') +
'\n\n' +
sprintf(lstrings.fiat_plugin_buy_complete_message_2_hour_s, '1') +
'\n\n' +
lstrings.fiat_plugin_sell_complete_message_3
await showUi.buttonModal({
buttons: {
ok: { label: lstrings.string_ok, type: 'primary' }
},
title: lstrings.fiat_plugin_buy_complete_title,
message
})
} else if (transactionStatus === 'failure') {
await showUi.showToast(lstrings.fiat_plugin_buy_failed_try_again, NOT_SUCCESS_TOAST_HIDE_MS)
} else {
await showUi.showError(new Error(`Paybis: Invalid transactionStatus "${transactionStatus}".`))
}
}
})
return
}
Expand Down

0 comments on commit af0ef8b

Please sign in to comment.