pay_offer
Process payments for specific offers using L402 payment protocol data. Submit offer details and payment context to complete transactions through the Fewsats payment system.
Instructions
Pays an offer_id from the l402_offers.
The l402_offer parameter must be a dict with this structure:
{
'offers': [
{
'id': 'test_offer_2', # String identifier for the offer
'amount': 1, # Numeric cost value
'currency': 'usd', # Currency code
'description': 'Test offer', # Text description
'title': 'Test Package' # Title of the package
}
],
'payment_context_token': '60a8e027-8b8b-4ccf-b2b9-380ed0930283', # Payment context token
'payment_request_url': 'https://api.fewsats.com/v0/l402/payment-request', # Payment URL
'version': '0.2.2' # API version
}
Returns payment status response.
If payment status is `needs_review` inform the user he will have to approve it at app.fewsats.com
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| offer_id | Yes | ||
| l402_offer | Yes |
Implementation Reference
- src/fewsats_mcp/server.py:28-50 (handler)MCP tool handler for 'pay_offer': decorated function that executes the payment by delegating to Fewsats.pay_offer and handles the response. Includes input schema in docstring.@mcp.tool() async def pay_offer(offer_id: str, l402_offer: dict) -> str: """Pays an offer_id from the l402_offers. The l402_offer parameter must be a dict with this structure: { 'offers': [ { 'id': 'test_offer_2', # String identifier for the offer 'amount': 1, # Numeric cost value 'currency': 'usd', # Currency code 'description': 'Test offer', # Text description 'title': 'Test Package' # Title of the package } ], 'payment_context_token': '60a8e027-8b8b-4ccf-b2b9-380ed0930283', # Payment context token 'payment_request_url': 'https://api.fewsats.com/v0/l402/payment-request', # Payment URL 'version': '0.2.2' # API version } Returns payment status response. If payment status is `needs_review` inform the user he will have to approve it at app.fewsats.com""" return handle_response(Fewsats().pay_offer(offer_id, l402_offer))
- src/fewsats_mcp/server.py:28-28 (registration)Registration of the 'pay_offer' tool using the @mcp.tool() decorator.@mcp.tool()
- src/fewsats_mcp/server.py:30-49 (schema)Input schema and usage description for the l402_offer parameter in the pay_offer tool docstring."""Pays an offer_id from the l402_offers. The l402_offer parameter must be a dict with this structure: { 'offers': [ { 'id': 'test_offer_2', # String identifier for the offer 'amount': 1, # Numeric cost value 'currency': 'usd', # Currency code 'description': 'Test offer', # Text description 'title': 'Test Package' # Title of the package } ], 'payment_context_token': '60a8e027-8b8b-4ccf-b2b9-380ed0930283', # Payment context token 'payment_request_url': 'https://api.fewsats.com/v0/l402/payment-request', # Payment URL 'version': '0.2.2' # API version } Returns payment status response. If payment status is `needs_review` inform the user he will have to approve it at app.fewsats.com"""