The protocol will allow for continuous streaming of payments until the merchant decides to stop the stream. The operator will track the streaming status and amounts, and the merchant can end the stream at any time.
Key Components
Operator: Manages the streaming money protocol and handles payment intents.
StreamIntent: Represents an intent to start a streaming payment between two parties.
PaymentMethod: Defines various payment methods such as UPI, IMPS, etc.
WebSocket: Provides real-time updates to both the merchant and the customer.
Security: Ensures all transactions and communications are secure.
API Specifications
1. Create StreamIntent
Endpoint: POST /stream-intent
Description: Creates a new stream intent for a payment.
Parameters:
amount_per_interval (required): The amount to be transferred per interval (e.g., per minute).
currency (required): The currency code (e.g., INR).
payment_method (required): The payment method (UPI, IMPS, WALLET...).
merchant_id (required): The identifier for the merchant.
customer_id (required): The identifier for the customer.
callback_url (optional): The URL to notify the merchant of the payment status.
Response:
stream_intent_id: Unique identifier for the stream intent.
payment_details: Details or URL for initiating the payment stream.
2. Get StreamIntent Status
Endpoint: GET /stream-intent/:id
Description: Retrieves the status of a stream intent.
Parameters:
id (required): Unique identifier for the stream intent.
Response:
stream_intent_id: Unique identifier for the stream intent.
status: Status of the stream intent (e.g., ACTIVE, PAUSED, COMPLETED, FAILED).
amount: The total amount involved in the stream.
payment_method: The payment method used.
transaction_id: The transaction ID from the payment network.
3. Update StreamIntent (Pause/Resume/Stop)
Endpoint: PATCH /stream-intent/:id
Description: Updates the status of a stream intent.
Parameters:
id (required): Unique identifier for the stream intent.
action (required): The action to perform (PAUSE, RESUME, STOP).
Response:
stream_intent_id: Unique identifier for the stream intent.
status: Updated status of the stream intent (e.g., PAUSED, RESUMED, STOPPED).
4. WebSocket for Real-Time Updates
WebSocket Endpoint: /ws
Description: Provides real-time updates on the status of the stream intents.
Implementation in Node.js
Below is the Node.js implementation of the streaming money protocol with WebSocket support: