fix(paperfly): send paperflykey + Basic Auth on both create & track; v2.3.1
This commit is contained in:
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "aura-courier-mcp",
|
"name": "aura-courier-mcp",
|
||||||
"version": "2.3.0",
|
"version": "2.3.1",
|
||||||
"description": "Universal Bangladesh courier MCP server — Steadfast, Pathao, RedX & Paperfly with a built-in fraud-risk engine — for Claude, Antigravity, Cursor & n8n AI agents. Runs as a local npx (STDIO) server or a remote HTTP endpoint.",
|
"description": "Universal Bangladesh courier MCP server — Steadfast, Pathao, RedX & Paperfly with a built-in fraud-risk engine — for Claude, Antigravity, Cursor & n8n AI agents. Runs as a local npx (STDIO) server or a remote HTTP endpoint.",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ export class PaperflyAdapter implements CourierAdapter {
|
|||||||
this.username = username;
|
this.username = username;
|
||||||
this.password = password;
|
this.password = password;
|
||||||
this.storeName = storeName;
|
this.storeName = storeName;
|
||||||
this.enabled = Boolean(apiKey && storeName);
|
this.enabled = Boolean(apiKey && username && password);
|
||||||
this.client = axios.create({
|
this.client = axios.create({
|
||||||
baseURL: baseUrl,
|
baseURL: baseUrl,
|
||||||
timeout: 15000,
|
timeout: 15000,
|
||||||
@@ -36,7 +36,10 @@ export class PaperflyAdapter implements CourierAdapter {
|
|||||||
|
|
||||||
async createParcel(req: ParcelCreateRequest): Promise<ParcelResponse> {
|
async createParcel(req: ParcelCreateRequest): Promise<ParcelResponse> {
|
||||||
if (!this.enabled) {
|
if (!this.enabled) {
|
||||||
throw new Error("Paperfly credentials (paperflykey + store name) are not configured.");
|
throw new Error("Paperfly credentials (paperflykey + merchant username & password) are not configured.");
|
||||||
|
}
|
||||||
|
if (!this.storeName) {
|
||||||
|
throw new Error("Paperfly store name is required to create a parcel.");
|
||||||
}
|
}
|
||||||
const payload = {
|
const payload = {
|
||||||
merchantOrderReference: req.invoice,
|
merchantOrderReference: req.invoice,
|
||||||
@@ -50,6 +53,7 @@ export class PaperflyAdapter implements CourierAdapter {
|
|||||||
};
|
};
|
||||||
const response = await this.client.post("/merchant/api/service/new_order_v2.php", payload, {
|
const response = await this.client.post("/merchant/api/service/new_order_v2.php", payload, {
|
||||||
headers: { paperflykey: this.apiKey },
|
headers: { paperflykey: this.apiKey },
|
||||||
|
auth: { username: this.username, password: this.password },
|
||||||
});
|
});
|
||||||
const data = response.data;
|
const data = response.data;
|
||||||
const ok = data?.success;
|
const ok = data?.success;
|
||||||
@@ -82,7 +86,7 @@ export class PaperflyAdapter implements CourierAdapter {
|
|||||||
const response = await this.client.post(
|
const response = await this.client.post(
|
||||||
"/API-Order-Tracking",
|
"/API-Order-Tracking",
|
||||||
{ ReferenceNumber: trackingCode },
|
{ ReferenceNumber: trackingCode },
|
||||||
{ auth: { username: this.username, password: this.password } }
|
{ headers: { paperflykey: this.apiKey }, auth: { username: this.username, password: this.password } }
|
||||||
);
|
);
|
||||||
const data = response.data;
|
const data = response.data;
|
||||||
const st = data?.success?.trackingStatus?.[0] || {};
|
const st = data?.success?.trackingStatus?.[0] || {};
|
||||||
|
|||||||
Reference in New Issue
Block a user