ap2_mandate_verifier 1.0.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.ja.md +44 -20
- data/README.md +50 -24
- data/SECURITY.md +3 -3
- data/docs/PAYMENT.md +70 -0
- data/docs/POST_RELEASE_110.md +39 -0
- data/docs/POST_RELEASE_MAINTENANCE.md +18 -14
- data/docs/PUBLIC_API.md +19 -10
- data/docs/RELEASE_100_CANDIDATE.md +7 -1
- data/docs/RELEASE_110_CANDIDATE.md +32 -0
- data/docs/RELEASE_120_CANDIDATE.md +32 -0
- data/docs/SELECTIVE_PAYMENT.md +67 -0
- data/docs/SUPPORT_CONTRACT.md +25 -12
- data/docs/evidence/1.1.0_publication.json +101 -0
- data/examples/payment.rb +67 -0
- data/examples/selective_payment.rb +71 -0
- data/lib/ap2_mandate_verifier/payment.rb +366 -0
- data/lib/ap2_mandate_verifier/payment_receipt.rb +87 -0
- data/lib/ap2_mandate_verifier/selective_payment.rb +259 -0
- data/lib/ap2_mandate_verifier.rb +3 -0
- metadata +19 -7
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
> Historical preparation snapshot. 1.0.0 was subsequently published on
|
|
2
|
+
> 2026-11-01 08:13:29.733 UTC; the 102,912-byte official distribution matches
|
|
3
|
+
> the retained candidate and all 33 payloads match the release source.
|
|
4
|
+
> See [publication](POST_RELEASE_100.md) and [current release/upgrade](RELEASE_100.md).
|
|
5
|
+
> Unpublished and pending statements below describe the preparation checkpoint.
|
|
6
|
+
|
|
7
|
+
# 1.0.0 candidate — historical preparation
|
|
2
8
|
|
|
3
9
|
**Unpublished candidate. The currently published release is 0.8.0.**
|
|
4
10
|
The candidate Gem has version `1.0.0`; that metadata is not a publication record.
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
> Historical preparation snapshot. The exact approved candidate is now published; see [publication evidence](POST_RELEASE_110.md). The original approval boundaries below describe that earlier checkpoint.
|
|
2
|
+
|
|
3
|
+
# 1.1.0 candidate — publication requires Owner approval
|
|
4
|
+
|
|
5
|
+
Status: unpublished candidate. Published 1.0.0 remains available and unchanged. The source version 1.1.0 is a proposal for additive Payment APIs under the existing 1.x Checkout contract. Do not tag, publish GitHub Release, push/yank RubyGems, announce or deploy on the basis of this document.
|
|
6
|
+
|
|
7
|
+
## Proposed GitHub Release body
|
|
8
|
+
|
|
9
|
+
Adds framework-independent Direct and conditional Payment Mandates, strict payment conditions/Checkout binding, original-wire persistence/reference helpers, and signed Success/Error Payment Receipts. Existing Checkout API defaults/profiles/results remain unchanged. Payment verification authenticates supported facts; applications still own consent/trust, durable atomic one-use state and payment execution.
|
|
10
|
+
|
|
11
|
+
```ruby
|
|
12
|
+
payment = AP2MandateVerifier::Payment.details(
|
|
13
|
+
checkout_jwt: original_checkout_from_trusted_order,
|
|
14
|
+
trusted_merchant_public_key_pem: registered_merchant_key,
|
|
15
|
+
expected_merchant_id: current_merchant_id,
|
|
16
|
+
payment_instrument: selected_instrument_from_application)
|
|
17
|
+
# After app authentication and consent: issue_direct(payment: payment,
|
|
18
|
+
# approved_payment: protected_consent_record, ...). See examples/payment.rb.
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Supported: one immediate payment, integer minor units, exact payee/instrument and amount range, optional fixed values, one Agent hop. General selective disclosure, recurrence/budgets, PISP/execution_date/risk_data, live processors and A2A/MCP are outside this profile and reject. See [Payment API and specification decisions](PAYMENT.md).
|
|
22
|
+
|
|
23
|
+
## Approval checklist and publication procedure
|
|
24
|
+
|
|
25
|
+
1. Confirm latest reviewed/merged source SHA, package contents/source equality, Gem filename/bytes/SHA256 and immutable evidence record in Issue #235. Verify both supported MRI endpoint tests, installed examples, existing Checkout regression, official pinned SDK/Schema bidirectional interoperability and latest-HEAD independent review. Any unresolved substantive finding or missing required test means HOLD.
|
|
26
|
+
2. Owner explicitly chooses version and approves the exact artifact SHA256, tag/Release and publication/announcement separately. Until then stop. If version/source/artifact changes, rebuild once and repeat affected validation/review; do not reuse approval for a different artifact.
|
|
27
|
+
3. With separate approval, verify `sha256sum` of the approved Gem and `gem specification ... --local`; push that exact file using Owner-controlled RubyGems credentials. Do not rebuild during publication. Create/push the approved tag on the recorded source SHA and publish the approved Release body only when separately authorized.
|
|
28
|
+
4. After approved publication, fetch public RubyGems version metadata and distribution, compare SHA256 and dependency/file metadata, install it into a new isolated environment, run packaged Direct/conditional examples and both Receipt outcomes, check README links/version claims. Record evidence before calling publication verified. Unknown outcomes require reconciliation, never blind retry/yank.
|
|
29
|
+
|
|
30
|
+
No publication/deployment workflow is added. Existing product CI is a read-only source/package validation workflow. Existing research HOLDs remain independent.
|
|
31
|
+
|
|
32
|
+
Runtime dependencies remain pinned: json=2.19.9, jwt=3.3.0, base64=0.3.0, openssl=4.0.2, digest=3.2.1. MRI test endpoints remain 3.4.12 and 4.0.9; installation range >=3.4.12,<4.1 is not a claim of formal support for every intermediate Ruby.
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# 1.2.0 candidate — unpublished, Owner decision required
|
|
2
|
+
|
|
3
|
+
Published1.1.0 remains the released SDK. This is preparation for an additive opt-in Payment candidate-disclosure profile. No RubyGems push/yank, formal tag, GitHub Release, announcement or deployment is authorized by this document. The Owner decides final version and publication after reviewing exact source/artifact/verification identity in Issue#238.
|
|
4
|
+
|
|
5
|
+
## Proposed Release body
|
|
6
|
+
|
|
7
|
+
Adds `SelectivePayment` for conditional Payment with individually disclosed payee and payment-instrument candidates. Retain the full issuance confidentially, select candidates, and send only the reduced Open plus Agent Closed. Mandatory amount/currency/time/delegation/fixed fields/Checkout reference remain visible and verified; partial disclosure never makes a required condition optional. Existing1.1.0 Checkout, Payment and Receipt APIs/defaults/formats are unchanged.
|
|
8
|
+
|
|
9
|
+
```ruby
|
|
10
|
+
# Read approved_combinations from the protected consent record; do not derive
|
|
11
|
+
# broader consent by expanding a correlated subset into a Cartesian product.
|
|
12
|
+
full = AP2MandateVerifier::SelectivePayment.issue_open(
|
|
13
|
+
**approved_open_inputs, approved_combinations: protected_approved_pairs,
|
|
14
|
+
selective: :both)
|
|
15
|
+
sent = AP2MandateVerifier::SelectivePayment.select(
|
|
16
|
+
open_sd_jwt: full, payee_index: 0, instrument_index: 0)
|
|
17
|
+
# Agent signs the exact reduced `sent` bytes, then receiver uses independently
|
|
18
|
+
# trusted Checkout/payment/key/challenge inputs. See examples/selective_payment.rb.
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Supported: single immediate conditional Payment, one Agent hop, candidate-array elements only, independent Cartesian allowlists with explicit approval guard. Correlated subsets require separate singleton/approved-rectangle Open Mandates; unsupported correlation, mandatory-field hiding, unknown structures and arbitrary SD reject. This does not add a generic selective-disclosure API or change Checkout disclosure support.
|
|
22
|
+
|
|
23
|
+
[Full profile, reference and Python interoperability contract](SELECTIVE_PAYMENT.md). Receipt authenticity, reported outcome and final execution permission remain separate. Application-owned consent/trust/key lifecycle, durable atomic one-use state and payment execution are required. Unknown/missing Receipt remains pending and never automatic retry permission.
|
|
24
|
+
|
|
25
|
+
## Exact-artifact publication checklist (not execution authority)
|
|
26
|
+
|
|
27
|
+
1. Confirm the recorded reviewed and merged source/tree, latest-HEAD independent review with zero substantive unresolved findings, relevant CI, both MRI endpoint regressions, candidate ordinary installation/all-file identity, installed sample/privacy comparison and honest official SDK/profile-adapter interoperability scope. Missing required verification means HOLD.
|
|
28
|
+
2. Verify exact candidate filename/bytes/SHA256 and unchanged five runtime dependencies in the final manifest and Issue#238. Earlier development builds are not publication candidates. Owner chooses version and approves that exact artifact plus any formal tag/Release/announcement separately.
|
|
29
|
+
3. Only after that separate approval, inspect current registry/version/tag/Release state. Never overwrite a version or rebuild during publication. Publish the approved archive using existing Owner-controlled authentication; stop at any human authentication handoff and never request credentials/OTP in chat. On uncertain outcome inspect registry before retry.
|
|
30
|
+
4. Fetch actual public metadata/distribution, compare full bytes/SHA256 and every payload against approved source, install into fresh isolated environments and rerun published lifecycle/privacy/Receipt guides. Only then create the approved tag on the approved source and publish Release. Preserve source vs repository-only postpublication documentation identities.
|
|
31
|
+
|
|
32
|
+
No new publication/deployment workflow is introduced. Current product CI builds test candidates only. Existing unrelated research/Rust/production HOLDs remain untouched. Tested MRI endpoints remain3.4.12 and4.0.9; runtime dependencies remain json2.19.9,jwt3.3.0,base640.3.0,openssl4.0.2,digest3.2.1. Installation range>=3.4.12,<4.1 is not formal support for every intermediate release.
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# Payment candidate disclosure — unpublished1.2.0 profile
|
|
2
|
+
|
|
3
|
+
Published1.1.0 remains available with its unchanged complete-content Payment profile. New `AP2MandateVerifier::SelectivePayment` is an explicit opt-in conditional-only profile: `ap2.payment.selective_candidates.1`. Existing `Payment` remains strict and does not accept this new Open format. Existing Checkout/Payment/Receipt keyword/default/result/storage/reference contracts are unchanged. Payment verification/issuance additionally detaches mutable Agent-key inputs consistently and rechecks copied Checkout time; this tightens snapshot safety without changing supported formats or defaults. This is a framework-independent Ruby API; Rails is optional.
|
|
4
|
+
|
|
5
|
+
## Normative source and policy boundary
|
|
6
|
+
|
|
7
|
+
Adopted official AP2 source/SDK/Schema SHA: `b4587ac1d055888a73b4b21750973cffba961793`. Current upstream `e1ea56db72a6385bce3e5c1112b3a56ce60acb43` has identical relevant specification/Schema/SDK. The `open_payment_mandate.json` allowed_payees and allowed_payment_instruments definitions explicitly mark their allowed arrays as selectively disclosable. This profile permits disclosure only at those ARRAY ELEMENT positions; each disclosure is `[salt, complete_candidate_object]` committed through `{"...":digest}` using SHA256/base64url without padding. Salts use16random bytes. Root header remains ES256/example+sd-jwt; Agent terminal is ES256/kb+sd-jwt.
|
|
8
|
+
|
|
9
|
+
An Open has exactly the existing four constraints: amount_range, allowed_payees, allowed_payment_instruments and payment.reference. The entire Open content and all constraint types/fields are mandatory, as are cnf/iat/exp and any fixed payee/payment_amount/payment_instrument. They cannot be hidden. The new root's signed `ap2_profile` marker and the independently selected API fix this exact grammar. Unresolved commitments are allowed only at known candidate positions; no hidden whole condition, unknown location, nested SD, decoy, duplicate digest/disclosure, extra disclosure or unsupported field is accepted. Strictness is a scoped profile, not proof about arbitrary SD-JWT or a source of trust in the signer.
|
|
10
|
+
|
|
11
|
+
**Independent allowlists mean Cartesian product.** `[A,B]` and `[X,Y]` authorize all four combinations, not only `(A,X),(B,Y)`. Issuance requires `approved_combinations` from the application's protected approval record: integer index pairs must exactly cover the Cartesian product, with no duplicate/missing/extra pair. Correlated subsets reject BEFORE signer invocation. Do not auto-generate a broader approval matrix from a paired policy. For a correlated policy, issue separate singleton-pair or explicitly approved rectangular-subset Open Mandates, retaining the required amount/reference/time limits in each. This release does not claim general pairing-constraint support. The SDK does not authenticate user consent or the provenance of the supplied approval record.
|
|
12
|
+
|
|
13
|
+
## Public lifecycle
|
|
14
|
+
|
|
15
|
+
```ruby
|
|
16
|
+
full = AP2MandateVerifier::SelectivePayment.issue_open(
|
|
17
|
+
**independently_approved_open_inputs,
|
|
18
|
+
approved_combinations: protected_approved_pairs, selective: :both)
|
|
19
|
+
sent = AP2MandateVerifier::SelectivePayment.select(
|
|
20
|
+
open_sd_jwt: full, payee_index: 0, instrument_index: 0)
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
`full` is confidential issuance material containing all disclosures. Retain it in protected application storage; do not send/log it. `sent` contains only the Open content disclosure plus selected candidate disclosures for selective axes. Nonselective axes are inline and therefore fully visible. `selective: :payees`, `:instruments` and `:both` explicitly determine the privacy boundary at issuance. Pass nil for each nonselective-axis index; providing an index for that axis rejects. Selection indices refer to the ORIGINAL signed candidate positions; reconstruction/removal of hidden array items does not renumber their meaning.
|
|
24
|
+
|
|
25
|
+
| API | Contract |
|
|
26
|
+
| --- | --- |
|
|
27
|
+
| `issue_open` | open_checkout_sd_jwt, constraints, fixed, approved_combinations, selective, agent_public_key_pem, issued_at, expires_at, signer, public_key_pem → confidential original issuance String. Constraints supplies exactly the three existing amount/payee/instrument conditions; reference is calculated from exact Open Checkout. |
|
|
28
|
+
| `select` | open_sd_jwt, payee_index, instrument_index → detached reduced Open String. Structural selection, not authenticity/consent. Each selective axis reveals exactly one candidate; nonselective axis remains visible. |
|
|
29
|
+
| `issue_closed` | open_presentation, payment, trusted_provider_public_key_pem, agent_public_key_pem, audience, nonce, verified_at, signer → Payment::Presentation with reduced Open and final Closed only. No Provider signer is passed to Agent. |
|
|
30
|
+
| `present` | open_presentation, closed_sd_jwt → Payment::Presentation preserving exact received reduced Open and final Closed; structural restoration only. |
|
|
31
|
+
| `verify` | open_presentation, closed_sd_jwt, checkout_inputs, expected_payment, trusted_provider_public_key_pem, expected_agent_public_key_pem, expected_audience, expected_nonce, verified_at → Payment::Verification. Reruns complete existing conditional Checkout verification, then root/delegation/conditions/reference/expected payment. |
|
|
32
|
+
|
|
33
|
+
The seven `checkout_inputs` are the original public `verify_checkout` keywords, prepared if useful with `InputBuilder.inputs`, at the same explicit verified_at. Expected Checkout/payment/keys/audience/challenge/time must come from independently trusted application state, not received unverified Payment. `Payment.details` can assemble expected payment from an independent Merchant JWT/key/current order and selected instrument. Full issuance/selection/restoration does not grant execution permission.
|
|
34
|
+
|
|
35
|
+
Result is the unchanged immutable `Payment::Verification`: verified?, code, selected payment claims, reference and expiry only; no full issuance/candidate universe. Existing `PaymentReceipt.sign/verify` works on the unchanged final Closed format. Errors use a fixed redacted new-profile Invalid exception without underlying cause; verify fails closed with no selected claims. No raw candidate, wire, parser cause or hidden value belongs in diagnostics/logs. Process/signing failure is not permission and may require reconciliation; preflight bounds run before signing callbacks.
|
|
36
|
+
|
|
37
|
+
## Original bytes, restoration and privacy
|
|
38
|
+
|
|
39
|
+
| Value | Exact SHA256 target |
|
|
40
|
+
| --- | --- |
|
|
41
|
+
| Issuer signature | Original compact root JWT; unchanged when its disclosure subset/order changes |
|
|
42
|
+
| Agent sd_hash | ACTUAL reduced Open presentation, all selected disclosure strings in transmitted order, including terminal `~` |
|
|
43
|
+
| transaction_id | Original Merchant Checkout JWT, unchanged by Payment disclosure choice |
|
|
44
|
+
| payment.reference | Exact Open Checkout presentation from the independently verified Checkout chain |
|
|
45
|
+
| Payment Receipt reference | Final Closed Payment SD-JWT alone including its terminal `~`; excludes Open and chain `~~` separator |
|
|
46
|
+
|
|
47
|
+
Subset/order changes preserve the issuer JWT but change the presented Open hash. Agent must sign the intended exact presentation; later insertion/removal/reordering must fail, never repair the wire from retained issuance. Changing selected candidate usually changes final Closed payment and Receipt reference; with the same Closed claims, a newly signed Agent terminal can still differ and references always follow exact actual bytes. No JSON rebuilding substitutes for original-wire references. Persist exact sent Open and final Closed; `present` restores without reconstructing hidden data, then `verify` must run again with current independent inputs.
|
|
48
|
+
|
|
49
|
+
The receiver does not receive unselected candidate objects, their random salts or leaf disclosure strings. It DOES see commitment count/order, fixed mandatory fields and selected values. Stable issuer JWT/digests permit linkage between presentations of the same issuance; count hiding, padding/decoys, traffic-analysis resistance, unlinkability and secrecy from the issuer/holder are not promised. Nonselective inline axes are deliberately visible. Issuance and protected approval state necessarily contain candidate values; keep them separate from transmitted data and operational logs.
|
|
50
|
+
|
|
51
|
+
## SDK differences and honest interoperability scope
|
|
52
|
+
|
|
53
|
+
Pinned Python `MandateClient.present` selects root2-element vct disclosures and3-element named claims, but drops candidate2-element array leaf disclosures. Its high-level selector cannot directly generate this profile. Use the tested explicit profile adapter and official lower-level issuance/chain primitives, and retain the exact received disclosure strings; do not claim the unsupported selector succeeds.
|
|
54
|
+
|
|
55
|
+
Official generic crypto verification and Schema validation are not this profile's semantic oracle. For example, the one-time Python payment constraint checker can accept a visible Open missing amount_range, and official Schema does not require all four constraints. This profile explicitly requires them and rejects signed missing/hidden mandatory conditions. Independent profile expectations check this safety boundary alongside official signature/chain/typed condition/Schema validation. Tests must report which layer passed and which stricter profile checks rejected; no signature-only or repaired-input result is called full Payment verification.
|
|
56
|
+
|
|
57
|
+
## Limits, example and application responsibilities
|
|
58
|
+
|
|
59
|
+
At most8payees/8instruments, one Agent hop, one immediate payment, supported1.1.0 integer minor units/currencies and600-second lifetime. Only known candidate-array disclosures are supported; no generic arbitrary SD or Checkout selective-disclosure extension. Open wire is limited to65,536bytes, root compactJWT to16,384bytes, each decoded disclosure to24,576bytes, and total disclosures to2–17. Each candidate array has1–8entries; selected presentation requires one revealed candidate per selective axis. Existing JSON depth24, finalClosed32,769-byte wire and per-field bounds are reused. All structural/signing bounds are checked before signer effects. Recurrence/budget/PISP/execution_date/risk_data, arbitrary delegation, unsupported algorithms and unknown constraints reject.
|
|
60
|
+
|
|
61
|
+
After installing the candidate with its pinned dependencies:
|
|
62
|
+
|
|
63
|
+
```sh
|
|
64
|
+
ruby "$(ruby -e 'puts Gem::Specification.find_by_name("ap2_mandate_verifier", "1.2.0").full_gem_path')/examples/selective_payment.rb"
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
The runnable example prints retained/transmitted disclosure counts and byte counts, confirms unchanged issuer JWT and changed presentation bytes, verifies chosen Payment and both Receipt outcomes without printing unselected values/disclosures. Its approved matrix is explicitly synthetic; real code reads protected consent. The application owns user authentication/consent, key enrollment/custody/revocation, current order/trust, final authorization, payment, durable one-use identity and atomic state transitions. Missing/invalid Receipt or uncertain processing remains pending, never automatic retry permission. Candidate status and exact artifact verification are in [release preparation](RELEASE_120_CANDIDATE.md).
|
data/docs/SUPPORT_CONTRACT.md
CHANGED
|
@@ -1,13 +1,22 @@
|
|
|
1
1
|
# AP2 Checkout Ruby SDK — support contract and history
|
|
2
2
|
|
|
3
|
-
## Current contract
|
|
4
|
-
|
|
5
|
-
**Published stable
|
|
6
|
-
The
|
|
7
|
-
|
|
8
|
-
[
|
|
9
|
-
[
|
|
10
|
-
are not new
|
|
3
|
+
## Current contract — published 1.0.0
|
|
4
|
+
|
|
5
|
+
**Published stable is 1.0.0.** It preserves the 0.8.0 product implementation and
|
|
6
|
+
acceptance contracts. The stable 1.x public surface is catalogued in
|
|
7
|
+
[PUBLIC_API](PUBLIC_API.md); exact distribution identity and validation are in
|
|
8
|
+
[the publication record](POST_RELEASE_100.md). The earlier
|
|
9
|
+
[preparation record](RELEASE_100_CANDIDATE.md) and older observations below retain
|
|
10
|
+
their historical scope; they are not new post-publication test results.
|
|
11
|
+
|
|
12
|
+
Registered 2026-11-01 **08:13:29.733 UTC**; official download comparison completed
|
|
13
|
+
**08:16:01 UTC**. The 102,912-byte Gem, SHA256
|
|
14
|
+
`a107101b0178c54ba417be7a2bd7e22feb2fd9a07bda089043e8c5ea8e65e12b`,
|
|
15
|
+
matches the retained candidate exactly, and all 33 payloads match source
|
|
16
|
+
`59e344ad865ed867d0993120456f9411d82bcdec`. Source association comes from
|
|
17
|
+
candidate/payload comparison, not RubyGems source attestation.
|
|
18
|
+
[Publication receipt](evidence/1.0.0_publication.json). The published Gem's documents
|
|
19
|
+
retain their preparation snapshot; repository updates do not rebuild or replace it.
|
|
11
20
|
|
|
12
21
|
| Current supported flow | Contract |
|
|
13
22
|
| --- | --- |
|
|
@@ -30,12 +39,16 @@ The app owns current trust, consent, durable state and final execution. Ruby SDK
|
|
|
30
39
|
support does not establish general AP2 compatibility, Payment support, actual
|
|
31
40
|
Issuer trust or a particular Host's production authorization.
|
|
32
41
|
|
|
33
|
-
The [maintenance policy](POST_RELEASE_MAINTENANCE.md) governs
|
|
42
|
+
The [maintenance policy](POST_RELEASE_MAINTENANCE.md) governs 1.x
|
|
34
43
|
versioning, dependency changes, security corrections and deprecation. The sections
|
|
35
44
|
below preserve older publication evidence and API details; statements explicitly
|
|
36
45
|
scoped to old versions do not remove the current flows listed above.
|
|
37
46
|
|
|
38
|
-
|
|
47
|
+
Documented 0.8.0 API use needs no source migration. A constraint such as `~> 0.8.0`
|
|
48
|
+
does not select 1.0.0; use an appropriate 1.x constraint such as `~> 1.0` and update
|
|
49
|
+
the application lockfile. See [release and migration notes](RELEASE_100.md).
|
|
50
|
+
|
|
51
|
+
## Historical 0.8.0: conditional delegation
|
|
39
52
|
|
|
40
53
|
`ConditionalCheckout.issue_open/issue_closed/present` add conditional delegation
|
|
41
54
|
issuance and original-wire presentation under the unchanged explicit multi-item
|
|
@@ -43,7 +56,7 @@ profile v1. [Contract, errors, limits and application responsibilities](CONDITIO
|
|
|
43
56
|
The packaged standalone example uses only public installed APIs. No old default,
|
|
44
57
|
profile definition/hash, Result/Evidence/diagnostic, saved record or Receipt
|
|
45
58
|
acceptance condition is changed. All candidates remain required; no new selective
|
|
46
|
-
disclosure profile is introduced.
|
|
59
|
+
disclosure profile is introduced. Version 0.8.0 was registered
|
|
47
60
|
2026-11-01 06:01:31.103 UTC and compared 06:03:20 UTC: 79,872 bytes, SHA256
|
|
48
61
|
`6c07664e4291aa8bc025b152075869322411a0d99861e1267959f1794e99acec`.
|
|
49
62
|
All29 payloads match published source `5a7394c1b98f000b321423e2c2f80d50b5157808`.
|
|
@@ -61,7 +74,7 @@ match source `9b4b78a7ed9aa95e7d35e01a64efc1281ba95be3`.
|
|
|
61
74
|
[Publication record](PROJECT_STATUS.md#070-publication). Older version statements below
|
|
62
75
|
retain their historical scope; they do not exclude the new Direct APIs.
|
|
63
76
|
|
|
64
|
-
##
|
|
77
|
+
## Historical 0.6.0: explicit multi-item profile
|
|
65
78
|
|
|
66
79
|
Published **0.6.0** adds the explicitly
|
|
67
80
|
selected `ap2.checkout.single_merchant_multi_item` v1 across input preparation,
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
{
|
|
2
|
+
"verified_at_utc": "2026-11-03T09:28:07.972453+00:00",
|
|
3
|
+
"name": "ap2_mandate_verifier",
|
|
4
|
+
"version": "1.1.0",
|
|
5
|
+
"platform": "ruby",
|
|
6
|
+
"registered_at": "2026-11-03T09:20:11.580Z",
|
|
7
|
+
"prerelease": false,
|
|
8
|
+
"yanked": false,
|
|
9
|
+
"ruby_requirement": ">= 3.4.12, < 4.1",
|
|
10
|
+
"runtime_dependencies": [
|
|
11
|
+
{
|
|
12
|
+
"name": "base64",
|
|
13
|
+
"requirements": "= 0.3.0"
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"name": "digest",
|
|
17
|
+
"requirements": "= 3.2.1"
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"name": "json",
|
|
21
|
+
"requirements": "= 2.19.9"
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"name": "jwt",
|
|
25
|
+
"requirements": "= 3.3.0"
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
"name": "openssl",
|
|
29
|
+
"requirements": "= 4.0.2"
|
|
30
|
+
}
|
|
31
|
+
],
|
|
32
|
+
"bytes": 115200,
|
|
33
|
+
"sha256": "4c64cf5b6c61ae4395577828093a6f4022c35cf18b6ad1bcfcb9f95fbb4f43c9",
|
|
34
|
+
"registry_metadata_sha_matches": true,
|
|
35
|
+
"candidate_public_archive_byte_identical": true,
|
|
36
|
+
"github_asset_byte_identical": true,
|
|
37
|
+
"payloads": 38,
|
|
38
|
+
"all_payloads_match_release_source_and_installed": true,
|
|
39
|
+
"release_source_sha": "89e779cadeac0ea7941e68f12951eed13f1b8081",
|
|
40
|
+
"reviewed_tested_sha": "631537ec52c33c3472fd856da55faeff3fb62203",
|
|
41
|
+
"release_tree": "4282e3349d2a2851940d3f153460a013f0ea6ceb",
|
|
42
|
+
"files_sha256": {
|
|
43
|
+
"LICENSE": "1442143c4265d88eedfc14f25d04298449358c837b0bb58dfa825f84b36391c8",
|
|
44
|
+
"README.ja.md": "8a9a9ad129dbd0be6a98d3097608f0e66705f832ee4e63b2026bcfd46095192e",
|
|
45
|
+
"README.md": "bc72e6df953d53ea8ac23d106c8d7a5e02aa28cd75328479b04f3fd68f4e8dfe",
|
|
46
|
+
"SECURITY.md": "3308faded0eaad624c5caf7477d59d6f172804588e910975873ef6a657010a06",
|
|
47
|
+
"docs/BUYER_DIRECT_CHECKOUT.md": "96c67be9340a152d8bb4d10ea69b812eedce995a7d7b6a54bc0de3e6efca6ed5",
|
|
48
|
+
"docs/CONDITIONAL_CHECKOUT.md": "6ce7b14e3171525a7cbd4283862f724f98650f3f3e669bfab84345273ef3a2a7",
|
|
49
|
+
"docs/DIAGNOSTICS.ja.md": "302c87b40cb44bda43af021448ebe83409db96bbb2b0fb9c44e6a3dc78f3d433",
|
|
50
|
+
"docs/DIAGNOSTICS.md": "881cb7416ac1b18c26042ffa7f3bdbb33ccf5dbc95a2f7394f753271807df056",
|
|
51
|
+
"docs/INPUT_BUILDER.md": "428dbe89887fa13868dd750d19b524aa614eb8a80268bae6e4fd0c837a69841c",
|
|
52
|
+
"docs/MERCHANT_SIGNING.md": "31af8ead7fd507d72af4c400f2134e753d6d2297b1d6b85c831b3bd53185eeb4",
|
|
53
|
+
"docs/MULTI_ITEM_CHECKOUT.md": "3db7caa63b33e7204c8d512ed22403fcceb2b90e198d9e963f13b2610c40b228",
|
|
54
|
+
"docs/PAYMENT.md": "7fea7f2d3433ad5d8fc922a0109d1a6ec34a60f4a1977eee42b43b02e688ccbc",
|
|
55
|
+
"docs/POST_RELEASE_MAINTENANCE.md": "d6662cd35a86d4b8f24a2d350cfef80f3e0b7a1c21bde079757da1b1ae6b5ea0",
|
|
56
|
+
"docs/PUBLIC_API.md": "1be306928a23dd49fe5d08da7714f7f524aed446a04926a6599d5355eef76a42",
|
|
57
|
+
"docs/RELEASE_100_CANDIDATE.md": "4c67c42b9d9987272bb9ef826c48651f7179888549dfe89e973589c8820555df",
|
|
58
|
+
"docs/RELEASE_110_CANDIDATE.md": "4bb9597c2ef0a7e8aa6ecd796f1886acad8dd0bd601ff84cf915260d24833c8b",
|
|
59
|
+
"docs/SUPPORT_CONTRACT.md": "fe48c918918d644bd580e9bdd3d6f80b1a0341a0360b36065149d2cd4e8cb0b3",
|
|
60
|
+
"examples/conditional_checkout.rb": "dd672cc54c4a6650bfff654eb777eddd379c892481b67e58781e297a02c4c5af",
|
|
61
|
+
"examples/payment.rb": "48706d40d97d21c616d4b34f6c8d78c58fa57a7266dfaa81739a971b48cfa019",
|
|
62
|
+
"lib/ap2_mandate_verifier.rb": "0a3608df80855b4986e105667aded9d63ada32b93b0d84f8e7a933636825df1b",
|
|
63
|
+
"lib/ap2_mandate_verifier/buyer.rb": "1a9c129b6eb33ac508472aa634eee7afc4add5a537a5c3cb7d49d12557269588",
|
|
64
|
+
"lib/ap2_mandate_verifier/checkout_jwt.rb": "d96a1e8ea9d69787ce94c35253b866c0d5fb867b8864cd7a9f93a526adbb8781",
|
|
65
|
+
"lib/ap2_mandate_verifier/checkout_receipt.rb": "ba37ef2519eb49d46313c2c85cba894e0e644626e33247d227e0b4c26149c303",
|
|
66
|
+
"lib/ap2_mandate_verifier/conditional_checkout.rb": "685a57939b8a1774dfeb40f2ba2fcb96686f613e4bbe02cb315a82b598e0391e",
|
|
67
|
+
"lib/ap2_mandate_verifier/diagnostic.rb": "0d2e961d80d5f29d42b49898e2df993f60962766437958adba568cbf9b5d7f1e",
|
|
68
|
+
"lib/ap2_mandate_verifier/host_binding.rb": "1373efe503ccc5eda817ffd790799fc622d6cb106f8b7da85ef2b3f4693c662e",
|
|
69
|
+
"lib/ap2_mandate_verifier/input_builder.rb": "a35a5ce9160f0a8816c6dde6eeeeac09724b655d465c5caf7f14acdbe17e3290",
|
|
70
|
+
"lib/ap2_mandate_verifier/input_validator.rb": "395f8e6f2012ab400d7b17f1fdcf4ee63a3c1c9622da4f2b32d35b522542bf00",
|
|
71
|
+
"lib/ap2_mandate_verifier/merchant_signature.rb": "f41aafd533dc3f988956c4503325ebbd82dc43a8bc1511e8c26572b4c32e7e70",
|
|
72
|
+
"lib/ap2_mandate_verifier/payment.rb": "93a44f115fd869fcc497e30e434253292b47aed6ec26502657c70b1477a1b285",
|
|
73
|
+
"lib/ap2_mandate_verifier/payment_receipt.rb": "31ad00de7c733810c6b243dcaf9880576cc3e552892eeeadaf16d212f2179335",
|
|
74
|
+
"lib/ap2_mandate_verifier/purchase_binding.rb": "6f3f966eed59511eed54cc7f28bb8fe83123d43b5b213502a9ea5cc328c53690",
|
|
75
|
+
"lib/ap2_mandate_verifier/research_result.rb": "6b0bc022e57a2a837e296f2b1bfe9a154d69b4c98fea46e269e2d3f28a1c948b",
|
|
76
|
+
"lib/ap2_mandate_verifier/result.rb": "ba4fc058784e34a870507446224121a6ba09387137ef2a8c044e02256fc6c64f",
|
|
77
|
+
"lib/ap2_mandate_verifier/root_disclosures.rb": "7e9d2f51a24c344b54fd4e63e6619108b794b88d0adc003b6cdee821b39a8d65",
|
|
78
|
+
"lib/ap2_mandate_verifier/root_signature.rb": "d9b68d989700a0c103f80004e14fb2d3aa992f823434e07bf2971f63052519dd",
|
|
79
|
+
"lib/ap2_mandate_verifier/scoped_constraints.rb": "5d50858ba365e2716b635a2888f08f38afda7937be879347dd536d11f7b5d44b",
|
|
80
|
+
"lib/ap2_mandate_verifier/trust_context.rb": "897936b2fec31e63a673ca15e89485c5254f13a427aafae9504e3c2525601f97"
|
|
81
|
+
},
|
|
82
|
+
"tag": "v1.1.0",
|
|
83
|
+
"tag_object": "dff5006234c35c24de416786fa7d088953f86105",
|
|
84
|
+
"github_release": {
|
|
85
|
+
"id": 432487583,
|
|
86
|
+
"published_at": "2026-11-03T09:23:10Z",
|
|
87
|
+
"draft": false,
|
|
88
|
+
"prerelease": false,
|
|
89
|
+
"url": "https://github.com/cuichangquan/ap2-mandate-verifier/releases/tag/v1.1.0"
|
|
90
|
+
},
|
|
91
|
+
"postpublication_validation": {
|
|
92
|
+
"mri": [
|
|
93
|
+
"3.4.12",
|
|
94
|
+
"4.0.9"
|
|
95
|
+
],
|
|
96
|
+
"ordinary_install_source_archive_installed_equality": "PASS both endpoints; release-tag source, no rebuild",
|
|
97
|
+
"payment_assertions_each_installed": 113,
|
|
98
|
+
"published_guides": "PASS both endpoints; EN/JA README, retained Checkout examples, installed Payment sample"
|
|
99
|
+
},
|
|
100
|
+
"authentication_observation": "Owner terminal reported successful registration; browser reported verification callback error. Registry metadata and distribution independently confirm publication. No retry push performed; browser error root cause not established."
|
|
101
|
+
}
|
data/examples/payment.rb
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
# Installed Gem only; every payment/processor result is synthetic.
|
|
3
|
+
require "ap2_mandate_verifier"
|
|
4
|
+
require_relative "conditional_checkout"
|
|
5
|
+
module PaymentExample
|
|
6
|
+
M = AP2MandateVerifier
|
|
7
|
+
NOW = ConditionalCheckoutExample::NOW
|
|
8
|
+
def self.run
|
|
9
|
+
state = ConditionalCheckoutExample.run
|
|
10
|
+
provider, agent, merchant = state.fetch(:keys)
|
|
11
|
+
sign = ->(key) { M::CheckoutJWT.es256_signer(private_key: key) }
|
|
12
|
+
checkout = state.fetch(:closed).checkout_jwt
|
|
13
|
+
# External application selects the instrument and independently trusts order/key.
|
|
14
|
+
details = M::Payment.details(checkout_jwt: checkout, trusted_merchant_public_key_pem: merchant.public_to_pem,
|
|
15
|
+
expected_merchant_id: "shop", payment_instrument: {"id" => "synthetic-card", "type" => "card"})
|
|
16
|
+
direct_checkout = M::Buyer.issue_closed(checkout_jwt: checkout, approved_checkout_jwt: checkout,
|
|
17
|
+
trusted_merchant_public_key_pem: merchant.public_to_pem, expected_merchant_id: "shop",
|
|
18
|
+
issued_at: NOW, expires_at: NOW+60, signer: sign.call(provider), public_key_pem: provider.public_to_pem)
|
|
19
|
+
direct_inputs = {closed_sd_jwt: direct_checkout.closed_sd_jwt, expected_checkout_jwt: checkout,
|
|
20
|
+
trusted_provider_public_key_pem: provider.public_to_pem, trusted_merchant_public_key_pem: merchant.public_to_pem,
|
|
21
|
+
expected_merchant_id: "shop", verified_at: NOW}
|
|
22
|
+
# In a real application approved_payment is read from its protected consent record.
|
|
23
|
+
direct = M::Payment.issue_direct(payment: details, approved_payment: details, issued_at: NOW,
|
|
24
|
+
expires_at: NOW+60, signer: sign.call(provider), public_key_pem: provider.public_to_pem)
|
|
25
|
+
base = {expected_payment: details, trusted_provider_public_key_pem: provider.public_to_pem, verified_at: NOW}
|
|
26
|
+
direct_check = M::Payment.verify(**base, closed_sd_jwt: direct.closed_sd_jwt, checkout_mode: :direct, checkout_inputs: direct_inputs)
|
|
27
|
+
raise "Direct failed" unless direct_check.verified?
|
|
28
|
+
|
|
29
|
+
conditions = [{"type" => "payment.amount_range", "currency" => "USD", "max" => 300},
|
|
30
|
+
{"type" => "payment.allowed_payees", "allowed" => [details.fetch("payee")]},
|
|
31
|
+
{"type" => "payment.allowed_payment_instruments", "allowed" => [details.fetch("payment_instrument")]}]
|
|
32
|
+
opening = M::Payment.issue_open(open_checkout_sd_jwt: state.fetch(:opening).root_presentation,
|
|
33
|
+
constraints: conditions, fixed: {"payment_instrument" => details.fetch("payment_instrument")},
|
|
34
|
+
agent_public_key_pem: agent.public_to_pem, issued_at: NOW, expires_at: NOW+60,
|
|
35
|
+
signer: sign.call(provider), public_key_pem: provider.public_to_pem)
|
|
36
|
+
closed = M::Payment.issue_closed(open_sd_jwt: opening, payment: details,
|
|
37
|
+
trusted_provider_public_key_pem: provider.public_to_pem, agent_public_key_pem: agent.public_to_pem,
|
|
38
|
+
audience: "credential-provider", nonce: "synthetic-payment-nonce", verified_at: NOW, signer: sign.call(agent))
|
|
39
|
+
restored = M::Payment.present(open_sd_jwt: opening, closed_sd_jwt: closed.closed_sd_jwt)
|
|
40
|
+
# Reuse existing complete Checkout input preparation; no facts from Payment claims.
|
|
41
|
+
raw = M::InputBuilder.inputs(**state.fetch(:host_inputs), saved_challenge: state.fetch(:saved),
|
|
42
|
+
terminal_jws: state.fetch(:closed).terminal_jws, expected_challenge_issuer_id: "host",
|
|
43
|
+
clock_source_id: "synthetic-clock", verified_at: NOW)
|
|
44
|
+
checked = M::Payment.verify(**base, closed_sd_jwt: restored.closed_sd_jwt, open_sd_jwt: restored.open_sd_jwt,
|
|
45
|
+
checkout_mode: :conditional, checkout_inputs: raw, expected_agent_public_key_pem: agent.public_to_pem,
|
|
46
|
+
expected_audience: "credential-provider", expected_nonce: "synthetic-payment-nonce")
|
|
47
|
+
raise "Conditional failed" unless checked.verified?
|
|
48
|
+
puts "Direct and conditional Payment: verified; no execution permission granted"
|
|
49
|
+
[direct, restored].each do |payment|
|
|
50
|
+
# Alternative simulated outcomes, never two actual executions.
|
|
51
|
+
%w[Success Error].each do |outcome|
|
|
52
|
+
fields = outcome == "Success" ? {psp_confirmation_id: "synthetic-psp", network_confirmation_id: "synthetic-network"} :
|
|
53
|
+
{error: "declined", error_description: "Simulated rejection"}
|
|
54
|
+
receipt = M::PaymentReceipt.sign(closed_sd_jwt: payment.closed_sd_jwt, issuer: "processor",
|
|
55
|
+
payment_id: "synthetic-payment", outcome: outcome, issued_at: NOW, **fields,
|
|
56
|
+
signer: sign.call(merchant), public_key_pem: merchant.public_to_pem)
|
|
57
|
+
result = M::PaymentReceipt.verify(jwt: receipt.jwt, closed_sd_jwt: payment.closed_sd_jwt,
|
|
58
|
+
trusted_public_key_pem: merchant.public_to_pem, expected_issuer: "processor", expected_payment_id: "synthetic-payment",
|
|
59
|
+
not_before: NOW, not_after: NOW+60, verified_at: NOW)
|
|
60
|
+
raise "Receipt failed" unless result.verified? && result.outcome == outcome
|
|
61
|
+
puts "Payment Receipt #{outcome}: authentic=#{result.verified?}; reported_success=#{result.payment_succeeded?}"
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
puts "Synthetic only. Persist one-use state atomically. Missing/invalid Receipt = pending; no automatic retry."
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
PaymentExample.run if $PROGRAM_NAME == __FILE__
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
# Installed SDK only. Confidential issuance stays local; simulated payments only.
|
|
3
|
+
require "ap2_mandate_verifier"
|
|
4
|
+
require_relative "conditional_checkout"
|
|
5
|
+
module SelectivePaymentExample
|
|
6
|
+
M = AP2MandateVerifier
|
|
7
|
+
NOW = ConditionalCheckoutExample::NOW
|
|
8
|
+
def self.run
|
|
9
|
+
state = ConditionalCheckoutExample.run
|
|
10
|
+
provider, agent, merchant = state.fetch(:keys)
|
|
11
|
+
signer = ->(key) { M::CheckoutJWT.es256_signer(private_key: key) }
|
|
12
|
+
checkout = state.fetch(:closed).checkout_jwt
|
|
13
|
+
chosen_instrument = {"id" => "synthetic-card-A", "type" => "card"}
|
|
14
|
+
details = M::Payment.details(checkout_jwt: checkout, trusted_merchant_public_key_pem: merchant.public_to_pem,
|
|
15
|
+
expected_merchant_id: "shop", payment_instrument: chosen_instrument)
|
|
16
|
+
payees = [details.fetch("payee"), {"id" => "another-shop", "name" => "Private alternative payee"}]
|
|
17
|
+
instruments = [chosen_instrument, {"id" => "private-alternative-B", "type" => "card"}]
|
|
18
|
+
conditions = [{"type" => "payment.amount_range", "currency" => "USD", "min" => 100, "max" => 300},
|
|
19
|
+
{"type" => "payment.allowed_payees", "allowed" => payees},
|
|
20
|
+
{"type" => "payment.allowed_payment_instruments", "allowed" => instruments}]
|
|
21
|
+
# This list comes from the app's PROTECTED approval record: every crossproduct
|
|
22
|
+
# combination is expressly approved. Do not expand a correlated subset here.
|
|
23
|
+
approved_combinations = [[0, 0], [0, 1], [1, 0], [1, 1]]
|
|
24
|
+
full = M::SelectivePayment.issue_open(open_checkout_sd_jwt: state.fetch(:opening).root_presentation,
|
|
25
|
+
constraints: conditions, fixed: {}, approved_combinations: approved_combinations, selective: :both,
|
|
26
|
+
agent_public_key_pem: agent.public_to_pem, issued_at: NOW, expires_at: NOW+60,
|
|
27
|
+
signer: signer.call(provider), public_key_pem: provider.public_to_pem)
|
|
28
|
+
reduced = M::SelectivePayment.select(open_sd_jwt: full, payee_index: 0, instrument_index: 0)
|
|
29
|
+
transmitted_disclosures = reduced.split("~", -1)[1...-1]
|
|
30
|
+
visible = transmitted_disclosures.map { |wire| JSON.parse(Base64.urlsafe_decode64(wire)) }
|
|
31
|
+
hidden_leaves = full.split("~", -1)[1...-1].select do |wire|
|
|
32
|
+
value = JSON.parse(Base64.urlsafe_decode64(wire))[1]
|
|
33
|
+
value == payees[1] || value == instruments[1]
|
|
34
|
+
end
|
|
35
|
+
raise "privacy boundary failed" unless (hidden_leaves & transmitted_disclosures).empty? &&
|
|
36
|
+
!JSON.generate(visible).include?("Private alternative") && !JSON.generate(visible).include?("private-alternative-B")
|
|
37
|
+
# Keep full confidential issuance in protected storage; send only reduced.
|
|
38
|
+
# No original unselected disclosure or confidential full wire is printed.
|
|
39
|
+
puts "Retained locally: payees=2; instruments=2; disclosures=#{full.count('~')-1}; bytes=#{full.bytesize}"
|
|
40
|
+
puts "Sent: chosen payee=shop; chosen instrument=synthetic-card-A; disclosures=#{reduced.count('~')-1}; bytes=#{reduced.bytesize}"
|
|
41
|
+
puts "Issuer JWT unchanged=#{full.split('~').first == reduced.split('~').first}; presentation bytes changed=#{full != reduced}"
|
|
42
|
+
closed = M::SelectivePayment.issue_closed(open_presentation: reduced, payment: details,
|
|
43
|
+
trusted_provider_public_key_pem: provider.public_to_pem, agent_public_key_pem: agent.public_to_pem,
|
|
44
|
+
audience: "credential-provider", nonce: "synthetic-selective-payment-nonce", verified_at: NOW,
|
|
45
|
+
signer: signer.call(agent))
|
|
46
|
+
restored = M::SelectivePayment.present(open_presentation: reduced, closed_sd_jwt: closed.closed_sd_jwt)
|
|
47
|
+
checkout_inputs = M::InputBuilder.inputs(**state.fetch(:host_inputs), saved_challenge: state.fetch(:saved),
|
|
48
|
+
terminal_jws: state.fetch(:closed).terminal_jws, expected_challenge_issuer_id: "host",
|
|
49
|
+
clock_source_id: "synthetic-clock", verified_at: NOW)
|
|
50
|
+
verified = M::SelectivePayment.verify(open_presentation: restored.open_sd_jwt, closed_sd_jwt: restored.closed_sd_jwt,
|
|
51
|
+
checkout_inputs: checkout_inputs, expected_payment: details, trusted_provider_public_key_pem: provider.public_to_pem,
|
|
52
|
+
expected_agent_public_key_pem: agent.public_to_pem, expected_audience: "credential-provider",
|
|
53
|
+
expected_nonce: "synthetic-selective-payment-nonce", verified_at: NOW)
|
|
54
|
+
raise "selective verification failed" unless verified.verified?
|
|
55
|
+
puts "Selected Payment verified=true; unselected candidate values/disclosures were not sent"
|
|
56
|
+
%w[Success Error].each do |outcome|
|
|
57
|
+
fields = outcome == "Success" ? {psp_confirmation_id: "synthetic-psp", network_confirmation_id: "synthetic-network"} :
|
|
58
|
+
{error: "declined", error_description: "Simulated rejection"}
|
|
59
|
+
receipt = M::PaymentReceipt.sign(closed_sd_jwt: restored.closed_sd_jwt, issuer: "processor",
|
|
60
|
+
payment_id: "synthetic-selective-payment", outcome: outcome, issued_at: NOW, **fields,
|
|
61
|
+
signer: signer.call(merchant), public_key_pem: merchant.public_to_pem)
|
|
62
|
+
checked = M::PaymentReceipt.verify(jwt: receipt.jwt, closed_sd_jwt: restored.closed_sd_jwt,
|
|
63
|
+
trusted_public_key_pem: merchant.public_to_pem, expected_issuer: "processor", expected_payment_id: "synthetic-selective-payment",
|
|
64
|
+
not_before: NOW, not_after: NOW+60, verified_at: NOW)
|
|
65
|
+
raise "receipt failed" unless checked.verified? && checked.outcome == outcome
|
|
66
|
+
puts "Payment Receipt #{outcome}: authentic=#{checked.verified?}; reported_success=#{checked.payment_succeeded?}"
|
|
67
|
+
end
|
|
68
|
+
puts "Synthetic only. Verification is not execution permission; one-use atomic state belongs to the app; unknown outcome remains pending."
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
SelectivePaymentExample.run if $PROGRAM_NAME == __FILE__
|