wl-online-payments-direct / sdk-client-js

Other
3 stars 2 forks source link

Payment product displayHints logo has wrong url #5

Closed TheoGautier closed 2 years ago

TheoGautier commented 2 years ago

Hi,

I have troubles retrieving a paymentProduct logo asset using the SDK. Sdk version:

onlinepayments-sdk-client-js: 2.0.0

Here is my code sample:

const paymentProductId;
const paymentDetails = {
    "totalAmount": props.amount * 100, // in cents
    "countryCode": "FR",
    "locale": "fr_FR",
    "isRecurring": false, // set if recurring
    "currency": "EUR" // set currency, see dropdown
};

const iinDetails = await session.getIinDetails(cardNumber, paymentDetails);
const paymentProductId = iinDetails.paymentProductId;
const paymentProduct = await session.getPaymentProduct(paymentProductId, paymentDetails);
return paymentProduct.displayHints.logo;
}

Value retrieved is a concatenation of assetUrl and logo displayHint retrieved from API:

It seems session assetUrl (asset base url) is not synced with paymentProduct logo asset path. The inner code of the sdk has this:

var formatImageUrl = function (url, imageUrl) {
    if (imageUrl) {
        url = formatUrl(url);
        // _cleanJSON can be called multiple times with the same data (which is cached between calls).
        // Don't prepend the url after the first time.
        if (startsWith(imageUrl, url)) {
            return imageUrl;
        }
        return url + imageUrl;
    }
};

(url is session.assetUrl, formatUrl just adds a trailing "/" at the end of the base path). It seems to me that imageUrl should hence just be an image path, and not an absolute path.

Can you please investigate this? I found a temp hack, which is paymentProduct.displayHints.logo.replaceAll(session.assetUrl + "/", "") Thanks, and have a nice day.

worldline-direct-support-team commented 2 years ago

Hello Theo,

Thank you for reporting the issue. We will make sure to resolve the issue so that SDK and server are aligned again.

Kind regards, Worldline support

worldline-direct-support-team commented 2 years ago

Hello Theo,

A fix for this issue has been released in version 2.0.1 of the SDK.

Kind regards, Worldline support