Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 10 additions & 21 deletions packages/agentcommercekit/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,10 @@ try {
#### Type Guards for Credential Validation

```ts
import { isControllerClaim, isControllerCredential } from "agentcommercekit"
import { isControllerCredential } from "agentcommercekit"

// Check if a credential is specifically a controller credential
isControllerCredential(credential)

// Check if a credential subject has the controller claim structure
isControllerClaim(credential.credentialSubject)
```

#### A2A Methods
Expand All @@ -115,7 +112,7 @@ import {
createDidWebUri,
createJwtSigner,
curveToJwtAlgorithm,
generateKeypair
generateKeypair,
} from "agentcommercekit"

// Create a payment request
Expand All @@ -129,9 +126,9 @@ const paymentRequest = {
decimals: 6,
currency: "USDC",
recipient: "did:web:payment.example.com",
paymentService: "https://pay.example.com"
}
]
paymentService: "https://pay.example.com",
},
],
}

const keypair = await generateKeypair("secp256k1")
Expand All @@ -140,14 +137,13 @@ const keypair = await generateKeypair("secp256k1")
const paymentRequestBody = await createSignedPaymentRequest(paymentRequest, {
issuer: createDidWebUri("https://server.example.com"),
signer: createJwtSigner(keypair),
algorithm: curveToJwtAlgorithm(keypair.curve)
algorithm: curveToJwtAlgorithm(keypair.curve),
})

// Create a 402 Payment Required response
// Create a 402 Payment Required response
const response = new Response(JSON.stringify(paymentRequestBody, {
const response = new Response(JSON.stringify(paymentRequestBody), {
status: 402,
contentType: "application/json"
headers: { "Content-Type": "application/json" },
})
```

Expand All @@ -171,27 +167,20 @@ import { getDidResolver, verifyPaymentReceipt } from "agentcommercekit"

const verified = await verifyPaymentReceipt(receipt, {
resolver: getDidResolver(),
trustedIssuers: ["did:web:merchant.example.com"],
trustedReceiptIssuers: ["did:web:receipt-service.example.com"],
})
```

#### Type Guards for Validation

```ts
import {
isPaymentReceiptClaim,
isPaymentReceiptCredential,
isPaymentRequest,
} from "agentcommercekit"
import { isPaymentReceiptCredential, isPaymentRequest } from "agentcommercekit"

// Check if a value is a valid payment request
isPaymentRequest(unknownObject)

// Check if a credential is specifically a payment receipt credential
isPaymentReceiptCredential(credential)

// Check if a credential subject has the payment receipt claim structure
isPaymentReceiptClaim(credential.credentialSubject)
```

## Agent Commerce Kit Version
Expand Down
Loading