Class: Portage::Ucp::PaymentEnrollment

Inherits:
Data
  • Object
show all
Defined in:
lib/portage/ucp/value_objects.rb

Overview

Portage extension (see Adapter#create_payment_enrollment / #get_payment_enrollment and Capabilities::PAYMENT_ENROLLMENT) — no schemas/ counterpart, not part of the UCP spec. Card entry never happens in this process: setup_url is a gateway-hosted page the human completes out-of-band; payment_token only appears once status reaches "complete", and is the same opaque string complete_checkout's payment_token: expects (never a raw PAN — PaymentTokenGuard rejects those regardless of source). See docs/plans/agentic-payments.md Phase 1. mandate: (design-log §33/Phase B) — an optional Ap2::PaymentMandate an adapter that received one at enrollment time can carry back on the enrollment it returns. Safe to add here (unlike Checkout/Order, which are schema-validated against UCP's own JSON schemas) because payment_enrollment is a Portage extension with no schemas/ counterpart to conflict with — see rspec.rb's comment on that.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id:, status:, setup_url: nil, payment_token: nil, expires_at: nil, mandate: nil) ⇒ PaymentEnrollment

Returns a new instance of PaymentEnrollment.



564
# File 'lib/portage/ucp/value_objects.rb', line 564

def initialize(id:, status:, setup_url: nil, payment_token: nil, expires_at: nil, mandate: nil) = super

Instance Attribute Details

#expires_at ⇒ Object (readonly)

Returns the value of attribute expires_at

Returns:

  • (Object) —

    the current value of expires_at



563
564
565
# File 'lib/portage/ucp/value_objects.rb', line 563

def expires_at
  @expires_at
end

#id ⇒ Object (readonly)

Returns the value of attribute id

Returns:

  • (Object) —

    the current value of id



563
564
565
# File 'lib/portage/ucp/value_objects.rb', line 563

def id
  @id
end

#mandate ⇒ Object (readonly)

Returns the value of attribute mandate

Returns:

  • (Object) —

    the current value of mandate



563
564
565
# File 'lib/portage/ucp/value_objects.rb', line 563

def mandate
  @mandate
end

#payment_token ⇒ Object (readonly)

Returns the value of attribute payment_token

Returns:

  • (Object) —

    the current value of payment_token



563
564
565
# File 'lib/portage/ucp/value_objects.rb', line 563

def payment_token
  @payment_token
end

#setup_url ⇒ Object (readonly)

Returns the value of attribute setup_url

Returns:

  • (Object) —

    the current value of setup_url



563
564
565
# File 'lib/portage/ucp/value_objects.rb', line 563

def setup_url
  @setup_url
end

#status ⇒ Object (readonly)

Returns the value of attribute status

Returns:

  • (Object) —

    the current value of status



563
564
565
# File 'lib/portage/ucp/value_objects.rb', line 563

def status
  @status
end

Instance Method Details

#to_wire_h ⇒ Object



566
567
568
569
570
571
572
573
# File 'lib/portage/ucp/value_objects.rb', line 566

def to_wire_h
  h = { "id" => id, "status" => status }
  h["setup_url"] = setup_url if setup_url
  h["payment_token"] = payment_token if payment_token
  h["expires_at"] = expires_at if expires_at
  h["mandate"] = mandate.to_wire_h if mandate
  h
end