Sellhub API
Payment Plugins
This guide about payment plugins allows you to handle incoming webhooks from various payment gateway providers.
Handle Webhook
POST
Handle an incoming webhook from a payment provider.
Request Parameters
pluginName
: string - The name of the payment pluginstoreId
: string - The ID of the store
Request Body
The request body should contain the raw webhook payload as received from the payment provider.
Example request:
Lua Environment
When working with this API in Lua, the following features and functions are available:
- HTTP Requests: Use the
fetch
function for making HTTP requests. - JSON Parsing: The
dkjson
library is built into the Lua environment. - HMAC Signing: Use the
hmacShaSign
function for creating HMAC signatures. - Logging: Use the
insertLog
function to log messages.
Available Lua Functions
Response
Your Lua should process the webhook and return a response based on the payment plugin's handling of transaction. The response should include:
Required Response
The Invoice ID is required only if the status is pushInvoice
or disputeInvoice
.
status
: Indicates the action to be taken based on the webhookinvoiceId
: The ID of the invoice (if applicable)
Based on the status
, the API will perform one of the following actions:
pushInvoice
: Complete the invoicedisputeInvoice
: Mark the invoice as disputedignore
: No action taken
The webhook will return the response along with the appropriate HTTP status code.
Testing Your Plugin
Before going live, thoroughly test your plugin:
- Simulate webhooks to ensure webhook processes them correctly.
- Test the checkout process to verify payments work as expected.
- Confirm that invoices are updated correctly based on your plugin's responses.
Security Considerations
- Securely store API keys and secrets for your payment provider.
- Validate all incoming data in your Lua functions.
- Implement proper error handling and logging.