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
So, something goes wrong and the WIX runtime fails to import it properly and I am not sure what to do.
Product:
Wix Studio