ap2_mandate_verifier 1.3.0 → 1.5.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 +24 -8
- data/README.md +24 -8
- data/SECURITY.md +4 -2
- data/docs/PAYMENT_ACCEPTANCE.md +88 -0
- data/docs/PAYMENT_POLICY.md +72 -0
- data/docs/PUBLIC_API.md +13 -3
- data/docs/RELEASE_130_CANDIDATE.md +2 -0
- data/docs/RELEASE_140_CANDIDATE.md +19 -0
- data/docs/RELEASE_150_CANDIDATE.md +21 -0
- data/docs/SELECTIVE_CHECKOUT.md +4 -2
- data/docs/SUPPORT_CONTRACT.md +5 -1
- data/examples/payment_acceptance.rb +77 -0
- data/examples/payment_policy.rb +101 -0
- data/lib/ap2_mandate_verifier/payment.rb +102 -54
- data/lib/ap2_mandate_verifier/payment_acceptance/sqlite_store.rb +316 -0
- data/lib/ap2_mandate_verifier/payment_acceptance.rb +263 -0
- data/lib/ap2_mandate_verifier/payment_policy.rb +115 -0
- data/lib/ap2_mandate_verifier/payment_receipt.rb +6 -5
- data/lib/ap2_mandate_verifier/selective_payment.rb +40 -31
- data/lib/ap2_mandate_verifier.rb +3 -0
- metadata +14 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 20e9c745f34056d635afd6b61add96b7e231c8ddb42e7240ff740d8cba53f850
|
|
4
|
+
data.tar.gz: 859ca97589c71e283afc3cc9963f03d89e3518d58e93e6f74adabfa9b1804352
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 118d2c83af40c04bba6d033880ab13676f401c9419a1f3c56f35a8c2822cd61b9622a0cf0eefffddbc4d097b3a0d2c4f6bec53bda910384167b1b5f1ebb23fa3
|
|
7
|
+
data.tar.gz: 856b624b16d3fdd369b43ac417308d4d0c6dac4cf8698b9a5359dd8c090677b88ddf303387adbea497d9cc3d4e35e06834ab5ed1d08c2e15ab50099ed33a3c5d
|
data/README.ja.md
CHANGED
|
@@ -1,9 +1,25 @@
|
|
|
1
1
|
# AP2 Mandate Verifier — Checkout・PaymentのRuby SDK
|
|
2
2
|
|
|
3
|
-
### 1.
|
|
3
|
+
### 1.5.0候補:Payment受理の原子性と冪等性支援
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
保護された業務上の支払い単位を原子的に予約し、開始前に全検証をやり直します。応答消失・結果不明では自動再実行せず、元のReceiptを照合して復旧できます。未公開候補です。[組込み・永続store・安全性契約](docs/PAYMENT_ACCEPTANCE.md)、[Ruby単体の復旧例](examples/payment_acceptance.rb)、[公開前の確認](docs/RELEASE_150_CANDIDATE.md)。
|
|
6
6
|
|
|
7
|
+
```ruby
|
|
8
|
+
accepted = service.accept(**trusted_scope, mode: :conditional, verification_inputs: raw_inputs)
|
|
9
|
+
dispatch = service.start(ticket: accepted.ticket, verification_inputs: fresh_inputs) if accepted.ticket
|
|
10
|
+
# 実際のprocessor呼出しはアプリ側。同じdispatch.processor_keyを使います。
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
検証成功・永続予約・決済完了は別の事象です。承認済みoccurrenceの保護、全worker共通の永続store、processorの冪等性・照会が必要です。旧1.xのverifierは変更せず、SQLite参照driverは任意の別依存です。
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
### 公開済み1.4.0:PISPと支払い実行日時の条件
|
|
17
|
+
|
|
18
|
+
承認したPISPと実行可能期間を指定し、アプリが独立して確認した決済サービス・実行予定時刻と照合できます。日時は解析した瞬間で比較し、旧1.xの既定動作を維持します。[仕様・API・公式との差](docs/PAYMENT_POLICY.md)、[3方式のRuby例](examples/payment_policy.rb)、[公開照合記録](docs/POST_RELEASE_140.md)。
|
|
19
|
+
|
|
20
|
+
### 公開済み1.3.0:CheckoutとPaymentの選択的開示
|
|
21
|
+
|
|
22
|
+
承認済みの完全Openを安全に保持し、Checkoutの販売者・商品候補、Paymentの支払先・決済手段から必要な情報だけを提示できます。全必須条件と数量の検証を維持します。[仕様・API・Python差分](docs/SELECTIVE_CHECKOUT.md)、[Ruby単体の一連の例](examples/selective_checkout_payment.rb)、[公開照合記録](docs/POST_RELEASE_130.md)。
|
|
7
23
|
|
|
8
24
|
### 公開済み1.2.0:Payment候補の選択的開示
|
|
9
25
|
|
|
@@ -15,13 +31,13 @@
|
|
|
15
31
|
Direct/条件付きPayment Mandateと成功/エラーPayment Receiptを追加しました。[API・制約・信頼境界](docs/PAYMENT.md)、[Ruby単体サンプル](examples/payment.rb)、[公開照合記録](docs/POST_RELEASE_110.md)、[GitHub Release](https://github.com/cuichangquan/ap2-mandate-verifier/releases/tag/v1.1.0)。検証成功は実行許可ではなく、永続的・原子的な単発利用管理と実決済は利用アプリの責任です。
|
|
16
32
|
|
|
17
33
|
```sh
|
|
18
|
-
gem install ap2_mandate_verifier --version 1.
|
|
19
|
-
ruby "$(ruby -e 'puts Gem::Specification.find_by_name("ap2_mandate_verifier", "1.
|
|
34
|
+
gem install ap2_mandate_verifier --version 1.4.0
|
|
35
|
+
ruby "$(ruby -e 'puts Gem::Specification.find_by_name("ap2_mandate_verifier", "1.4.0").full_gem_path')/examples/payment.rb"
|
|
20
36
|
```
|
|
21
37
|
|
|
22
38
|
[English](README.md)
|
|
23
39
|
|
|
24
|
-
**公開済み安定版は1.
|
|
40
|
+
**公開済み安定版は1.4.0です。**
|
|
25
41
|
|
|
26
42
|
1.0.0では、既存のDirectと条件付きCheckoutの公開API・保守契約を確立しました。
|
|
27
43
|
0.8.0の引数・既定値・profile・結果の意味・保存形式と製品実装を維持します。
|
|
@@ -41,8 +57,8 @@ Agent処理へProvider秘密鍵を渡しません。[API・信頼境界](docs/CO
|
|
|
41
57
|
正式対応MRI 3.4.12/4.0.9で動くRuby単体の導入例です。source checkoutやRailsは不要です:
|
|
42
58
|
|
|
43
59
|
```sh
|
|
44
|
-
gem install ap2_mandate_verifier --version 1.
|
|
45
|
-
ruby "$(ruby -e 'puts Gem::Specification.find_by_name("ap2_mandate_verifier", "1.
|
|
60
|
+
gem install ap2_mandate_verifier --version 1.4.0
|
|
61
|
+
ruby "$(ruby -e 'puts Gem::Specification.find_by_name("ap2_mandate_verifier", "1.4.0").full_gem_path')/examples/conditional_checkout.rb"
|
|
46
62
|
```
|
|
47
63
|
|
|
48
64
|
[Ruby単体の実行例](examples/conditional_checkout.rb)はインストール済み公開APIだけを使い、
|
|
@@ -72,7 +88,7 @@ Rubyで購入委任データを検証する、AP2の固定profile向けGemです
|
|
|
72
88
|
正式対応は **MRI 3.4.12とMRI 4.0.9** です。利用者が選ぶGem環境で導入します。
|
|
73
89
|
|
|
74
90
|
```sh
|
|
75
|
-
gem install ap2_mandate_verifier --version 1.
|
|
91
|
+
gem install ap2_mandate_verifier --version 1.4.0
|
|
76
92
|
```
|
|
77
93
|
|
|
78
94
|
BundlerのGemfile:
|
data/README.md
CHANGED
|
@@ -1,9 +1,25 @@
|
|
|
1
1
|
# AP2 Mandate Verifier — Ruby SDK for Checkout and Payment
|
|
2
2
|
|
|
3
|
-
### 1.
|
|
3
|
+
### 1.5.0 candidate: transactional Payment acceptance
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Reserve a protected business occurrence atomically, reverify before one fenced start, and recover the original Receipt after response loss without reopening an uncertain attempt. This candidate is not published. [Integration/store/security contract](docs/PAYMENT_ACCEPTANCE.md), [plain Ruby recovery example](examples/payment_acceptance.rb), [release gates](docs/RELEASE_150_CANDIDATE.md).
|
|
6
6
|
|
|
7
|
+
```ruby
|
|
8
|
+
accepted = service.accept(**trusted_scope, mode: :conditional, verification_inputs: raw_inputs)
|
|
9
|
+
dispatch = service.start(ticket: accepted.ticket, verification_inputs: fresh_inputs) if accepted.ticket
|
|
10
|
+
# Application-owned processor call uses dispatch.processor_key; no SDK payment call.
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Verification, durable reservation and settlement are separate. Use protected enrollment, one authoritative store and processor idempotency/lookup; no automatic timeout release. Existing1.x verifiers remain unchanged. The optional SQLite reference driver is installed separately.
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
### Published1.4.0: PISP and execution-date Payment conditions
|
|
17
|
+
|
|
18
|
+
Explicit Payment profiles now constrain approved PISPs and parsed inclusive execution windows, bound to independent application provider/time context. Existing1.x defaults remain unchanged. [Contract/API/official differences](docs/PAYMENT_POLICY.md), [plain Ruby three-mode example](examples/payment_policy.rb), [verified publication](docs/POST_RELEASE_140.md).
|
|
19
|
+
|
|
20
|
+
### Published 1.3.0: selective Checkout and Payment
|
|
21
|
+
|
|
22
|
+
Keep the complete approved Open confidential and disclose only the merchant/products needed for Checkout, then selected payee/instrument candidates for Payment. Every mandatory condition and quantity remains enforced. [Profile/API/privacy/Python limits](docs/SELECTIVE_CHECKOUT.md), [plain Ruby combined lifecycle](examples/selective_checkout_payment.rb), [verified publication](docs/POST_RELEASE_130.md).
|
|
7
23
|
|
|
8
24
|
### Published1.2.0: selective Payment
|
|
9
25
|
|
|
@@ -15,13 +31,13 @@ Published1.2.0 adds explicit `SelectivePayment` candidate-array disclosure: reta
|
|
|
15
31
|
1.1.0 adds Direct and conditional Payment Mandates plus signed Success/Error Payment Receipts. [Payment APIs and constraints](docs/PAYMENT.md), [plain Ruby lifecycle sample](examples/payment.rb), [verified publication](docs/POST_RELEASE_110.md), [GitHub Release](https://github.com/cuichangquan/ap2-mandate-verifier/releases/tag/v1.1.0). Verification does not grant execution permission; durable atomic one-use state and actual payment remain application responsibilities.
|
|
16
32
|
|
|
17
33
|
```sh
|
|
18
|
-
gem install ap2_mandate_verifier --version 1.
|
|
19
|
-
ruby "$(ruby -e 'puts Gem::Specification.find_by_name("ap2_mandate_verifier", "1.
|
|
34
|
+
gem install ap2_mandate_verifier --version 1.4.0
|
|
35
|
+
ruby "$(ruby -e 'puts Gem::Specification.find_by_name("ap2_mandate_verifier", "1.4.0").full_gem_path')/examples/payment.rb"
|
|
20
36
|
```
|
|
21
37
|
|
|
22
38
|
[日本語](README.ja.md)
|
|
23
39
|
|
|
24
|
-
**Published stable: 1.
|
|
40
|
+
**Published stable: 1.4.0.**
|
|
25
41
|
|
|
26
42
|
1.0.0 establishes the stable public contract for the existing
|
|
27
43
|
Direct and conditional Checkout APIs. It preserves 0.8.0 signatures, defaults,
|
|
@@ -45,8 +61,8 @@ multi-item profile. Provider private keys never enter Agent operations.
|
|
|
45
61
|
Ruby-only Quick Start on MRI 3.4.12 or 4.0.9; no source checkout or Rails required:
|
|
46
62
|
|
|
47
63
|
```sh
|
|
48
|
-
gem install ap2_mandate_verifier --version 1.
|
|
49
|
-
ruby "$(ruby -e 'puts Gem::Specification.find_by_name("ap2_mandate_verifier", "1.
|
|
64
|
+
gem install ap2_mandate_verifier --version 1.4.0
|
|
65
|
+
ruby "$(ruby -e 'puts Gem::Specification.find_by_name("ap2_mandate_verifier", "1.4.0").full_gem_path')/examples/conditional_checkout.rb"
|
|
50
66
|
```
|
|
51
67
|
|
|
52
68
|
The [standalone Ruby example](examples/conditional_checkout.rb) uses only installed
|
|
@@ -80,7 +96,7 @@ The [Rails demo](https://github.com/cuichangquan/ap2-mandate-verifier-demo#readm
|
|
|
80
96
|
Formal support is **MRI 3.4.12 and MRI 4.0.9**. In your chosen Gem environment:
|
|
81
97
|
|
|
82
98
|
```sh
|
|
83
|
-
gem install ap2_mandate_verifier --version 1.
|
|
99
|
+
gem install ap2_mandate_verifier --version 1.4.0
|
|
84
100
|
```
|
|
85
101
|
|
|
86
102
|
Or add to your Gemfile:
|
data/SECURITY.md
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
## 現在の対象と限界 / Current scope
|
|
4
4
|
|
|
5
|
-
[Published 1.
|
|
5
|
+
[Published 1.4.0](https://rubygems.org/gems/ap2_mandate_verifier/versions/1.4.0) is a framework-independent Ruby SDK for the documented AP2 Checkout profiles, including Direct/conditional Checkout and Payment, selective disclosure, PISP/date conditions and Receipt confirmation. See [publication evidence](docs/POST_RELEASE_140.md), the stable [PUBLIC_API](docs/PUBLIC_API.md) and [SUPPORT_CONTRACT](docs/SUPPORT_CONTRACT.md) for its scope and limitations.
|
|
6
6
|
|
|
7
|
-
現在の配布版は、対応profileのDirect/条件付き購入委任の発行・提示・検証・Checkout Receipt確認を備えた、フレームワーク非依存のRuby SDK **1.
|
|
7
|
+
現在の配布版は、対応profileのDirect/条件付き購入委任の発行・提示・検証・Checkout Receipt確認を備えた、フレームワーク非依存のRuby SDK **1.4.0**です。1.xの保守対象は最新マイナー系列の最新修正版のみとし、旧マイナー・0.x・preへのbackportは約束しません。現行版の報告窓口は以下のままです。保守対象・互換性・セキュリティ修正の扱いは[公開後の整備](docs/POST_RELEASE_MAINTENANCE.md)を参照してください。
|
|
8
8
|
|
|
9
9
|
The 1.x policy covers only the latest patch of the latest 1.x minor series; older minors, 0.x and prereleases carry no backport promise. Existing reporting routes below remain available for the current release. See [maintenance and compatibility](docs/POST_RELEASE_MAINTENANCE.md). The pre.3, 0.1.0 candidate and R2 statements below are historical records of those stages, not the current release status.
|
|
10
10
|
|
|
@@ -12,6 +12,8 @@ Evidence is not Host ALLOW or payment permission. Real Issuer trust, specific Ho
|
|
|
12
12
|
|
|
13
13
|
EvidenceはHost ALLOW・決済許可ではありません。実Issuer信頼、特定Host本番GO、Phase 2-BはHOLDを維持し、一般AP2/全Schema・Phase2-A全面PASS・最悪資源/並行性能・native/runtime全面安全性は未証明です。SLA・固定保守年数・受付/修正期限は約束せず、既存のprovider/JSON勧告metadata・通信会計の限界を保持します。本記録は新たな実行・変更・公開を許可しません。
|
|
14
14
|
|
|
15
|
+
1.5.0 is an unpublished opt-in acceptance/idempotency candidate. Its store coordinates protected business occurrences and one start handle; it does not change existing verifier/Host authority contracts or prove external exactly-once/settlement. Store adapters, current authority/order/nonce CAS, filesystem/database recovery and processor lookup/idempotency require application guarantees. No memory fallback or timeout-based re-execution is safe. See [the candidate contract](docs/PAYMENT_ACCEPTANCE.md).
|
|
16
|
+
|
|
15
17
|
## 歴史記録:pre.3の対象と限界 / Historical pre.3 scope
|
|
16
18
|
|
|
17
19
|
`ap2_mandate_verifier 0.1.0.pre.3` is a fixed-profile research prerelease,
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
# Payment acceptance and idempotency support (1.5.0 candidate)
|
|
2
|
+
|
|
3
|
+
This opt-in application-side coordinator separates three events: cryptographic verification, durable reservation of an approved business occurrence, and an external payment processor’s outcome. Existing1.x verifiers and their result meanings remain unchanged. The SDK does not call a processor, transfer funds or promise distributed exactly-once execution.
|
|
4
|
+
|
|
5
|
+
## Stable identity and protected approval
|
|
6
|
+
|
|
7
|
+
A Checkout JWT hash (`transaction_id`), final Mandate hash or Receipt reference changes when an otherwise identical instruction is re-signed. None is sufficient as the business idempotency key. Use independently authenticated Host identifiers: `tenant_id`, `merchant_id` (the actual authority/account namespace), stable `operation_id`, `approval_id`, approved `occurrence_id` and `order_id`. Never allocate a fresh random operation/occurrence for each request or retry.
|
|
8
|
+
|
|
9
|
+
A protected Host approval backend must enroll the exact Checkout/payment semantics and pinned Receipt trust context before acceptance. `accept` cannot enroll or change authority from a received `approved: true` or arbitrary occurrence. The reference adapter enforces uniqueness of the business operation and of the approved occurrence. A secondary final-Closed-reference guard prevents dispatching the exact same final instruction under another occurrence. Wire hashes remain audit/Receipt bindings, not the sole replay key.
|
|
10
|
+
|
|
11
|
+
Canonical terms include the complete supported Checkout payload and payment fields. Only the technical Checkout-JWT hash is excluded from payment terms; parsed execution dates are normalized to exact instants. Changed amounts, products, provider/instrument or other terms conflict rather than create a new slot. JSON object key order is normalized; array order remains significant, so reordered business payload arrays can conservatively conflict. The original signed wires, Receipt reference and processor idempotency key stay pinned to the first reservation.
|
|
12
|
+
|
|
13
|
+
## Minimal integration
|
|
14
|
+
|
|
15
|
+
The optional SQLite reference adapter uses the separately installed `sqlite3 = 2.10.2` driver. It is not a new base-Gem runtime dependency. The ordinary verifier entry loads without SQLite. Missing driver/storage returns unavailable; there is no in-memory fallback.
|
|
16
|
+
|
|
17
|
+
```ruby
|
|
18
|
+
m = AP2MandateVerifier::PaymentAcceptance
|
|
19
|
+
# Protected one-time offline bootstrap only. Fails if the file already exists.
|
|
20
|
+
store = m::SQLiteStore.create(path: "/srv/app/payment_acceptance.sqlite3")
|
|
21
|
+
# Normal startup opens an EXISTING database; a lost file must never reset a ledger.
|
|
22
|
+
store = m::SQLiteStore.new(path: "/srv/app/payment_acceptance.sqlite3")
|
|
23
|
+
service = m::Service.new(store: store)
|
|
24
|
+
|
|
25
|
+
# All six IDs come from authenticated current application state.
|
|
26
|
+
scope = {tenant_id: "tenant-A", merchant_id: "shop", operation_id: "order-42/payment-1",
|
|
27
|
+
approval_id: "consent-99", occurrence_id: "payment-1", order_id: "order-42"}
|
|
28
|
+
# Call this only in the protected approval backend, never a request-driven flag.
|
|
29
|
+
store.authorize!(**scope, mode: :direct,
|
|
30
|
+
profile_ref: AP2MandateVerifier::Payment::PROFILE_REF,
|
|
31
|
+
checkout: approved_checkout, payment: approved_payment,
|
|
32
|
+
receipt_context: {trusted_public_key_pem: processor_public_key,
|
|
33
|
+
expected_issuer: "processor", expected_payment_id: "payment-42",
|
|
34
|
+
not_before: receipt_window_start, not_after: receipt_window_end})
|
|
35
|
+
|
|
36
|
+
accepted = service.accept(**scope, mode: :direct, verification_inputs: raw_payment_verify_inputs)
|
|
37
|
+
if accepted.ticket
|
|
38
|
+
# Fresh authenticated Host/trust/order/challenge/clock inputs; first wires unchanged.
|
|
39
|
+
dispatch = service.start(ticket: accepted.ticket, verification_inputs: fresh_verify_inputs)
|
|
40
|
+
if dispatch
|
|
41
|
+
# Application-owned processor call MUST reuse dispatch.processor_key.
|
|
42
|
+
# The SDK itself performs no network request or payment.
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
`mode` is `:direct`, `:conditional` or `:selective`. `verification_inputs` is the complete raw keyword hash of the corresponding existing `Payment.verify` or `SelectivePayment.verify`, including1.4 profile/context options where applicable. A caller-created verification result is not accepted as evidence. Current supported forms are fully verified; unsupported recurrence/budget formats remain rejected.
|
|
48
|
+
|
|
49
|
+
Enrollment, active authorization/occurrence checks, semantic comparison and reservation occur atomically in the reference DB. An immutable grant cannot be silently replaced; `revoke!` disables it without releasing an existing attempt. `start` reruns the full existing verification pipeline with fresh trusted inputs and requires every original signed Checkout/Payment wire to match. Payment expiry alone is insufficient: Checkout, trust and challenge can expire earlier. Grant/current-order/nonce checks in a production adapter must share its authoritative transaction with reservation/start CAS. A check in one DB followed by a CAS in another leaves a race; the reference grant is not a live connection to an external order or revocation service.
|
|
50
|
+
|
|
51
|
+
## States, retries and uncertain outcomes
|
|
52
|
+
|
|
53
|
+
| Observation | Meaning and permitted next step |
|
|
54
|
+
| --- | --- |
|
|
55
|
+
| `reserved` with opaque Ticket | First committed claim only; not purchase permission. Fresh `start` may yield one dispatch-coordination handle. |
|
|
56
|
+
| `pending` | Existing reservation/processing; no new Ticket or start rights. Read its stored original outcome/key. |
|
|
57
|
+
| `unknown` | Execution outcome uncertain; never automatically release, expire or take over. Query/reconcile using the original processor key. |
|
|
58
|
+
| `receipt_success` / `receipt_error` | Authentic reported Receipt outcome; no independent settlement or no-charge proof. No automatic re-execution. |
|
|
59
|
+
| `conflict` | Same operation/grant with different terms, scope or original instruction usage. No fresh slot. |
|
|
60
|
+
| `rejected` / `unavailable` | No capability. Unknown DB commit outcomes must not be treated as permission or retried as a new operation. |
|
|
61
|
+
|
|
62
|
+
Only the first successful fenced `reserved → processing` CAS returns an `Execution` handle. A crash after that commit but before a processor call can leave zero executions and a pending record. A crash after the call can leave one execution and the same pending record. The SDK cannot distinguish those cases by timeout. It intentionally provides no lease takeover, automatic release or re-execution API. Processor idempotency/lookup semantics and application reconciliation are necessary; database atomicity alone cannot cover an external side effect.
|
|
63
|
+
|
|
64
|
+
For an expired original presentation, use authenticated `lookup(**scope)` to retrieve existing state; it does not bypass fresh verification to create a new claim. Retrying with a re-signed equivalent presentation returns the first record without a Ticket. Never attach its old Receipt to a replacement Closed/Open wire. Returned first signed wires/reference describe the original attempt; no hidden candidate universe is reconstructed.
|
|
65
|
+
|
|
66
|
+
## Receipt and recovery
|
|
67
|
+
|
|
68
|
+
`finish(ticket:, receipt_jwt:, verified_at:)` authenticates a Receipt against the grant’s pinned issuer/key/payment ID/window and the first exact Closed bytes. Receipt time cannot predate successful start. `unknown(ticket:)` preserves an uncertain processing record. After a worker restart, `reconcile(**scope, receipt_jwt:, verified_at:)` may finalize processing/unknown with the same checks, but cannot return a Ticket or start again. `lookup(**scope)` is read-only.
|
|
69
|
+
|
|
70
|
+
A Receipt may arrive after the Mandate expires; its independently pinned Receipt window is distinct. Conflicting Receipt bytes/outcomes do not overwrite a completed record. Error Receipt, missing Receipt or response loss never frees the operation. Key rotation or changed Receipt trust after enrollment needs an explicit application recovery policy; the reference adapter does not silently replace trust.
|
|
71
|
+
|
|
72
|
+
## Reuse and new transactions
|
|
73
|
+
|
|
74
|
+
This API does not consume every Open Mandate globally. A reusable supported Open can lead to fresh Closed instructions for separately authorized new business occurrences. Those occurrences must be independently approved/enrolled and use their own stable operation identity. Arbitrary retry UUIDs are not new authority. The exact same final Closed cannot be dispatched twice under this local acceptance policy. Official recurrence/budget enforcement is not added by this release; applications must not infer reusable authority from an unsupported wire format.
|
|
75
|
+
|
|
76
|
+
## Persistence and adapter contract
|
|
77
|
+
|
|
78
|
+
SQLite is a local single-host reference using transactions, strict supported schema/index/FK checks, unique constraints, fencing and synchronous durable commits. Explicit initialization creates a private file; reopening requires the existing expected database. Missing/corrupt/unsupported schema is unavailable, with no repair/reset/migration or memory fallback. Use a protected local filesystem, one authoritative ledger for all workers and separate connections after fork. Do not create one ledger per worker or request.
|
|
79
|
+
|
|
80
|
+
Database deletion, rollback to an old backup, split-brain copies, broken filesystem locking/fsync, adversarial DB edits, NFS/multi-host replication or operator re-enrollment can invalidate protection. Restore must stop dispatch and reconcile against the processor. SQLite is not a distributed consensus service or a replacement for disaster recovery. Stored Checkout/payment terms and first wires may contain sensitive information; apply application access controls, retention and at-rest protection. Do not log Tickets/fences or raw payloads.
|
|
81
|
+
|
|
82
|
+
Custom adapters may integrate existing DB/Redis infrastructure but must implement atomic protected enrollment/uniqueness, read-and-claim, active-grant/order/occurrence CAS, no capability before durable commit, first-wire/processor-key retention, and monotonic fenced finalization. No check-then-insert, timeout reset or guessed success on I/O/commit error. They need their own independent concurrency/crash/durability tests; this SDK cannot attest an adapter’s persistence guarantees.
|
|
83
|
+
|
|
84
|
+
## Official evidence and guarantees
|
|
85
|
+
|
|
86
|
+
Adopted AP2 pin remains `b4587ac1d055888a73b4b21750973cffba961793`. Relevant docs/schema/SDK are byte-identical to observed official main `e1ea56db72a6385bce3e5c1112b3a56ce60acb43`; current changes there are outside those paths. [Issue346](https://github.com/google-agentic-commerce/AP2/issues/346), [Issue328](https://github.com/google-agentic-commerce/AP2/issues/328) and [Issue339](https://github.com/google-agentic-commerce/AP2/issues/339) remain discussions, not adopted requirements. [PR347](https://github.com/google-agentic-commerce/AP2/pull/347) adds sample reservations but does not establish stable business identity, terms binding and Receipt persistence as normative protocol behavior.
|
|
87
|
+
|
|
88
|
+
The [re-signing discussion](https://github.com/google-agentic-commerce/AP2/issues/346#issuecomment-6614173999) motivates stable merchant-scoped occurrences. AP2 still defines transaction_id from the Checkout JWT and Receipt reference from exact Closed bytes. Official SDK optional expected-Checkout bindings and hidden-constraint discussions do not relax this SDK’s existing strict verification. This local helper is application coordination around those cryptographic facts, not a new AP2 protocol or generic conformance/external exactly-once claim.
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# PISP and execution-date Payment constraints (published1.4.0)
|
|
2
|
+
|
|
3
|
+
New explicit complete/selective Payment profiles add `payment.allowed_pisps` and `payment.execution_date` without changing the existing1.x defaults. Direct and conditional issuance, presentation, strict verification, selective Checkout/Payment and Payment Receipt references share the existing cryptographic and Host verification paths. This SDK remains framework independent and performs no payment scheduling or execution.
|
|
4
|
+
|
|
5
|
+
## Ruby API
|
|
6
|
+
|
|
7
|
+
```ruby
|
|
8
|
+
m = AP2MandateVerifier
|
|
9
|
+
profile = m::PaymentPolicy::PROFILE_REF
|
|
10
|
+
payment = m::Payment.details(**existing_checkout_details,
|
|
11
|
+
pisp: approved_pisp, execution_date: "2026-11-10T00:00:00Z",
|
|
12
|
+
profile_ref: profile)
|
|
13
|
+
constraints = existing_payment_constraints + [
|
|
14
|
+
{"type" => "payment.allowed_pisps", "allowed" => [approved_pisp]},
|
|
15
|
+
{"type" => "payment.execution_date",
|
|
16
|
+
"not_before" => "2026-11-10T00:00:00Z", "not_after" => "2026-11-30T23:59:59Z"}
|
|
17
|
+
]
|
|
18
|
+
open = m::Payment.issue_open(**existing_open_inputs,
|
|
19
|
+
constraints: constraints, candidate_policy: :independent, profile_ref: profile)
|
|
20
|
+
# Existing issue_closed/present flow, with profile_ref: profile on each call.
|
|
21
|
+
checked = m::Payment.verify(**existing_verification_inputs,
|
|
22
|
+
profile_ref: profile,
|
|
23
|
+
trusted_pisp: authenticated_registry.fetch("processor-A"),
|
|
24
|
+
execution_at: independent_application_execution_at)
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Keep the application’s protected approval, authenticated registry and execution context distinct from received claims. Do not build the last two inputs by copying a received Payment. All existing parameters remain required; the snippets show only additions. The [complete installed Ruby example](../examples/payment_policy.rb) runs Direct, complete conditional and selective conditional Payment, rejects mismatched provider/time and an out-of-window date, then verifies both Receipt alternatives.
|
|
28
|
+
|
|
29
|
+
For `SelectivePayment`, use `PaymentPolicy::SELECTIVE_PROFILE_REF` on every lifecycle call (including `select`), retain its existing protected payee/instrument `approved_combinations` and `selective:` inputs, and add `candidate_policy: :independent` on issuance. `Payment.details` prepares the shared details using the new complete profile. Receipt `reference`, `sign` and `verify` take the corresponding explicit profile; final Closed bytes remain the reference source.
|
|
30
|
+
|
|
31
|
+
## Which conditions are checked, and when?
|
|
32
|
+
|
|
33
|
+
| Condition | Issuance/Agent preparation | Verification |
|
|
34
|
+
| --- | --- | --- |
|
|
35
|
+
| PISP identity | Validate exact legal/brand/domain fields and approved allowlist membership | Authenticate signed chain; compare Closed PISP to independent trusted application PISP and any allowed set |
|
|
36
|
+
| Execution instant | Parse explicit Closed/fixed date and every supplied bound; enforce inclusive window | Compare signed instant with independent application `execution_at`, then all window/fixed conditions |
|
|
37
|
+
| Existing amount/payee/instrument | Retain existing complete or selective constraints | Retain complete Checkout/Host/order/challenge/reference verification |
|
|
38
|
+
| Receipt | Sign a reference to exact final Closed bytes | Authenticate issuer, outcome/time and exact reference; no settlement inference |
|
|
39
|
+
|
|
40
|
+
The new profiles require both explicit `pisp` and `execution_date` in Closed and both `trusted_pisp` and `execution_at` during verification. New Open constraints can contain either new type or both, with at least one. This is a deliberately strict subset: it does not silently interpret an omitted date as immediate execution. The old profiles retain their existing contract.
|
|
41
|
+
|
|
42
|
+
## Independent trusted execution context
|
|
43
|
+
|
|
44
|
+
`trusted_pisp` must come from the application’s independently authenticated provider selection/registry/channel, not from a received token. Matching `expected_payment` alone is insufficient. Each PISP has exactly `legal_name`, `brand_name` and `domain_name`; all three compare exactly. Domain is canonical lowercase ASCII DNS in this supported profile (bounded valid labels; no URL, port, path, wildcard, trailing dot or unknown field). Names are bounded descriptive strings with no implicit Unicode or case normalization.
|
|
45
|
+
|
|
46
|
+
The official PISP Schema describes the domain as secured by an eIDAS QWAC certificate. This library does not fetch/validate QWACs, establish legal authorization or authenticate a network endpoint from text. Applications own certificate/channel validation, enrollment, revocation and the provenance/freshness of their trusted PISP input. A syntactically valid domain or valid Mandate signature does not establish those facts.
|
|
47
|
+
|
|
48
|
+
`execution_at` is an independently controlled application execution-plan/operational instant. It must represent the same instant as signed `execution_date`. It is distinct from `verified_at`, which checks signature/Mandate freshness. Future plan verification does not prove that execution occurred or will later occur under that context. The existing maximum600secondMandate lifetime is unchanged; a future execution date does not extend its expiry. At the actual execution gate, the application must recheck the actual provider/time/current approval and a valid Mandate, atomically consume one-use state and reconcile uncertain outcomes. The SDK does not schedule, call a PISP or settle a payment.
|
|
49
|
+
|
|
50
|
+
## Date semantics
|
|
51
|
+
|
|
52
|
+
The supported subset is an explicit RFC3339 timestamp: Gregorian year0001..9999, uppercase `T`/`Z`, valid calendar/time, optional1..9 fractional digits and an explicit `Z` or numeric offset. Offsets must be syntactically valid; `-00:00` (unknown offset), date-only/local timestamps, invalid dates, leap seconds and unsupported precision are rejected. Parsing produces an exact rational instant, without floating-point rounding or lexical comparison.
|
|
53
|
+
|
|
54
|
+
`not_before` and `not_after` are inclusive. At least one bound must be present; if both are present the lower instant cannot exceed the upper. Equivalent offsets denote the same instant for window/context comparisons. A bound ending at `23:59:59Z` denotes that exact instant; later fractions of that second are outside the window. Specify the intended fractional precision or next boundary explicitly. An Open fixed `execution_date` additionally binds its exact string through Agent delegation; a different representation cannot replace that fixed value even if it denotes the same instant.
|
|
55
|
+
|
|
56
|
+
## Profiles and compatibility
|
|
57
|
+
|
|
58
|
+
Use `PaymentPolicy::PROFILE_REF` (`ap2.payment.pisp_execution.complete.1`) with `Payment`, or `PaymentPolicy::SELECTIVE_PROFILE_REF` (`ap2.payment.pisp_execution.selective.1`) with `SelectivePayment`. Pass the corresponding explicit `profile_ref:` through issuance, selection/presentation, verification and Receipt APIs. New signed profile markers prevent silent cross-profile interpretation. Omitting the option preserves old defaults; old profiles reject the new fields/conditions/context.
|
|
59
|
+
|
|
60
|
+
For new Opens, `candidate_policy: :independent` explicitly means the protected consent approved independent PISP/payee/instrument sets. It is not proof of consent. Existing selective payee×instrument `approved_combinations` checks remain required. Correlated PISP/instrument/payee restrictions cannot be flattened into these sets; issue separate Opens for permitted combinations. Recurrence and cumulative budgets remain unsupported and fail closed.
|
|
61
|
+
|
|
62
|
+
PISP lists and execution conditions are mandatory visible content, including under `SelectivePayment`: the official Schema does not mark the PISP array as selectively disclosable. Only the existing payee/instrument candidate positions may be reduced. Keep complete issuance confidential; counts/order/issuer linkage and intentionally visible PISP conditions remain observable. Errors/diagnostics must not expose hidden candidate values or caller inputs.
|
|
63
|
+
|
|
64
|
+
Direct Payment uses exact protected `approved_payment`, including PISP and execution instant, rather than an Open constraint window. Conditional Payment adds Open constraints and keeps the exact reduced Checkout Open reference. `checkout_profile_ref:` still explicitly selects selective Checkout when used. Receipt authenticity remains a statement about signed reported outcome, not independent PISP/settlement confirmation.
|
|
65
|
+
|
|
66
|
+
## Official source and Python boundary
|
|
67
|
+
|
|
68
|
+
Adopted source remains AP2v0.2.0 `b4587ac1d055888a73b4b21750973cffba961793`: [Payment specification](https://github.com/google-agentic-commerce/AP2/blob/b4587ac1d055888a73b4b21750973cffba961793/docs/ap2/payment_mandate.md), [Open Schema](https://github.com/google-agentic-commerce/AP2/blob/b4587ac1d055888a73b4b21750973cffba961793/code/sdk/schemas/ap2/open_payment_mandate.json), [PISP Schema](https://github.com/google-agentic-commerce/AP2/blob/b4587ac1d055888a73b4b21750973cffba961793/code/sdk/schemas/ap2/types/pisp.json).
|
|
69
|
+
|
|
70
|
+
The normative text requires inclusive execution bounds. Schema permits weakly typed strings; it does not itself enforce this strict timestamp subset. The pinned Python evaluator compares date strings lexically and permits absent dates even with a date constraint. Its PISP evaluator does compare all three identity fields. Ruby’s parsed/context-bound behavior is an explicit safer supported subset, not an unqualified claim that all official high-level helpers behave identically. Source interoperability observed three lifecycle cases in each direction (Direct/complete conditional/selective conditional), twelve Receipt checks and62 negatives, plus six explicitly recorded upstream date-check disagreements. Separate positive variants cover PISP-only/date-only/one-sided constraints. Exact signed-wire hashes and actual runtime provenance are recorded with the candidate; supported claims do not extend to QWAC provenance, execution or generic AP2 conformance.
|
|
71
|
+
|
|
72
|
+
[Verified public artifact, tag and Release](POST_RELEASE_140.md). The original candidate preparation is retained as [historical evidence](RELEASE_140_CANDIDATE.md).
|
data/docs/PUBLIC_API.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Ruby SDK public API — 1.x
|
|
2
2
|
|
|
3
|
-
**Status: published 1.
|
|
3
|
+
**Status: published 1.4.0; the original 1.0.0 Checkout contract below is preserved.**
|
|
4
4
|
This document defines the 1.x contract for the existing Checkout APIs.
|
|
5
5
|
The 1.0.0 release preserves the 0.8.0 runtime behavior, API names and accepted
|
|
6
6
|
formats. Exact distribution identity and validation are in
|
|
@@ -206,8 +206,18 @@ The preceding 1.0.0 Checkout contract remains unchanged. New `Payment` and `Paym
|
|
|
206
206
|
|
|
207
207
|
New explicit `SelectivePayment` APIs are described in the [selective Payment contract](SELECTIVE_PAYMENT.md). They do not alter the published1.1.0 `Payment` default profile or Receipt reference format. They are available in1.2.0 and later, not in1.1.0.
|
|
208
208
|
|
|
209
|
-
## 1.3.0
|
|
209
|
+
## Published 1.3.0: selective Checkout
|
|
210
210
|
|
|
211
|
-
The additive `SelectiveCheckout` profile is
|
|
211
|
+
The additive `SelectiveCheckout` profile is available in published 1.3.0. See the [candidate contract](SELECTIVE_CHECKOUT.md) for mandatory disclosure, independent candidate semantics, original-wire references and application responsibilities. It is not available in the published 1.2.0 package. Existing complete profile defaults are preserved.
|
|
212
212
|
|
|
213
213
|
For the explicit selective Checkout profile, Evidence `original_root_graph_closure` records that every signed commitment and supplied disclosure was inspected and accounted for, allowing unresolved candidate leaves only at registered positions. It does not certify hidden preimages, their schema or uniqueness, or consent provenance. The checked scope covers the visible candidate subset and all mandatory conditions.
|
|
214
|
+
|
|
215
|
+
## Published1.4.0: explicit Payment policy profiles
|
|
216
|
+
|
|
217
|
+
`PaymentPolicy::PROFILE_REF` and `SELECTIVE_PROFILE_REF` opt into PISP/execution constraints in existing `Payment`, `SelectivePayment` and `PaymentReceipt` APIs via `profile_ref:`. Verification additionally requires independently trusted `trusted_pisp:` and `execution_at:`; missing context is never filled from claims. New Open issuance requires `candidate_policy: :independent`. Both new fields are mandatory in Closed, even when only one new Open constraint is used. See [strict parsing, condition stages, API additions and official limitations](PAYMENT_POLICY.md). Old defaults, grammar and result meanings remain unchanged. No scheduler/payment execution is added.
|
|
218
|
+
|
|
219
|
+
## 1.5.0 candidate: application-side Payment acceptance
|
|
220
|
+
|
|
221
|
+
`PaymentAcceptance::Service` takes a transactional `store:` adapter. `accept` invokes existing raw verifiers then atomically checks an enrolled protected occurrence and reserves it; `start` requires fresh raw verification and exact first signed wires before fenced CAS. `finish`, `unknown`, `lookup` and `reconcile` retain first-wire/Receipt/processor-key bindings and never automatically release or reissue a Ticket. No existing verifier result is reinterpreted as Host ALLOW.
|
|
222
|
+
|
|
223
|
+
`SQLiteStore.create(path:)` explicitly initializes once; `new(path:)` opens an existing supported database and requires optional `sqlite3 = 2.10.2`. Base runtime dependencies remain unchanged. `authorize!` and `revoke!` are protected Host operations, never request-derived approval flags. See [all parameters, states, adapter guarantees, supported reuse and recovery limits](PAYMENT_ACCEPTANCE.md).
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# 1.3.0 release candidate preparation
|
|
2
2
|
|
|
3
|
+
**Historical prepublication record. 1.3.0 is now published; see [verified publication](POST_RELEASE_130.md). Do not repeat its push or rebuild a substitute artifact.**
|
|
4
|
+
|
|
3
5
|
Status: release candidate prepared; final evidence and GO/HOLD judgment are tracked in [Issue #241](https://github.com/cuichangquan/ap2-mandate-verifier/issues/241). **Publication remains HOLD pending the Owner’s final decision.** RubyGems publication, formal v1.3.0 tag, GitHub Release and announcements require the Owner’s final approval. No production deployment or real payment is included.
|
|
4
6
|
|
|
5
7
|
## Proposed release notes
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# 1.4.0 candidate preparation
|
|
2
|
+
|
|
3
|
+
**Historical prepublication record.1.4.0 is now public; see [verified publication](POST_RELEASE_140.md). Do not repeat its push or substitute a rebuilt artifact.**
|
|
4
|
+
|
|
5
|
+
Status: release candidate preparation. Final exact-source/package/CI evidence and GO/HOLD recommendation are recorded in the PR and external manifest after verification. RubyGems publication, formalv1.4.0 tag, GitHub Release, announcements, deployment and real payment remain HOLD for Owner decision.
|
|
6
|
+
|
|
7
|
+
## Proposed notes
|
|
8
|
+
|
|
9
|
+
Ruby applications can constrain a conditional Payment to approved PISPs and an inclusive execution window, bind its signed plan to independently trusted application provider/time context, and combine it with selective Checkout/Payment and Success/Error Receipts. Direct Payment binds exact approved PISP/date details. Existing1.x defaults remain unchanged.
|
|
10
|
+
|
|
11
|
+
This explicit profile supports strict parsed RFC3339 instants and exact PISP identity; it does not authenticate QWACs from strings, schedule payments, prove consent provenance or settlement. PISP/date conditions stay visible. Independent allowlists cannot express correlated provider/payment-method policies; separate Opens are required. Recurrence/budget remain unsupported.
|
|
12
|
+
|
|
13
|
+
## Final gates
|
|
14
|
+
|
|
15
|
+
Exact-source independent review with no unresolvedP1/P2; signed/context/date/crypto/SD/Receipt/privacy negatives; full regression and installed package verification under supportedMRI3.4.12/4.0.9; independent Python datetime oracle and pinned official SDK/Schema interoperability with discrepancies explicit; exactHEADCI; reproducible one-candidate archive and complete source/archive/installed file equality. Candidate source/size/hash, review/PR/CI links and GO/HOLD recommendation will be recorded externally to avoid self-referential checksums.
|
|
16
|
+
|
|
17
|
+
The fixed builder is existing MRI3.4.12/RubyGems3.6.9 with `SOURCE_DATE_EPOCH=1793750400`; build twice and compare complete archive bytes. Both supported MRI versions must install the same fixed-builder candidate. A different RubyGems builder may change metadata and must not be silently substituted. No checksum is embedded in its own package.
|
|
18
|
+
|
|
19
|
+
Only after Owner approves an exact candidate may publication begin. Recheck source/bytes/reviews/CI and registry absence immediately before a single owner-controlled interactive push. Never retry an ambiguous push; verify registry and downloaded bytes first. Formal tag/Release require matching published bytes and separately authorized release scope. No publish/deploy trigger may be introduced into CI.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# 1.5.0 release candidate preparation
|
|
2
|
+
|
|
3
|
+
Release candidate preparation; final exact-source/artifact/review/CI evidence is recorded in the PR and external manifest. RubyGems/public tag/GitHub Release/production connection/real payment remain HOLD pending Owner decision.
|
|
4
|
+
|
|
5
|
+
## Proposed notes and main use
|
|
6
|
+
|
|
7
|
+
1.5 adds opt-in transactional Payment acceptance: enroll a protected business occurrence, verify raw Mandates, reserve atomically, reverify before one fenced start and reconcile the original Receipt after uncertain outcomes. Re-signing does not create a new operation. Separately authorized new occurrences are supported without globally consuming every Open Mandate. Existing1.x verifier APIs/results and base runtime dependencies remain unchanged; SQLite reference persistence uses an optional pinned driver.
|
|
8
|
+
|
|
9
|
+
```ruby
|
|
10
|
+
accepted = service.accept(**trusted_scope, mode: :conditional, verification_inputs: raw_inputs)
|
|
11
|
+
dispatch = service.start(ticket: accepted.ticket, verification_inputs: fresh_inputs) if accepted.ticket
|
|
12
|
+
# Application-owned processor call reuses dispatch.processor_key; no SDK payment call.
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
State reservation, verification and settlement are distinct. No automatic release/takeover after timeout, Error Receipt, worker crash or response loss. Stable Host identity, protected enrollment, one authoritative durable store and processor lookup/idempotency remain application requirements. Receipt authenticity is not proof of settlement. Custom adapters need their own atomicity/durability tests.
|
|
16
|
+
|
|
17
|
+
## Final gates and publication procedure
|
|
18
|
+
|
|
19
|
+
Full supported MRI3.4.12/4.0.9 regressions; optional-driver absence isolation; source/installed acceptance tests; independent multi-process barrier/external counter/SIGKILL/restart and re-sign/new-occurrence controls; schema/commit/Receipt/expiry/privacy negatives; exact-HEAD independent review with zero unresolved P1/P2; Draft-first PRs, successful CI and verified merged-tree equality; candidate package metadata and every source/archive/installed file identical. Fixed builder/source-date epoch must reproduce the same archive; both MRIs install that one archive. Evidence/checksum remain outside their own package.
|
|
20
|
+
|
|
21
|
+
Only after Owner approves an exact candidate may publication begin. Recheck registry absence/source/bytes/review/CI; no blind retry of uncertain writes. Verify downloaded published bytes before formal tag/Release. No publication or deployment CI trigger may be added.
|
data/docs/SELECTIVE_CHECKOUT.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Selective Checkout Mandates (1.3.0
|
|
1
|
+
# Selective Checkout Mandates (published 1.3.0)
|
|
2
2
|
|
|
3
3
|
This explicit profile lets an application retain a confidential complete Open Checkout Mandate and send only the merchant and product candidates needed for a purchase. Every requirement and quantity remains visible and enforced. The existing complete Checkout profiles and their defaults remain available.
|
|
4
4
|
|
|
@@ -39,7 +39,7 @@ Configure `InputBuilder.trust(..., profile_ref: SelectiveCheckout::PROFILE_REF)`
|
|
|
39
39
|
|
|
40
40
|
For Payment, pass `checkout_profile_ref: SelectiveCheckout::PROFILE_REF` explicitly to `Payment.issue_open` or `SelectivePayment.issue_open`, and supply the reduced Checkout Open as `open_checkout_sd_jwt`. The default is unchanged. `SelectivePayment.verify` still takes the seven original Checkout verification inputs and rechecks the full Host-bound chain.
|
|
41
41
|
|
|
42
|
-
Run the installed
|
|
42
|
+
Run the installed Gem’s [standalone Checkout example](../examples/selective_checkout.rb) and [combined Checkout/Payment example](../examples/selective_checkout_payment.rb). They generate synthetic keys in memory, compare retained/sent disclosures and authenticate both Success/Error Receipt alternatives without executing a purchase.
|
|
43
43
|
|
|
44
44
|
## Verification and quantities
|
|
45
45
|
|
|
@@ -68,3 +68,5 @@ The adopted AP2 source remains pinned to `b4587ac1d055888a73b4b21750973cffba9617
|
|
|
68
68
|
The pinned Python SDK high-level presentation helper does not expose this candidate selection/profile flow. Interoperability must distinguish official low-level signatures/chain/typed Schema checks from the strict subset adapter. In particular, its max-flow helper may accept an empty candidate list as a wildcard or accept underfilled demand; this SDK requires nonempty disclosed candidates and exact quantity coverage. Official SDK acceptance alone is not a strict quantity oracle.
|
|
69
69
|
|
|
70
70
|
Source interoperability observed two Checkout scenarios in each direction, eight Success/Error Receipt checks and 28 negative controls under Ruby 3.4.12 / Python 3.11.2. The Python terminal adapter uses the official JWT primitive plus an exact reduced-wire `sd_hash`, because the SDK’s generic key-binding creator discloses its final payload while this supported Checkout grammar requires an inline final Closed payload. Source and installed-candidate evidence, final review and CI are recorded separately in the release preparation report; these limited synthetic observations do not establish production trust.
|
|
71
|
+
|
|
72
|
+
[Verified public artifact, tag and Release](POST_RELEASE_130.md). The original candidate preparation remains historical in [release preparation](RELEASE_130_CANDIDATE.md).
|
data/docs/SUPPORT_CONTRACT.md
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
# AP2 Checkout Ruby SDK — support contract and history
|
|
2
2
|
|
|
3
|
-
## Current
|
|
3
|
+
## Current published and candidate scope
|
|
4
|
+
|
|
5
|
+
Published stable is1.4.0: [verified publication](POST_RELEASE_140.md). The1.5.0 candidate adds opt-in [transactional Payment acceptance](PAYMENT_ACCEPTANCE.md) while preserving all existing1.x verifier APIs, defaults and stored formats. The SQLite reference adapter additionally requires optional pinned driver2.10.2 and a protected local persistent filesystem; other adapters require their own atomicity/durability validation. No new external exactly-once or production authorization guarantee is made. Final1.5 publication remains Owner-held.
|
|
6
|
+
|
|
7
|
+
## Historical1.0.0 baseline contract
|
|
4
8
|
|
|
5
9
|
**Published stable is 1.0.0.** It preserves the 0.8.0 product implementation and
|
|
6
10
|
acceptance contracts. The stable 1.x public surface is catalogued in
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
# Installed SDK; optional sqlite3=2.10.2. Synthetic temporary DB/mock processor.
|
|
3
|
+
# Production uses a protected persistent existing DB, never per-request temp storage.
|
|
4
|
+
require "ap2_mandate_verifier"
|
|
5
|
+
require "tmpdir"
|
|
6
|
+
require_relative "selective_checkout"
|
|
7
|
+
module PaymentAcceptanceExample
|
|
8
|
+
M = AP2MandateVerifier
|
|
9
|
+
A = M::PaymentAcceptance
|
|
10
|
+
NOW = SelectiveCheckoutExample::NOW
|
|
11
|
+
def self.run
|
|
12
|
+
state = SelectiveCheckoutExample.run
|
|
13
|
+
provider, agent, merchant = state.fetch(:keys)
|
|
14
|
+
signer = ->(key) { M::CheckoutJWT.es256_signer(private_key: key) }
|
|
15
|
+
checkout = state.fetch(:closed).checkout_jwt
|
|
16
|
+
details = M::Payment.details(checkout_jwt: checkout, trusted_merchant_public_key_pem: merchant.public_to_pem,
|
|
17
|
+
expected_merchant_id: "shop", payment_instrument: {"id" => "synthetic-card", "type" => "card"})
|
|
18
|
+
buyer = M::Buyer.issue_closed(checkout_jwt: checkout, approved_checkout_jwt: checkout,
|
|
19
|
+
trusted_merchant_public_key_pem: merchant.public_to_pem, expected_merchant_id: "shop", issued_at: NOW,
|
|
20
|
+
expires_at: NOW + 60, signer: signer.call(provider), public_key_pem: provider.public_to_pem)
|
|
21
|
+
payment_args = {payment: details, approved_payment: details, issued_at: NOW, expires_at: NOW + 60,
|
|
22
|
+
signer: signer.call(provider), public_key_pem: provider.public_to_pem}
|
|
23
|
+
payment = M::Payment.issue_direct(**payment_args)
|
|
24
|
+
raw = {closed_sd_jwt: payment.closed_sd_jwt, checkout_mode: :direct, checkout_inputs: {
|
|
25
|
+
closed_sd_jwt: buyer.closed_sd_jwt, trusted_provider_public_key_pem: provider.public_to_pem,
|
|
26
|
+
trusted_merchant_public_key_pem: merchant.public_to_pem, expected_checkout_jwt: checkout,
|
|
27
|
+
expected_merchant_id: "shop", verified_at: NOW}, expected_payment: details,
|
|
28
|
+
trusted_provider_public_key_pem: provider.public_to_pem, verified_at: NOW}
|
|
29
|
+
# These identifiers/terms are protected authenticated Host approval state,
|
|
30
|
+
# never request-generated retry UUIDs or values copied from received claims.
|
|
31
|
+
scope = {tenant_id: "tenant", merchant_id: "shop", operation_id: "office-1/payment-1",
|
|
32
|
+
approval_id: "synthetic-consent-1", occurrence_id: "payment-1", order_id: "office-1"}
|
|
33
|
+
Dir.mktmpdir("ap2-acceptance-example") do |directory|
|
|
34
|
+
path = File.join(directory, "acceptance.sqlite3")
|
|
35
|
+
store = A::SQLiteStore.create(path: path) # Explicit ONE-TIME bootstrap only.
|
|
36
|
+
store.authorize!(**scope, mode: :direct, profile_ref: M::Payment::PROFILE_REF,
|
|
37
|
+
checkout: state.fetch(:checkout), payment: details, receipt_context: {
|
|
38
|
+
trusted_public_key_pem: merchant.public_to_pem, expected_issuer: "processor-A",
|
|
39
|
+
expected_payment_id: "synthetic-payment-1", not_before: NOW, not_after: NOW + 1000})
|
|
40
|
+
service = A::Service.new(store: store)
|
|
41
|
+
first = service.accept(**scope, mode: :direct, verification_inputs: raw)
|
|
42
|
+
raise "first reservation failed" unless first.status == :reserved && first.ticket
|
|
43
|
+
# New salt/signature changes original bytes, but not the approved business operation.
|
|
44
|
+
resigned = M::Payment.issue_direct(**payment_args)
|
|
45
|
+
replay = service.accept(**scope, mode: :direct, verification_inputs: raw.merge(closed_sd_jwt: resigned.closed_sd_jwt))
|
|
46
|
+
raise "retry issued another ticket" unless replay.status == :pending && replay.ticket.nil? &&
|
|
47
|
+
replay.closed_sd_jwt == payment.closed_sd_jwt && replay.processor_key == first.processor_key
|
|
48
|
+
puts "First=reserved; re-signed retry=pending; no second Ticket; first wire retained"
|
|
49
|
+
# Production supplies FRESH authenticated Host/trust/order/clock inputs here.
|
|
50
|
+
execution = service.start(ticket: first.ticket, verification_inputs: raw)
|
|
51
|
+
raise "start failed" unless execution && !service.start(ticket: first.ticket, verification_inputs: raw)
|
|
52
|
+
mock_processor = {} # This counter is a demo side effect, not real money.
|
|
53
|
+
mock_processor[execution.processor_key] ||= "synthetic-processor-result"
|
|
54
|
+
service.unknown(ticket: first.ticket) # Simulated response loss after dispatch.
|
|
55
|
+
store.close
|
|
56
|
+
# New process/service opens the SAME existing ledger. No create/reset fallback.
|
|
57
|
+
reopened = A::SQLiteStore.new(path: path)
|
|
58
|
+
recovered = A::Service.new(store: reopened)
|
|
59
|
+
pending = recovered.lookup(**scope)
|
|
60
|
+
raise "unknown attempt reopened" unless pending.status == :unknown && pending.ticket.nil? &&
|
|
61
|
+
pending.processor_key == execution.processor_key
|
|
62
|
+
puts "After reopen=unknown; original processor key available for QUERY; mock dispatches=#{mock_processor.size}"
|
|
63
|
+
# Delayed authentic Receipt can resolve an unknown attempt after Mandate expiry.
|
|
64
|
+
receipt = M::PaymentReceipt.sign(closed_sd_jwt: execution.closed_sd_jwt, issuer: "processor-A",
|
|
65
|
+
payment_id: "synthetic-payment-1", outcome: "Success", issued_at: NOW + 120,
|
|
66
|
+
psp_confirmation_id: "synthetic-psp", network_confirmation_id: "synthetic-network",
|
|
67
|
+
signer: signer.call(merchant), public_key_pem: merchant.public_to_pem)
|
|
68
|
+
final = recovered.reconcile(**scope, receipt_jwt: receipt.jwt, verified_at: NOW + 120)
|
|
69
|
+
raise "Receipt recovery failed" unless final.status == :receipt_success && final.ticket.nil? &&
|
|
70
|
+
final.reference == first.reference
|
|
71
|
+
puts "Delayed original-wire Receipt=receipt_success; reconciliation grants no Ticket"
|
|
72
|
+
reopened.close
|
|
73
|
+
end
|
|
74
|
+
puts "Synthetic temporary demo only. Durable reservation is not settlement or external exactly-once; no payment performed."
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
PaymentAcceptanceExample.run if $PROGRAM_NAME == __FILE__
|