diff --git a/index.d.ts b/index.d.ts index ca796bf..36404a7 100644 --- a/index.d.ts +++ b/index.d.ts @@ -716,11 +716,11 @@ declare namespace WAWebJS { /** * Gets the order associated with a given message */ - getOrder: () => Order, + getOrder: () => Promise, /** * Gets the payment details associated with a given message */ - getPayment: () => Payment, + getPayment: () => Promise, } /** ID that represents a message */ diff --git a/src/structures/Message.js b/src/structures/Message.js index d8ea5ba..4a0c83c 100644 --- a/src/structures/Message.js +++ b/src/structures/Message.js @@ -487,9 +487,9 @@ class Message extends Base { */ async getOrder() { if (this.type === MessageTypes.ORDER) { - const result = await this.client.pupPage.evaluate((orderId, token) => { - return window.WWebJS.getOrderDetail(orderId, token); - }, this.orderId, this.token); + const result = await this.client.pupPage.evaluate((orderId, token, chatId) => { + return window.WWebJS.getOrderDetail(orderId, token, chatId); + }, this.orderId, this.token, this._getChatId()); if (!result) return undefined; return new Order(this.client, result); } diff --git a/src/util/Injected.js b/src/util/Injected.js index 0169494..49283af 100644 --- a/src/util/Injected.js +++ b/src/util/Injected.js @@ -556,8 +556,9 @@ exports.LoadUtils = () => { return (chat.labels || []).map(id => window.WWebJS.getLabel(id)); }; - window.WWebJS.getOrderDetail = async (orderId, token) => { - return window.Store.QueryOrder.queryOrder(orderId, 80, 80, token); + window.WWebJS.getOrderDetail = async (orderId, token, chatId) => { + const chatWid = window.Store.WidFactory.createWid(chatId); + return window.Store.QueryOrder.queryOrder(chatWid, orderId, 80, 80, token); }; window.WWebJS.getProductMetadata = async (productId) => {