Closed DanielePalombo closed 2 years ago
Bolt team provided us an API to set the webhook. The following documentation can be opened with swagger
openapi: 3.0.1
info:
title: Bolt Webhook Config API
description: This is a set of APIs to configure your webhooks with Bolt.
version: 1.0.0
servers:
- url: https://api.bolt.com/
- url: http://api.bolt.com/
tags:
- name: webhooks
description: Everything about your webhooks with Bolt.
paths:
/v1/webhooks:
post:
tags:
- webhooks
summary: Add a new Bolt Webhook.
description: Create a new Webhook to receive notifications from Bolt about various
events, such as transaction status.
operationId: createWebhook
requestBody:
description: Webhook to be added to receive notifications.
content:
application/json:
schema:
oneOf:
- $ref: '#/components/schemas/EventGroupCreateWebhook'
- $ref: '#/components/schemas/EventsArrayCreateWebhook'
required: true
responses:
200:
description: successful operation
content:
application/json:
schema:
$ref: '#/components/schemas/Webhook'
400:
description: BAD REQUEST. Request is malformed or invalid values are detected.
division_id could be invalid.
content:
application/json:
schema:
$ref: '#/components/schemas/DefaultApiResponse'
403:
description: FORBIDDEN. Not authorized to create a webhook for this entity.
content:
application/json:
schema:
$ref: '#/components/schemas/DefaultApiResponse'
security:
- api_key: []
x-codegen-request-body-name: body
components:
schemas:
BaseCreateWebhook:
required:
- division_id
- url
type: object
properties:
division_id:
type: string
description: The unique public ID associated with the merchant's
Bolt Account division.
example: 4ab56ad7865ada4ad32
url:
type: string
description: The full URL to receive webhook notifications.
example: https://eva-nerv.shop.com/path/to/hook
EventsArrayCreateWebhook:
allOf:
- $ref: '#/components/schemas/BaseCreateWebhook'
- type: object
properties:
events:
type: array
description: 'Pick a list of notification events to subscribe to.'
items:
$ref: '#/components/schemas/Event'
EventGroupCreateWebhook:
allOf:
- $ref: '#/components/schemas/BaseCreateWebhook'
- type: object
properties:
event_group:
type: string
description: 'all: subscribe to all events and future new events.'
enum:
- all
Event:
type: string
description: Events the webhook will notify the url about.
enum:
- payment
- credit
- capture
- void
- auth
- pending
- rejected_irreversible
- rejected_reversible
- no_op
- failed_payment
- newsletter_subscription
- risk_insights
- credit_card_deleted
Webhook:
required:
- created_at
- subscribe_to_all_events
- events
- url
- webhook_id
type: object
properties:
webhook_id:
type: string
description: A unique string webhook ID. This will be used for modify/delete
operations as well.
example: wh_za7VbYcSQU2zRgGQXQAm-g
DefaultApiResponse:
type: object
properties:
result:
type: object
properties:
success:
type: boolean
example: false
errors:
type: array
items:
type: object
properties:
code:
type: integer
format: int32
example: 1006
message:
type: string
example: detailed error message.
securitySchemes:
api_key:
type: apiKey
name: X-API-KEY
in: header
At there moment there is no way to know if the webhook is already set or not.
We'd like to build towards the ideal and most frictionless experience, to achieve that goal it would be nice to allow solidus to set webhook URLs via API.
My proposal is to add a link on the BoltConfiguration page that calls the Bolt API endpoint and create a webhook to the provided route url.