Skip to content

Add initial Bitrefill widget to staging #3343

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: staging-bitrefill
Choose a base branch
from

Conversation

sutterseba
Copy link
Collaborator

@sutterseba sutterseba commented May 12, 2025

Adds an initial proof of concept integration of the Bitrefill widget.

Still missing:

  • Disclaimers (currently set to BTC direct instead)
  • Some smaller UI elements

Copy link
Collaborator

@thisconnect thisconnect left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice LGTM, added some small comments

also @Beerosagos please review if you have a moment.

@@ -21,7 +21,7 @@ export const getExchangeRegionCodes = (): Promise<string[]> => {
return apiGet('exchange/region-codes');
};

export type TPaymentMethod = 'card' | 'bank-transfer' | 'bancontact' | 'sofort';
export type TPaymentMethod = 'card' | 'bank-transfer' | 'bancontact' | 'sofort' | 'spend';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: 'spend' looks a bit wrong here, but I haven't yet checked why it is needed…

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah it's a bit ugly. I'm basically abusing the payment method field to pass a custom message (which depends on the provider). Strictly speaking "spend" is the payment method here, i.e. the wallet itself pays.

import { A } from '../anchor/anchor';
import style from './terms.module.css';
import { isBitcoinOnly } from '@/routes/account/utils';
import { localeMapping } from '@/routes/exchange/bitrefill';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bitrefill-terms.tsx imports from bitrefill.tsx and bitrefill.tsx imports bitrefill-term.tsx.

Altough it is ok to have circular imports (dependencies) in ES6 modules, we try to not have them

Please move the localeMapping to it's own module (bitrefill-locales.ts ?) so that you can import into both bitrefill.tsx and bitrefill-terms.tsx

} catch (e) {
return null;
}
};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: we have same (similar?) function in btcdirect, this could be shared in a new `utils/url.ts or similar.

hl: i18n.resolvedLanguage ? localeMapping[i18n.resolvedLanguage] : 'en',
paymentMethods: account.coinCode ? coinMapping[account.coinCode] : 'bitcoin',
refundAddress: bitrefillInfo.address,
// Option to keep pending payment information longer in session, defaults to 'false'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you add a link to their documentation somewhere (in this file or in commit message)?

})}</h2>}/>
) : (
<Header title={<h2>{title}</h2>}/>
)}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: an alternative could be to use 1 <Header element and move the condition into title attribute.

@sutterseba sutterseba force-pushed the staging-bitrefill branch 2 times, most recently from a90ae85 to 4440b2a Compare May 14, 2025 15:38
Integrates Bitrefill widget into the backend and adds a new "spend"
action, as Bitrefill is a new type of exchange next to buy and sell.
Integrates Bitrefill in the frontend. On the previous "Buy & sell"
menu, there is now a third selectable pill "Spend", opening the
available exchange options (Bitrefill in this case).

The widget is requested from bitboxapp.shiftcrypto.io using config
parameters from the user/app, handled in the "request-configuration"
event. Note that the iframe will still have its source set to
"https://embed.bitrefill.com".

When the user clicks "Pay" inside the Bitrefill widget to purchase
a gift card, the returned address and amount is used to propose a
transaction on the connected BitBox.

The PaymentMethod component is adjusted to allow custom messages
to be shown in the exchange overview, as these will differ in the
"Spend" section between providers.

Disclaimer and info texts are added technically, but the actual
text is still missing in this commit.

Bitrefill developer documentation:
https://www.bitrefill.com/playground/documentation/url-params
@sutterseba sutterseba force-pushed the staging-bitrefill branch from 57d1a0b to b26e651 Compare May 14, 2025 17:20
@sutterseba
Copy link
Collaborator Author

@thisconnect addressed comments and also changed to the same tx note format now (as in #3351)

Copy link
Collaborator

@thisconnect thisconnect left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

very nice, initial Bitrefill pr LGTM

Lets get this merged to staging-bitrefill soon, you've already over-delivered and it looks like almost done and more than just a POC :)

ping @Beerosagos ptal

if (result.success) {
const txNote = t('generic.paymentRequestNote', {
name: 'Bitrefill',
invoiceId,
Copy link
Collaborator

@thisconnect thisconnect May 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
invoiceId,
orderId: invoiceId,

The placeholder name is orderId

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

Copy link
Collaborator

@thisconnect thisconnect left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM but one small issue: orderId: invoiceId

Uses the same "Bitrefill payment XYZ" format for transaction notes
of Bitrefill spends, which other integrations use as well.
@sutterseba sutterseba force-pushed the staging-bitrefill branch from c1fe7f1 to 0dd92bc Compare May 15, 2025 11:41
@Beerosagos
Copy link
Collaborator

ping @Beerosagos ptal

I already saw the first mention 😂 I'll have a look asap

@thisconnect
Copy link
Collaborator

I already saw the first mention 😂 I'll have a look asap

I didn't want to rush you, but wanted to hand it over to you. 😇

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants