Platform Webhook Notifications

Webhooks are automated messages sent from our servers to make you aware of various events.

After you've subscribed to a webhook, you can let your app execute code immediately after specific events occur, instead of having to make API calls periodically to check their status.

Available webhooks

Rules

  • You can have multiple subscriptions per each webhook.
  • After 5 failed notifications you will receive an email warning you of the issue.
  • After 15 failed notifications (we couldn’t reach your URL), the hook will be automatically invalidated.
  • The URL that we hook must respond with a 2XX status code within 10 seconds – otherwise it will be considered as a failure
  • You are strongly advised to do a GET on the resource to check its status.

Configure a webhook using the API

Setup new webhook: make a POST /webhooks request:

curl --request POST \
  --url 'https://sandbox.unipaas.com/platform/webhooks' \
  --header 'Accept: application/json' \
  --header 'Content-Type: application/json' \
  --header 'Authorization: Bearer <PLATFORM_SECRET_KEY>' \
  --data-raw '{
  	"webhookName": "authorization/update",
    "email": "[email protected]",
    "url": "https://example.com/webhook" 
   }'

Modify existing webhook: make a PATCH /webhooks/{webhookId} request:

curl --request PATCH \
  --url 'https://sandbox.unipaas.com/platform/webhooks/{webhookId}' \
  --header 'Accept: application/json' \
  --header 'Content-Type: application/json' \
  --header 'Authorization: Bearer <PLATFORM_SECRET_KEY>' \
  --data-raw '{
    "url": "https://example.com/webhook-updated-url" 
   }'

Delete existing webhook: make a DELETE /webhooks/{webhookId} request:

curl --request DELETE \
  --url 'https://sandbox.unipaas.com/platform/webhooks/{webhookId}' \
  --header 'Accept: application/json' \
  --header 'Content-Type: application/json' \
  --header 'Authorization: Bearer <PLATFORM_SECRET_KEY>'

Verifying webhooks

Webhooks created through the API are verified by calculating a digital signature. Each webhook request includes a base64-encoded X-Hmac-SHA256 header, which is generated using the <PLATFORM_SECRET_KEY> along with the data sent in the request.

To verify that the request came from UNIPaaS, compute the HMAC digest according to the following algorithm and compare it to the value in the X-Hmac-SHA256 header. If they match, then you can be sure that the webhook was sent from UNIPaaS.

const express = require('express')
const bodyParser = require('body-parser');
const { createHmac } = require('crypto');
const app = express();

const SECRET = '<PLATFORM_SECRET_KEY>';

app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json());
app.use(bodyParser.raw());

app.post('/webhook', function (req, res) {
  const {headers, body} = req;
  const signedHeader = headers["x-hmac-sha256"];
  const hash = createHmac('sha256', SECRET)
    .update(JSON.stringify(body))
    .digest('hex');
  const buff = new Buffer(hash);
  const calculated =  buff.toString('base64');

  if (calculated === signedHeader) {
    console.log('hook verified successfully')
  }
  else {
    console.log('failed to verify hook!')
  }

  res.send('Hello World')
})

app.listen(8080)

Onboarding

If there are any status changes to a vendor's onboarding, you'll receive a webhook notification to your server, indicating the current status.

Available webhooks:

  • onboarding/update

Please refer to the onboarding Webhook Notifications page to learn more about onboarding webhooks and review examples.

Payin

On every new Authorization or Authorization status change, you will receive a webhook notification to your server.

Available webhooks:

  • authorization/update

The body will include the AuthorizationResult object:

ParameterAlways AvailableTypeDescription
authorizationIdYesStringUnique ID of the Object
authorizationStatusYesEnumThe status of the Authorization. See below detailed information
currencyYesStringThe Currency of the payment
amountYesNumberThe Amount of the payment
orderidYesStringUnique ID from the merchant system
itemsYesObjectThe items of the order per item per vendor
transactionIdYesStringThe transaction ID of the specific payment operation
paymentMethodYesStringThe method of the payment (creditCard, bankTransfer, directDebit, e.t.c)
checkoutIdYesStringUnique ID of the checkout that has been paid
vendorIdYesStringUnique ID of the vendor
paymentOptionYesObjectPayment Option object that could represent card payment:
{ cardAccount: { brand: "VISA" bin: "476134" last4Digits: "1390", issuerCountry: "GB" } }

or bank transfer payment:
{ bankAccount: { brand: "Mock Bank" } }
planIdNoStringUnique ID of the recurring payment plan
subscriptionIdNoStringUnique ID of the recurring subscription
declinedReasonNoStringThe reason why payment has been declined
descriptionNoStringDescription of payment
In most cases value is taken from checkout creation
metadataNoObjectThe custom data that was used during checkout creation (this field can be used to pass some internal data through payment process)
consumerEmailNoStringThe email of buyer that made a payment
consumerIdNoStringUnique ID of the buyer
referenceYesStringUnique ID from the merchant system

Account

Account notifications are created to notify you when your vendor receives money for the first time - creating an automatic account in the accepted currency. Each time an account balance is created or disabled, you'll get a webhook notification to your server, indicating its current status.

Available webhooks:

  • ewallet/create

The body will include the following object:

ParameterAlways AvailableTypeDescription
eWalletIdyesstringAccount unique identifier
vendorIdnostringThe unique ID of the vendor's Account.
If the Account belongs to the platform, it will return null
platformIdyesstringUnique ID of the platform
currencyyesenumUSD, GBP, EUR

Payouts

Payout notifications notify you of every newly created payout and any change in the status of a payout. The webhook notification gets sent to your server.

Available webhooks:

  • payout/update

The body will include the PayoutResult object:

ParameterAlways AvailableTypeDescription
payoutIdyesstring
statusyesEnum
amountyesnumber
currencyyesstring
createdDateyesdate
updatedDateyesdate
targetReferenceIdnostring

🚧

Sending Vendor emails from your system

In case you plan to use these webhook notifications to send emails from your system, you should communicate that to UNIPaaS during your integration, to make sure UNIPaaS emails are disabled.