This repository is intended for users who are testing their connectivity and interaction with the ClearBank API and webhooks.
It contains an example .NET 5 application that demonstrates how to make a call to the ClearBank API and how to receive, validate and respond to webhooks.
Please note that the code in this repository is not production ready and has been simplified for brevity.
The application has one controller with 2 endpoints:
POST /sample/api
to make an API request to thePOST /v1/test
endpoint in the ClearBank APIPOST /sample/webhook
to receive webhooks from ClearBank
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:
- .NET 5 SDK
- ngrok We have used version 2.3.35
You will need:
- Your private key and a Certificate Signing Request (CSR) created in PKCS #10 format
- An API token, which can be generated by uploading your CSR file on the
Certificates and Tokens
page of the ClearBank Portal - Your public key which can be downloaded from the
Webhook Management
page of the ClearBank Portal
Copy your public key, API token and the ClearBank public key into the SampleController constructor.
dotnet run
Application starts listening on port 5000. You can also test it:
curl.exe --location --request POST "http://localhost:5000/sample/api" --header "Content-Type: application/json" --data-raw "{\"fieldName\" :\"test\"}"
Now set up ngrok
.\ngrok.exe http 5000
You will get an output similar to
Forwarding https://91bf871fa2aa.ngrok.io -> http://localhost:5000
Copy the url and add /sample/webhook
at the end.
The full url will be https://91bf871fa2aa.ngrok.io/sample/webhook
.
On the Webhook Management page of the ClearBank Portal, find the test webhook i.e. FITestEvent, enable it and set the webhook URL.
Click the Test button to receive a webhook in the application and see it in the console:
Received webhook: FITestEvent, payload: Test