Skip to content

Commit 647f91e

Browse files
authored
Add v1.1.0 commercial TypeScript examples (#20)
1 parent 35579f6 commit 647f91e

File tree

11 files changed

+1437
-1
lines changed

11 files changed

+1437
-1
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ protocol-commercial/
120120
│ └── verify.receipt.schema.json
121121
├── examples/
122122
│ ├── v1.0.0/ # published legacy line
123-
│ └── v1.1.0/commercial/<verb>/{valid,invalid}/
123+
│ └── v1.1.0/commercial/<verb>/{valid,invalid,ts}/
124124
├── manifest.json
125125
├── checksums.txt
126126
└── scripts/
Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
// examples/v1.1.0/commercial/authorize/ts/authorize.receipt.examples.ts
2+
3+
export interface Money {
4+
amount: string;
5+
currency: string;
6+
decimals?: number;
7+
includes?: "subtotal" | "tax" | "shipping" | "fees" | "discount" | "total";
8+
}
9+
10+
export interface PaymentProof {
11+
scheme: "x402";
12+
proof_type: "payment-session" | "payment-authorization" | "payment-proof";
13+
proof_ref: string;
14+
uri?: string;
15+
}
16+
17+
export interface ActorIdentity {
18+
role: "payer" | "payee" | "merchant" | "provider" | "carrier" | "verifier";
19+
id: string;
20+
kind?: "agent" | "organization" | "wallet" | "account" | "service" | "human";
21+
display_name?: string;
22+
uri?: string;
23+
}
24+
25+
export interface Reference {
26+
type:
27+
| "order"
28+
| "invoice"
29+
| "authorization"
30+
| "checkout"
31+
| "purchase"
32+
| "fulfillment"
33+
| "shipment"
34+
| "payment"
35+
| "settlement"
36+
| "receipt"
37+
| "payment_requirement"
38+
| "payment_session"
39+
| "payment_proof"
40+
| "agent_card";
41+
id: string;
42+
uri?: string;
43+
}
44+
45+
export interface AuthorizeReceipt {
46+
protocol: "commercial";
47+
version: "1.1.0";
48+
verb: "authorize";
49+
receipt_id: string;
50+
issued_at: string;
51+
request_id: string;
52+
status: "approved" | "denied" | "expired";
53+
payer: ActorIdentity & { role: "payer" };
54+
payee: ActorIdentity & { role: "payee" };
55+
amount: Money;
56+
authorization_id?: string;
57+
merchant?: ActorIdentity & { role: "merchant" };
58+
approved_until?: string;
59+
payment_requirement_ref?: Reference & { type: "payment_requirement" };
60+
order_ref?: Reference;
61+
invoice_ref?: Reference;
62+
payment_proof?: PaymentProof;
63+
reason?: string;
64+
}
65+
66+
export const validAuthorizeReceiptExample: AuthorizeReceipt = {
67+
protocol: "commercial",
68+
version: "1.1.0",
69+
verb: "authorize",
70+
receipt_id: "authrcpt-001",
71+
issued_at: "2026-03-19T10:00:05Z",
72+
request_id: "authreq-001",
73+
status: "approved",
74+
authorization_id: "auth-001",
75+
payer: {
76+
role: "payer",
77+
id: "buyer-001",
78+
kind: "account"
79+
},
80+
payee: {
81+
role: "payee",
82+
id: "merchant-settlement",
83+
kind: "wallet"
84+
},
85+
merchant: {
86+
role: "merchant",
87+
id: "merchant.example",
88+
kind: "organization"
89+
},
90+
amount: {
91+
amount: "49.99",
92+
currency: "USDC",
93+
decimals: 2
94+
},
95+
approved_until: "2026-03-20T10:00:00Z",
96+
payment_requirement_ref: {
97+
type: "payment_requirement",
98+
id: "x402-auth-001"
99+
},
100+
order_ref: {
101+
type: "order",
102+
id: "ord-1001"
103+
},
104+
invoice_ref: {
105+
type: "invoice",
106+
id: "inv-1001"
107+
},
108+
payment_proof: {
109+
scheme: "x402",
110+
proof_type: "payment-authorization",
111+
proof_ref: "proof-auth-001",
112+
uri: "https://merchant.example/x402/proofs/proof-auth-001"
113+
}
114+
};
115+
116+
export const invalidAuthorizeReceiptExample: any = {
117+
protocol: "commercial",
118+
version: "1.1.0",
119+
verb: "authorize",
120+
receipt_id: "authrcpt-invalid-001",
121+
issued_at: "not-a-date",
122+
request_id: "authreq-001",
123+
status: "approved",
124+
payer: {
125+
role: "payer",
126+
id: "buyer-001"
127+
},
128+
payee: {
129+
role: "payee",
130+
id: "merchant-settlement"
131+
},
132+
amount: {
133+
amount: "49.99",
134+
currency: "USDC"
135+
},
136+
payment_proof: {
137+
scheme: "x402",
138+
proof_type: "authorization",
139+
proof_ref: "proof-auth-001"
140+
}
141+
};
Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
// examples/v1.1.0/commercial/authorize/ts/authorize.request.examples.ts
2+
3+
export interface Money {
4+
amount: string;
5+
currency: string;
6+
decimals?: number;
7+
includes?: "subtotal" | "tax" | "shipping" | "fees" | "discount" | "total";
8+
}
9+
10+
export interface PaymentRequirement {
11+
scheme: "x402";
12+
resource: string;
13+
network?: string;
14+
max_amount: Money;
15+
payment_request_id?: string;
16+
}
17+
18+
export interface AuthorizationScope {
19+
capture_mode: "manual" | "automatic";
20+
valid_until?: string;
21+
reusable?: boolean;
22+
}
23+
24+
export interface ActorIdentity {
25+
role: "payer" | "payee" | "merchant" | "provider" | "carrier" | "verifier";
26+
id: string;
27+
kind?: "agent" | "organization" | "wallet" | "account" | "service" | "human";
28+
display_name?: string;
29+
uri?: string;
30+
}
31+
32+
export interface Reference {
33+
type:
34+
| "order"
35+
| "invoice"
36+
| "authorization"
37+
| "checkout"
38+
| "purchase"
39+
| "fulfillment"
40+
| "shipment"
41+
| "payment"
42+
| "settlement"
43+
| "receipt"
44+
| "payment_requirement"
45+
| "payment_session"
46+
| "payment_proof"
47+
| "agent_card";
48+
id: string;
49+
uri?: string;
50+
}
51+
52+
export interface AuthorizeRequest {
53+
protocol: "commercial";
54+
version: "1.1.0";
55+
verb: "authorize";
56+
request_id: string;
57+
requested_at: string;
58+
payer: ActorIdentity & { role: "payer" };
59+
payee: ActorIdentity & { role: "payee" };
60+
merchant: ActorIdentity & { role: "merchant" };
61+
amount: Money;
62+
authorization_scope: AuthorizationScope;
63+
payment_requirement?: PaymentRequirement;
64+
order_ref?: Reference;
65+
invoice_ref?: Reference;
66+
merchant_reference?: string;
67+
idempotency_key?: string;
68+
}
69+
70+
export const validAuthorizeRequestExample: AuthorizeRequest = {
71+
protocol: "commercial",
72+
version: "1.1.0",
73+
verb: "authorize",
74+
request_id: "authreq-001",
75+
requested_at: "2026-03-19T10:00:00Z",
76+
payer: {
77+
role: "payer",
78+
id: "buyer-001",
79+
kind: "account"
80+
},
81+
payee: {
82+
role: "payee",
83+
id: "merchant-settlement",
84+
kind: "wallet"
85+
},
86+
merchant: {
87+
role: "merchant",
88+
id: "merchant.example",
89+
kind: "organization"
90+
},
91+
amount: {
92+
amount: "49.99",
93+
currency: "USDC",
94+
decimals: 2
95+
},
96+
authorization_scope: {
97+
capture_mode: "manual",
98+
valid_until: "2026-03-20T10:00:00Z",
99+
reusable: false
100+
},
101+
payment_requirement: {
102+
scheme: "x402",
103+
resource: "https://merchant.example/x402/authorize/authreq-001",
104+
network: "eip155:8453",
105+
max_amount: {
106+
amount: "49.99",
107+
currency: "USDC",
108+
decimals: 2
109+
},
110+
payment_request_id: "x402-auth-001"
111+
},
112+
order_ref: {
113+
type: "order",
114+
id: "ord-1001"
115+
},
116+
invoice_ref: {
117+
type: "invoice",
118+
id: "inv-1001"
119+
},
120+
merchant_reference: "web-checkout-1001",
121+
idempotency_key: "authorize-1001"
122+
};
123+
124+
export const invalidAuthorizeRequestExample: any = {
125+
protocol: "commercial",
126+
version: "1.1.0",
127+
verb: "authorize",
128+
request_id: "authreq-invalid-001",
129+
requested_at: "2026-03-19T10:00:00Z",
130+
payer: {
131+
role: "payer",
132+
id: "buyer-001"
133+
},
134+
payee: {
135+
role: "merchant",
136+
id: "merchant-settlement"
137+
},
138+
merchant: {
139+
role: "merchant",
140+
id: "merchant.example"
141+
},
142+
amount: {
143+
amount: 49.99,
144+
currency: "USDC"
145+
},
146+
authorization_scope: {
147+
capture_mode: "delayed"
148+
}
149+
};

0 commit comments

Comments
 (0)