This repository is intended for users who are testing their connectivity and interaction with the ClearBank API and webhooks.
It contains an example .NET 8 application that demonstrates how to make a call to the ClearBank API and how to receive, validate and respond to webhooks using minimal APIs.
Please note that the code in this repository is not production ready and has been simplified for brevity.
The application has the following minimal API endpoints:
POST /sample/apito make an API request to thePOST /v1/testendpoint in the ClearBank API.POST /sample/webhookto receive webhooks.POST /webhooktrigger/triggerto simulate sending a webhook (for testing purposes).
It does payload signing for API calls and signature verification for webhooks.
To be able to run the application and receive webhooks, you will need:
You will need:
- To generate a public and private key pair (PKCS#8 format), this can be done using open source tools such as openssl.
- To generate a Certificate Signing Request (CSR) using your private key which was created in the previous step. The CSR should be created in PKCS#10 format.
- An API token which can be generated by uploading your CSR file on the
Certificates and Tokenspage of the ClearBank Portal
Copy your API token, private key, and public key into the AuthProfile configuration in the Startup.cs file.
dotnet runApplication starts listening on port 5000.
You can test the API endpoint by running the following command, which will use the contents of the test.json file as the body of the request:
curl.exe --location --request POST "http://localhost:5000/sample/api" --header "Content-Type: application/json" --data-binary "@test.json"You will receive the request body and the correlation ID as a response.
To test webhooks functionality, you can use the webhook trigger endpoint to simulate sending a simplified webhook to the webhooks receiver endpoint:
curl.exe --location --request POST "http://localhost:5000/webhooktrigger/trigger" --header "Content-Type: application/json" --data-binary "@test.json"This will simulate sending a webhook to the /sample/webhook endpoint and you will see the following output in the console:
Received webhook: test.webhook, payload: {"FieldName":"test"}