Skip to content

Commit 8979f8f

Browse files
authored
chore: add temporarly disabled fiat payments warning (#75)
1 parent 4c87762 commit 8979f8f

2 files changed

Lines changed: 97 additions & 3 deletions

File tree

src/components/tables/InstancesTable.vue

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2119,6 +2119,11 @@ export default defineComponent({
21192119
this.planDialog.fiatOnly = useFiat
21202120
}
21212121
2122+
if (this.isFiatPaymentSelected()) {
2123+
this.notifyFiatPaymentsDisabled()
2124+
return
2125+
}
2126+
21222127
const selectedTag = this.normalizeSelectedInstanceTypeTag(
21232128
this.planDialog.selectedTag
21242129
)
@@ -2168,6 +2173,18 @@ export default defineComponent({
21682173
}
21692174
await this.submitOneTimePlan(instanceId)
21702175
},
2176+
isFiatPaymentSelected() {
2177+
return this.planDialog.fiatOnly || this.planDialog.subscription
2178+
},
2179+
notifyFiatPaymentsDisabled() {
2180+
this.q.notify({
2181+
message: 'Fiat payments are temporarily unavailable.',
2182+
caption: 'Please choose Bitcoin payment for now.',
2183+
color: 'warning',
2184+
textColor: 'dark',
2185+
icon: 'warning'
2186+
})
2187+
},
21712188
async submitSubscriptionPlan(instanceId) {
21722189
try {
21732190
this.planDialog.inProgress = true

test/pricing.spec.js

Lines changed: 80 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ const createPricingPayload = premiumOverrides => ({
5656
}
5757
})
5858

59+
const chooseBitcoinPayment = async page => {
60+
await page.locator('.q-radio').filter({hasText: 'Bitcoin'}).click()
61+
}
62+
5963
test('renders pricing plans from the dev pricing API', async ({page}) => {
6064
await page.addInitScript(() => {
6165
window.localStorage.setItem('apiEnv', 'dev')
@@ -225,14 +229,85 @@ test('shows every instance type returned by the API in the create instance fundi
225229
expect(optionLabels).toEqual(expectedLabels)
226230
await page.keyboard.press('Escape')
227231

228-
await page.getByRole('button', {name: /Pay with USD|Payment/}).click()
232+
await chooseBitcoinPayment(page)
233+
await page.getByRole('button', {name: /Pay with bitcoin/}).click()
229234
await expect.poll(() => createInstanceRequestBody).toMatchObject({
230235
instance_type: 'lnbits-spark',
231236
payment_plan_tier: 'premium',
232237
payment_plan_interval: 'monthly'
233238
})
234239
})
235240

241+
test('warns instead of checking out when fiat payment is selected', async ({page}) => {
242+
let createInstanceRequestBody = null
243+
244+
await page.addInitScript(() => {
245+
window.localStorage.setItem('apiEnv', 'dev')
246+
window.localStorage.setItem('email', 'pricing-test@example.com')
247+
})
248+
249+
await page.route('https://api.dev.lnbits.com/pricing', route =>
250+
route.fulfill({
251+
status: 200,
252+
contentType: 'application/json',
253+
body: JSON.stringify(pricingPayload)
254+
})
255+
)
256+
await page.route('https://api.dev.lnbits.com/instance', route =>
257+
route.request().method() === 'POST'
258+
? (() => {
259+
createInstanceRequestBody = route.request().postDataJSON()
260+
return route.fulfill({
261+
status: 200,
262+
contentType: 'application/json',
263+
body: JSON.stringify({
264+
id: 'instance-1',
265+
domain: 'instance-1.example.com',
266+
is_enabled: true,
267+
is_active: true,
268+
timestamp: 1700000000,
269+
timestamp_start: 1700000000,
270+
timestamp_stop: 1700086400,
271+
installtoken: 'install-token',
272+
lnurl: ''
273+
})
274+
})
275+
})()
276+
: route.fulfill({
277+
status: 200,
278+
contentType: 'application/json',
279+
body: JSON.stringify([])
280+
})
281+
)
282+
await page.route('https://api.dev.lnbits.com/', route =>
283+
route.fulfill({
284+
status: 200,
285+
contentType: 'application/json',
286+
body: JSON.stringify({timestamp: Math.floor(Date.now() / 1000)})
287+
})
288+
)
289+
await page.route('https://api.dev.lnbits.com/instance/types', route =>
290+
route.fulfill({
291+
status: 200,
292+
contentType: 'application/json',
293+
body: JSON.stringify(instanceTypesPayload)
294+
})
295+
)
296+
297+
await page.goto('/instances?tier=premium&billing=monthly&funding=spark_l2')
298+
await page
299+
.locator('#lnbits-chat-embed-iframe')
300+
.evaluateAll(nodes => nodes.forEach(node => node.remove()))
301+
302+
await page.getByRole('button', {name: /Pay with USD|Payment/}).click()
303+
304+
await expect(
305+
page.getByText('Fiat payments are temporarily unavailable.')
306+
).toBeVisible()
307+
await page.waitForTimeout(100)
308+
expect(createInstanceRequestBody).toBeNull()
309+
})
310+
236311
test('prompts for a custom subdomain when the selected payment plan allows it', async ({page}) => {
237312
let createInstanceRequestBody = null
238313

@@ -315,7 +390,8 @@ test('prompts for a custom subdomain when the selected payment plan allows it',
315390
await expect(domainInput).toHaveAttribute('aria-label', 'Subdomain')
316391
await expect(page.locator('.q-field__suffix')).toContainText('.lnbits.com')
317392
await domainInput.fill('my-team')
318-
await page.getByRole('button', {name: /Pay with USD|Payment/}).click()
393+
await chooseBitcoinPayment(page)
394+
await page.getByRole('button', {name: /Pay with bitcoin/}).click()
319395

320396
await expect.poll(() => createInstanceRequestBody).toMatchObject({
321397
instance_type: 'lnbits-spark',
@@ -406,7 +482,8 @@ test('prompts for a custom domain when the selected payment plan allows it', asy
406482
await expect(domainInput).toBeVisible()
407483
await expect(domainInput).toHaveAttribute('aria-label', 'Domain or subdomain')
408484
await domainInput.fill('pay.example.com')
409-
await page.getByRole('button', {name: /Pay with USD|Payment/}).click()
485+
await chooseBitcoinPayment(page)
486+
await page.getByRole('button', {name: /Pay with bitcoin/}).click()
410487

411488
await expect.poll(() => createInstanceRequestBody).toMatchObject({
412489
instance_type: 'lnbits-spark',

0 commit comments

Comments
 (0)