Swipelux
Server-side integration

Listen to webhook events

Swipelux provides webhook notifications to keep your service updated about order status changes.

Implementation

Implement a webhook handler

Implement a webhook endpoint handler that can receive POST requests from Swipelux.

For starters, we've prepared example implementations for Node.js, Python, and PHP.

Verify the webhook payload

To ensure webhook payload authenticity, we sign it using JWT (JSON Web Token).

If you're using one of the example implementations, then you can skip this step as they already include the verification logic.

You can verify the signature using our public key available at https://api.swipelux.com/api/merchants/webhookKeys.

// Make sure you've installed the `jose` package
const jose = require('jose');
 
async function getPublicKeys() {
  const response = await fetch(
    "https://api.swipelux.com/api/merchants/webhookKeys"
  );
  const { keys } = await response.json();
  return keys;
}
 
async function verifyWebhookPayload(webhookPayload) {
  const publicKeys = await getPublicKeys();
  const publicKey = await jose.importJWK(publicKeys[0], 'ES256');
 
  const token = `${webhookPayload.protected}.${webhookPayload.payload}.${webhookPayload.signature}`;
  const decoded = await jose.jwtVerify(jwt_token, publicKey);
  return decoded.payload;
}

Handle the webhook payload

Once the payload is verified, you can handle the webhook payload as you see fit.

Use orderId or externalId to locate the order in your system and update its status based on the webhook payload.

The payload is a JSON object that contains the following fields:

PropTypeDefault
status
enum(PROCESSING, SUCCESS, FAILED)
-
externalId?
string
-
orderId
string
-
eventTs
number
-

Start receiving webhook events

Once you've implemented the webhook handler and deployed it somewhere, set up a webhook endpoint URL in the Merchant Panel to start receiving events from us.

Ensure the endpoint is publicly accessible and properly configured.

On this page