SOAP createClientAsync raises error "Cannot read properties of undefined (reading 'createClientAsync')"

Question:
I have a WIX website, and I need to integrate custom payment systems from my bank provider. I have the following js module that does the heavy-lifting. Here’s a the portion of the code that fails

import soap from 'soap';

export async function createClient(partnerKey) {

    const exchangeServiceUrl = 'https://my.bank.service.url';
    // Create the SOAP client
    const exchangeServiceClient = await soap.createClientAsync(exchangeServiceUrl);
    return exchangeServiceClient;

}

I am using the soap npm client.

When I run this function in a standalone node module

import { createClient } from './ameria.js';
let client = await createClient('KEY');

Everything works as expected. Client is initialized and I am able to execute all of the SOAP requests. However, when I try to run the same code inside a WIX Web module like this

import { getSecret } from 'wix-secrets-backend';
import { Permissions, webMethod } from "wix-web-module";
import { createClient } from './ameria.js';

export const initPayment = webMethod(Permissions.Anyone, async (amount, currency, lang) => {

   let client = await createClient('KEY');
......
});

I receive the following error

"Cannot read properties of undefined (reading 'createClientAsync')"

I have installed the soap node module in my web application
image

So, something goes wrong and the WIX runtime fails to import it properly and I am not sure what to do.

Product:
Wix Studio

I am not familiar with this npm package, but not all npm packages are compatible with the Wix Studio environment.

There is a section here on compatibiltiy About npm Packages

Another path to consider for integrating external payment providers is to use the service plugin. Not sure if this could be accomplished without use of this particular package but take a look https://dev.wix.com/docs/velo/api-reference/wix-payment/service-plugin-spi/wix-payments/payment-provider/introduction

1 Like

Dear @amandam

Thanks for getting back. Yeah, that’s the conclusion I came to. I will try to find an alternative package.

As for payment provider plugin, that’s also something new to me (I just came to WIX). I will investigate that direction as well.

1 Like