Skip to content

Commit b2cefc6

Browse files
fix(billing): use SquareCardForm in PaymentMethodManager
Replace the server-side CardForm (which calls /card/tokenize and gets 503 due to PCI compliance) with SquareCardForm which uses the Square Web Payments SDK for client-side card tokenization. The Square sourceId token is passed as _sourceToken on the PaymentMethod object so consuming apps can send it to commerce's payment-methods endpoint for real $1 pre-auth card verification. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 8e0201f commit b2cefc6

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

pkg/ui/src/billing/components/payment-manager.tsx

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { useAccount, useChainId } from 'wagmi'
66

77
import type { PaymentMethod, PaymentMethodType, CryptoNetwork } from '../types'
88
import { AnimatedCard } from './animated-card'
9+
import { SquareCardForm } from './square-card-form'
910

1011
export interface PaymentMethodManagerProps {
1112
paymentMethods?: PaymentMethod[]
@@ -212,9 +213,19 @@ export function PaymentMethodManager(props: PaymentMethodManagerProps) {
212213
</div>
213214

214215
{activeTab === 'card' && (
215-
<CardForm
216-
onAdd={addMethod}
217-
setError={setError}
216+
<SquareCardForm
217+
onToken={async (sourceId) => {
218+
const method: PaymentMethod = {
219+
id: `pm_${Math.random().toString(36).slice(2, 12)}`,
220+
type: 'card',
221+
is_default: false,
222+
isDefault: false,
223+
created_at: new Date().toISOString(),
224+
_sourceToken: sourceId,
225+
card: { brand: 'card', last4: '••••', exp_month: 0, exp_year: 0, funding: 'credit' },
226+
}
227+
await addMethod(method)
228+
}}
218229
/>
219230
)}
220231
{activeTab === 'crypto' && <CryptoForm onAdd={addMethod} setError={setError} />}

0 commit comments

Comments
 (0)