pay_offer
Process payments for specific offers by submitting offer_id and l402_offer details. Returns payment status; redirect users to Fewsats for payment review if required.
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 |
|---|---|---|---|
| l402_offer | Yes | ||
| offer_id | Yes |
Implementation Reference
- src/fewsats_mcp/server.py:28-50 (handler)The primary handler for the 'pay_offer' MCP tool. This async function is decorated with @mcp.tool(), defining its input parameters (offer_id: str, l402_offer: dict), detailed schema in docstring, and delegates execution to Fewsats().pay_offer, handling the response.@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:9-11 (helper)Shared helper function used by the pay_offer handler (and other tools) to standardize HTTP response handling from the Fewsats API.def handle_response(response): try: return response.status_code, response.json() except: return response.status_code, response.text
- src/fewsats_mcp/server.py:100-101 (registration)The main function that runs the MCP server, thereby registering and serving all tools including 'pay_offer' via the FastMCP instance.def main(): mcp.run(transport='stdio')