Class: Portage::Ucp::Ap2::PaymentMandate
- Inherits:
-
Data
- Object
- Data
- Portage::Ucp::Ap2::PaymentMandate
- Defined in:
- lib/portage/ucp/ap2/mandate.rb
Overview
A typed shape for an AP2 payment mandate (design-log §33/Phase B,
citing design-log.md:1984-2117's already-confirmed AP2 gap) — the
cart/intent authorization a shopper's agent presents alongside (or
instead of) a bare payment_token. amount/currency mirror the
minor-unit-integer convention Total#amount already uses elsewhere
in this gem (see value_objects.rb).
kid identifies which of the issuing agent's keys signature was
made with — optional (defaults nil) so existing callers that only
ever exercised shape validation keep constructing a PaymentMandate
without it; it's required the moment a caller actually wants
Ap2::MandateSignature/MandateGuard's trusted_keys: to verify the
signature cryptographically. signature itself is still carried
opaquely here — this Data class doesn't verify anything, it's just
the shape; see MandateGuard and Ap2::MandateSignature for the two
tiers of validation (shape-only vs shape+crypto).
Instance Attribute Summary collapse
-
#amount ⇒ Object
readonly
Returns the value of attribute amount.
-
#currency ⇒ Object
readonly
Returns the value of attribute currency.
-
#expires_at ⇒ Object
readonly
Returns the value of attribute expires_at.
-
#kid ⇒ Object
readonly
Returns the value of attribute kid.
-
#merchant ⇒ Object
readonly
Returns the value of attribute merchant.
-
#signature ⇒ Object
readonly
Returns the value of attribute signature.
Instance Method Summary collapse
-
#initialize(kid: nil, **rest) ⇒ PaymentMandate
constructor
A new instance of PaymentMandate.
-
#signing_payload ⇒ Object
The exact bytes Ap2::MandateSignature verifies
signatureagainst — every field butsignatureitself, canonicalized the same way Manifest#sign canonicalizes its own payload (JSON.generate over a fixed-order hash, no key sorting beyond that fixed order, since both sides of a mandate are expected to agree on the field order out of band rather than this gem inventing a JCS-style canonicalization scheme it doesn't need elsewhere). - #to_wire_h ⇒ Object
Constructor Details
#initialize(kid: nil, **rest) ⇒ PaymentMandate
Returns a new instance of PaymentMandate.
23 24 25 |
# File 'lib/portage/ucp/ap2/mandate.rb', line 23 def initialize(kid: nil, **rest) super end |
Instance Attribute Details
#amount ⇒ Object (readonly)
Returns the value of attribute amount
22 23 24 |
# File 'lib/portage/ucp/ap2/mandate.rb', line 22 def amount @amount end |
#currency ⇒ Object (readonly)
Returns the value of attribute currency
22 23 24 |
# File 'lib/portage/ucp/ap2/mandate.rb', line 22 def currency @currency end |
#expires_at ⇒ Object (readonly)
Returns the value of attribute expires_at
22 23 24 |
# File 'lib/portage/ucp/ap2/mandate.rb', line 22 def expires_at @expires_at end |
#kid ⇒ Object (readonly)
Returns the value of attribute kid
22 23 24 |
# File 'lib/portage/ucp/ap2/mandate.rb', line 22 def kid @kid end |
#merchant ⇒ Object (readonly)
Returns the value of attribute merchant
22 23 24 |
# File 'lib/portage/ucp/ap2/mandate.rb', line 22 def merchant @merchant end |
#signature ⇒ Object (readonly)
Returns the value of attribute signature
22 23 24 |
# File 'lib/portage/ucp/ap2/mandate.rb', line 22 def signature @signature end |
Instance Method Details
#signing_payload ⇒ Object
The exact bytes Ap2::MandateSignature verifies signature
against — every field but signature itself, canonicalized the
same way Manifest#sign canonicalizes its own payload (JSON.generate
over a fixed-order hash, no key sorting beyond that fixed order,
since both sides of a mandate are expected to agree on the field
order out of band rather than this gem inventing a JCS-style
canonicalization scheme it doesn't need elsewhere).
39 40 41 42 43 44 |
# File 'lib/portage/ucp/ap2/mandate.rb', line 39 def signing_payload JSON.generate( { "amount" => amount, "currency" => currency, "merchant" => merchant, "expires_at" => expires_at, "kid" => kid } ) end |
#to_wire_h ⇒ Object
27 28 29 30 |
# File 'lib/portage/ucp/ap2/mandate.rb', line 27 def to_wire_h { "amount" => amount, "currency" => currency, "merchant" => merchant, "expires_at" => expires_at, "signature" => signature, "kid" => kid } end |