merchant

Merchant backend to process payments, run by merchants
Log | Files | Refs | Submodules | README | LICENSE

commit 32db715dcd16aa3ab72c61c4961351906a3a7e76
parent 5a901f14331d6a10de2221df3b162776fc6eb99d
Author: Christian Grothoff <christian@grothoff.org>
Date:   Wed, 21 Dec 2022 13:28:30 +0100

new webhook pending table

Diffstat:
Msrc/backenddb/merchant-0004.sql | 38++++++++++++++++++++++++++++++++++----
1 file changed, 34 insertions(+), 4 deletions(-)

diff --git a/src/backenddb/merchant-0004.sql b/src/backenddb/merchant-0004.sql @@ -47,8 +47,6 @@ COMMENT ON COLUMN merchant_template.image COMMENT ON COLUMN merchant_template.template_contract IS 'The template contract will contains some additional information.'; -COMMIT; - CREATE TABLE IF NOT EXISTS merchant_webhook (webhook_serial BIGINT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY @@ -67,12 +65,44 @@ COMMENT ON TABLE merchant_webhook COMMENT ON COLUMN merchant_webhook.event_type IS 'Event of the webhook'; COMMENT ON COLUMN merchant_webhook.url - IS 'URL use by the customer'; + IS 'URL to make the request to'; COMMENT ON COLUMN merchant_webhook.http_method IS 'http method use by the merchant'; COMMENT ON COLUMN merchant_webhook.header_template - IS 'Header of the webhook'; + IS 'Template for the header of the webhook, to be modified based on trigger data'; COMMENT ON COLUMN merchant_webhook.body_template + IS 'Template for the body of the webhook, to be modified based on trigger data'; + + +CREATE TABLE IF NOT EXISTS merchant_pending_webhooks + (webhook_pending_serial BIGINT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY + ,merchant_serial BIGINT NOT NULL + REFERENCES merchant_instances (merchant_serial) ON DELETE CASCADE + ,webhook_serial BIGINT NOT NULL + REFERENCES merchant_webhook (webhook_serial) ON DELETE CASCADE + ,retries INT4 NOT NULL DEFAULT(0) + ,next_attempt INT8 NOT NULL DEFAULT(0) + ,url VARCHAR NOT NULL + ,http_method VARCHAR NOT NULL + ,header VARCHAR + ,body VARCHAR + ,UNIQUE (merchant_serial, webhook_pending_serial) + ); +COMMENT ON TABLE merchant_pending_webhooks + IS 'webhooks that still need to be executed by the merchant'; +COMMENT ON COLUMN merchant_pending_webhooks.url + IS 'URL to make the request to'; +COMMENT ON COLUMN merchant_pending_webhooks.webhook_id + IS 'Reference to the configured webhook template'; +COMMENT ON COLUMN merchant_pending_webhooks.retries + IS 'How often have we tried this request so far'; +COMMENT ON COLUMN merchant_pending_webhooks.next_attempt + IS 'Time when we should make the next request to the webhook'; +COMMENT ON COLUMN merchant_pending_webhooks.http_method + IS 'http method use for the webhook'; +COMMENT ON COLUMN merchant_pending_webhooks.header_template + IS 'Header of the webhook'; +COMMENT ON COLUMN merchant_pending_webhooks.body_template IS 'Body of the webhook'; COMMIT;