่ทณๅˆฐไธป่ฆๅ†…ๅฎน

Best way to fetch JSON from DID Space in Pages Kit

Twelve
ๆ”ฏๆŒ
did-spacesdocsfeature

Hello Team,

Iโ€™ve got a question about DID Space.

I want to use it to hold a priceTable.json file for my store, so my React component can pull live prices without redeploying.

๐Ÿ‘‰ Whatโ€™s the recommended way to fetch JSON from DID Space inside a Pages Kit component?

  • If the file is public, can I just fetch('https://{did}.abtwallet.io/files/priceTable.json') like a normal URL?
  • If itโ€™s private, whatโ€™s the best practice for authenticating a fetch request from the front end?
  • Do you suggest using raw JSON files in DID Space, or is there a better pattern (like DID docs) for storing this kind of structured catalog data?

Just trying to set this up clean and scalable so I can manage product catalogs directly from DID Space.

Thanks ๐Ÿ™

5 ๆกๅ›žๅค

JianChao13ไธชๆœˆๅ‰

ไฝ ๅฅฝ๏ผŒๆ˜ฏๆฏไธช็”จๆˆท้ƒฝ้œ€่ฆๆœ‰่‡ชๅทฑ็š„ priceTable.json๏ผŒ่ฟ˜ๆ˜ฏๆ•ดไธชๅบ”็”จ้ƒฝไฝฟ็”จๅŒไธ€ไธช priceTable.json ๅ‘ข? ไธบไป€ไนˆ่ฆๅœจ pages kit ็ป„ไปถไธญ่Žทๅ–ๅ‘ข?

Twelve12ไธชๆœˆๅ‰

Hi, I just wanted to confirm โ€” in the Pages Kit environment, can a component directly access a userโ€™s DID Space, or does it have to go through the server (Blocklet API) to read and write files likeย priceTable.json?

Connecting to DID space through the pages kit will be very helpful for some of the custom components im working on.

JianChao12ไธชๆœˆๅ‰(edited)

ๆ˜ฏ็š„๏ผŒ็›ฎๅ‰ๆ— ๆณ•ๆ”ฏๆŒๅœจ pages kit ็ป„ไปถไธŠ็›ดๆŽฅ่ฎฟ้—ฎ did spacesใ€‚ๅช่ƒฝ้€š่ฟ‡ไฝ ็š„ๅบ”็”จ็š„ๅŽ็ซฏๆŽฅๅ…ฅ @blocklet/did-space-js ๅœจๅŽ็ซฏ่ฏปๅ†™ priceTable.json๏ผŒ็„ถๅŽๅ†ไฝฟ็”จ pages kit ็ป„ไปถ่ฏทๆฑ‚ไฝ ็š„ๅบ”็”จ็š„ api ๆฅๅฎŒๆˆใ€‚see: https://www.arcblock.io/docs/did-space-js/en

Twelve12ไธชๆœˆๅ‰

Hello Jian and team,

Weโ€™ve built a complete invoicing system in Pages Kit that can dynamically calculate line items, tax, discounts, and tips. Printing and invoice management work perfectly โ€” the only limitation now is that Payment Kit only supports static price IDs for generating payment links.

Weโ€™ve noticed that Payment Kitโ€™s cart checkout already creates a temporary checkout session when multiple hard-priced items are sent. Thatโ€™s very close to what we need โ€” the missing piece is allowing that same flow to accept dynamic modifiers like tax_rate, discount, and tip.

Hereโ€™s what an ideal API call might look like directly from Pages Kit:

javascriptCopy
const paymentLink = await arcblock.payment.createCheckout({
  did: user.did,
  currency: 'usd',
  items: [
    { name: 'Mixing Session', amount: 20000 },
    { name: 'Mastering', amount: 10000 }
  ],
  tax_rate: 0.07,     // 7% tax
  discount: 0.10,     // 10% off
  tip: 1500           // $15 tip
});
console.log(paymentLink.url);

In this flow:

  1. Pages Kit sends selected items + optional modifiers.
  2. Payment Kit creates a temporary product/price session with these values.
  3. It returns a ready-to-use checkout_url tied to that DID session.

This would allow any Pages Kit app to generate dynamic payment links โ€” fully automated, secure, and DID-authenticated โ€” without needing pre-created price IDs or backend API keys.

Since cart checkouts already create ephemeral sessions, this enhancement feels like a natural extension of the current system. It would unlock flexible, real-world billing for all creators and developers using ArcBlock.

Is something like this possible and if so on any part of the roadmap?

Thanks for all your building!

JianChao12ไธชๆœˆๅ‰

tax_rate/discount/tip ้œ€่ฆๅŠจๆ€่ฎพ็ฝฎ๏ผŒๆ˜ฏ้’ˆๅฏนๅ•ไธช็”จๆˆท่‡ชๅฎšไน‰่ฟ˜ๆ˜ฏๅคšไธช็”จๆˆท่‡ชๅฎšไน‰?

ๅ›žๅค