Can I use paypack with typescript and make tests for it

I am trying to integrate paypack in my nodejs app with typescript, but so far I am having trouble

  1. When I build my app I get this error :
    node_modules/paypack-js/index.d.ts:118:14 - error TS2395: Individual declarations in merged declaration ‘Paypack’ must be all exported or all local.

118 export class Paypack {

node_modules/paypack-js/index.d.ts:133:15 - error TS2395: Individual declarations in merged declaration ‘Paypack’ must be all exported or all local.

133 declare const Paypack: PaypackStatic;

  1. I tried making tests for cashin, cashout and transaction but it isn’t working as it can be mocked or stubbed. I was wondering if you have a way around it

  1. I can’t import paypackJs with import statement, I am using require for it to be imported with all attributes available, and it is somehow affecting my codebase.


Hello @AngeloChristian1, we haven’t met this challenge so far. This happens because mainly paypack-js was built without typescript in mind and we will be refactoring it in the coming days.

Can you create a minimal example that can reproduce this and share it with us? We can pinpoint exactly where this issue is coming from.

The error was occuring in the node_modules/paypack-js and it was because of the way some of the functions and classes were exported as there were not adhering with typescript fundamentals.
But I managed to go around it by using the paypack API and it seems to be working fine. But I have an issue on webhooks as I have created them and also connected one from suceesfully. With help of you well detailed documentation but the isssue is that I can not get data that is being send by the weebhook. I can see it on the but I can’t see it in my app

    export const webHook = async(req: any, res: any) => {

      const requestHash = req.get("X-Paypack-Signature");
      const secret = process.env.PAYPACK_WEBHOOK_KEY;

      const hash = Crypto.createHmac("sha256", secret)
    .update(typeof req.rawBody === "undefined" ? "" : req.rawBody)
    .update( req.rawBody)
      if (hash === requestHash || req.method !== "HEAD") {
        console.log("Webhook is originating from Paypack");

        try {
          const { data } = req.body;
          const orderRef = data.ref;
      console.log("raw body:",req.rawBody)
          const order = await Order.findOne({ where: { reference: orderRef } });
          if (!order) {
            console.error(`Order with reference ${orderRef} not found.`);
            return res.status(400).json({ message: 'Invalid order reference' });
          if (data.status === 'successful') {
            order.status = 'COMPLETED'; 
            console.log(`Order ${} status updated to ${order.status}`);
          } else {
            console.log(`Payment for order ${} failed.`);
          res.status(200).json({ message: 'Webhook processed successfully' });
        } catch (error) {
          console.error('Error processing webhook:', error);
          res.status(500).json({ message: 'Internal Server Error' });
        throw new Error("Signature is Invalid")

This is a simplified version of my code which is exposed on the route /webhook
but when I make a payment nothing happens and when I run it I get this error

    "code": 500,
    "message": "The \"data\" argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received undefined",
    "error": {
        "code": "ERR_INVALID_ARG_TYPE"

If there is a way to help me you can and if you need any clarification please feel free to reach out

Regards. provides a cli to forward your localhost to its provided address. Make sure the app is forwarded correctly and with the right port your app is listening to.

If this fails we can schedule a time to resolve this issue.