← 返回
未分类 Key 中文

Shopify Link Checkout

Autonomous Shopify purchasing using Stripe Link for payment and Playwright for browser checkout. Search products across all Shopify merchants, generate one-t...
使用 Stripe Link 支付并借助Playwright 完成浏览器结账,实现全自动 Shopify 采购;在所有 Shopify 商家搜索商品并生成一键购买流程。
sdliriano sdliriano 来源
未分类 clawhub v1.0.0 1 版本 100000 Key: 需要
★ 0
Stars
📥 294
下载
💾 0
安装
1
版本
#latest

概述

Shopify + Link Autonomous Checkout

Buy products from any Shopify store using Stripe Link for payment and Playwright for browser checkout.

Prerequisites

Stripe Link CLI

npm install -g @stripe/link-cli
link-cli auth login --client-name "YourAgent" --format json

User approves at the returned verification_url. Backup credentials from ~/.config/link-cli-nodejs/config.json.

Shopify Catalog API

Get credentials at dev.shopify.com/dashboard → Catalogs → Get API key.

Store CLIENT_ID and CLIENT_SECRET in your env.

Playwright + Chromium

npm install playwright
npx playwright install chromium

If missing system libs (headless server), download Debian packages manually and set LD_LIBRARY_PATH. See references/chromium-deps.md.

Workflow

Step 1: Find the Product

Option A — Catalog API (search across all Shopify merchants):

# Get auth token (60min TTL)
TOKEN=$(curl -s -X POST https://api.shopify.com/auth/access_token \
  -H 'Content-Type: application/json' \
  -d '{"client_id":"'$CLIENT_ID'","client_secret":"'$CLIENT_SECRET'","grant_type":"client_credentials"}' \
  | jq -r .access_token)

# Search
curl -s -X POST https://catalog.shopify.com/api/ucp/mcp \
  -H "Authorization: Bearer $TOKEN" \
  -H 'Content-Type: application/json' \
  -d '{
    "jsonrpc":"2.0","method":"tools/call","id":1,
    "params":{"name":"search_catalog","arguments":{
      "meta":{"ucp-agent":{"profile":"https://shopify.dev/ucp/agent-profiles/examples/2026-04-08/valid-with-capabilities.json"}},
      "catalog":{"query":"YOUR SEARCH QUERY","filters":{"ships_to":{"country":"US"},"available":true}}
    }}
  }'

Response includes variants[].id, variants[].seller.domain, variants[].price, and variants[].checkout_url.

Option B — Direct store lookup (known store):

GET https://{store-domain}/products/{handle}.json

Returns variant IDs and prices.

Step 2: Create Link Spend Request

link-cli spend-request create \
  --payment-method-id "<PAYMENT_METHOD_ID>" \
  --amount <AMOUNT_IN_CENTS> \
  --context "<DESCRIPTION_OF_PURCHASE>" \
  --merchant-name "<STORE_NAME>" \
  --merchant-url "<STORE_URL>" \
  --request-approval \
  --format json
  • Amount should cover product + tax + shipping (estimate generously)
  • Context must be 100+ chars describing the purchase (user reads this when approving)
  • Send the returned approval_url to the user

List payment methods: link-cli payment-methods list --format json

Step 3: User Approves

Poll for approval:

link-cli spend-request retrieve <ID> --interval 2 --max-attempts 150 --format json

Step 4: Get One-Time Card

link-cli spend-request retrieve <ID> --include card --format json

Returns: card.number, card.exp_month, card.exp_year, card.cvc, card.billing_address.

Step 5: Run Checkout

export LD_LIBRARY_PATH="<path-to-chromium-deps>"  # if needed
node scripts/shopify-checkout.mjs <store-domain> <variant-id> <card-number> <MM/YY> <cvc> \
  --email <email> --first <name> --last <name> \
  --address "<street>" --apt "<unit>" --city "<city>" --state <ST> --zip <zip> \
  --phone <phone>

See scripts/shopify-checkout.mjs for the full automation script.

Key Technical Details

Cart Permalink Bypass

Always use https://{domain}/cart/{variantId}:1 to enter checkout. This bypasses Cloudflare bot detection that blocks direct /checkout navigation.

Checkout Types

Shopify has two checkout layouts:

  • Single-page: Email, address, shipping, payment all visible. Common on newer stores.
  • Multi-step: Information → Shipping → Payment. Must click "Continue" between steps.

Detect by checking for button:has-text("Continue to shipping") on page load.

Address Entry

Use pressSequentially() with the full address including city to trigger Shopify's autocomplete, then click the [role="option"] suggestion. This properly validates the address. Plain fill() may not trigger validation events.

Phone Numbers

Some stores require phone. Always use pressSequentially(), never fill(). Never use fake numbers (555-xxxx) — stores validate them. Then Tab to blur the field.

Card PCI Iframes

Shopify checkout uses isolated PCI-compliant iframes for card entry:

  • number-ltr#number (card number)
  • expiry-ltr#expiry (MM/YY format)
  • verification_value-ltr#verification_value (CVC)
  • name-ltr#name (cardholder name)

Access via page.frames().find(f => f.url().includes('number-ltr')).

Modal Popups

Some stores show Shop Pay / login modals on checkout load. Dismiss with:

await page.keyboard.press('Escape');
await page.evaluate(() => {
  document.querySelectorAll('[data-type="modal"]').forEach(el => el.remove());
});

The Click IS the Purchase

Once "Pay now" is clicked, the order is placed server-side immediately. The browser redirect to /thank_you may lag or fail in headless mode. Don't treat missing confirmation page as failure — check email instead.

Error Handling

ErrorCauseFix
-------------------
Cloudflare "Just a moment..."Bot detectionUse cart permalink, not /checkout
"Enter a phone number"Required field or fake numberUse real phone with pressSequentially
"Issue processing payment"Card declined or expiredCreate fresh Link spend request
"Checkout system error"Shopify infra issue or rate limitWait and retry
Modal intercepts clicksShop Pay popupDismiss with Escape + remove via JS
Card frames not foundMulti-step checkout, not at payment step yetNavigate through steps first

References

  • scripts/shopify-checkout.mjs — Full checkout automation script
  • references/chromium-deps.md — Installing Chromium on headless servers without root
  • Stripe Link for Agents — Link CLI docs
  • Shopify Agentic Commerce — Catalog + Cart + Checkout MCP
  • Link skill.md — Official Link CLI skill reference

版本历史

共 1 个版本

  • v1.0.0 当前
    2026-05-08 02:26 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

dev-programming

Github

steipete
使用 `gh` CLI 与 GitHub 交互,通过 `gh issue`、`gh pr`、`gh run` 和 `gh api` 管理议题、PR、CI 运行及高级查询。
★ 677 📥 325,908
ai-agent

Self-Improving + Proactive Agent

ivangdavila
自我反思+自我批评+自我学习+自组织记忆。智能体评估自身工作、发现错误并持续改进。
★ 1,385 📥 321,017
ai-agent

self-improving agent

pskoett
捕获经验教训、错误及修正内容,以实现持续改进。适用于以下场景:(1)命令或操作意外失败;(2)用户纠正Claude(如“不,那不对……”“实际上……”);(3)用户请求的功能不存在;(4)外部API或工具出现故障;(5)Claude发现自身
★ 4,086 📥 814,818