Class: Blockchain0x::Resources::PaymentRequests
- Inherits:
-
Object
- Object
- Blockchain0x::Resources::PaymentRequests
- Defined in:
- lib/blockchain0x/resources/payment_requests.rb
Overview
PaymentRequestsResource is ‘client.payment_requests.*`.
Instance Method Summary collapse
-
#initialize(client) ⇒ PaymentRequests
constructor
A new instance of PaymentRequests.
-
#settle(payment_request_id, body) ⇒ Hash
Settle a payment request with the on-chain proof tuple.
Constructor Details
#initialize(client) ⇒ PaymentRequests
Returns a new instance of PaymentRequests.
40 41 42 |
# File 'lib/blockchain0x/resources/payment_requests.rb', line 40 def initialize(client) @client = client end |
Instance Method Details
#settle(payment_request_id, body) ⇒ Hash
Settle a payment request with the on-chain proof tuple.
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/blockchain0x/resources/payment_requests.rb', line 55 def settle(payment_request_id, body) if payment_request_id.nil? || payment_request_id.to_s.empty? raise ArgumentError, 'payment_request_id is required' end wire_body = if body.respond_to?(:to_h_wire) body.to_h_wire else # Accept the canonical camelCase shape verbatim - the # x402 server adapter already passes this exact shape. body.to_h.transform_keys(&:to_s) end @client.post("/v1/payment-requests/#{payment_request_id}/settle", body: wire_body) end |