@longvansoftware/storefront-js-client 1.6.6 → 1.6.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/config/config.d.ts +2 -0
- package/dist/config/config.js +5 -3
- package/dist/src/graphql/paymentV2/mutations.d.ts +1 -0
- package/dist/src/graphql/paymentV2/mutations.js +9 -0
- package/dist/src/graphql/paymentV2/queries.d.ts +2 -0
- package/dist/src/graphql/paymentV2/queries.js +50 -0
- package/dist/src/lib/SDK.d.ts +3 -0
- package/dist/src/lib/SDK.js +4 -0
- package/dist/src/lib/order/index.d.ts +1 -0
- package/dist/src/lib/order/index.js +13 -0
- package/dist/src/lib/paymentV2/index.d.ts +7 -0
- package/dist/src/lib/paymentV2/index.js +67 -0
- package/dist/src/lib/serviceSDK.d.ts +2 -0
- package/dist/src/lib/serviceSDK.js +55 -0
- package/dist/src/lib/warehouse/index.d.ts +1 -2
- package/dist/src/lib/warehouse/index.js +4 -4
- package/package.json +1 -1
package/dist/config/config.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ export declare const environmentEndpoints: {
|
|
|
11
11
|
computing: string;
|
|
12
12
|
campaign: string;
|
|
13
13
|
image: string;
|
|
14
|
+
paymentV2: string;
|
|
14
15
|
};
|
|
15
16
|
live: {
|
|
16
17
|
product: string;
|
|
@@ -24,5 +25,6 @@ export declare const environmentEndpoints: {
|
|
|
24
25
|
computing: string;
|
|
25
26
|
campaign: string;
|
|
26
27
|
image: string;
|
|
28
|
+
paymentV2: string;
|
|
27
29
|
};
|
|
28
30
|
};
|
package/dist/config/config.js
CHANGED
|
@@ -10,10 +10,11 @@ exports.environmentEndpoints = {
|
|
|
10
10
|
user: "https://user.dev.longvan.vn/user-gateway/graphql",
|
|
11
11
|
payment: "https://portal.dev.longvan.vn/invoice-gateway/graphql",
|
|
12
12
|
service: "https://portal.dev.longvan.vn/service-api/graphql",
|
|
13
|
-
warehouse: "https://portal.dev.longvan.vn/facility-api/public-facility/1.0.0",
|
|
13
|
+
warehouse: "https://portal.dev.longvan.vn/facility-api/public-facility/1.0.0/inventory-item",
|
|
14
14
|
computing: "https://api-gateway.dev.longvan.vn/computing-service/graphql",
|
|
15
15
|
campaign: "https://crm.dev.longvan.vn/campaign-gateway/graphql",
|
|
16
16
|
image: "https://product-service.dev.longvan.vn/product-service/v1/products",
|
|
17
|
+
paymentV2: "https://payment.dev.longvan.vn/graphql"
|
|
17
18
|
},
|
|
18
19
|
live: {
|
|
19
20
|
product: "https://product-service.longvan.vn/product-service/graphql",
|
|
@@ -23,9 +24,10 @@ exports.environmentEndpoints = {
|
|
|
23
24
|
user: "https://user.longvan.vn/user-gateway/graphql",
|
|
24
25
|
payment: "https://portal.longvan.vn/invoice-gateway/graphql",
|
|
25
26
|
service: "https://portal.longvan.vn/service-api/graphql",
|
|
26
|
-
warehouse: "https://portal.longvan.vn/facility-api/public-facility/1.0.0",
|
|
27
|
+
warehouse: "https://portal.longvan.vn/facility-api/public-facility/1.0.0/inventory-item",
|
|
27
28
|
computing: "https://api-gateway.longvan.vn/computing-service/graphql",
|
|
28
29
|
campaign: "https://crm.longvan.vn/campaign-gateway/graphql",
|
|
29
|
-
image: "https://product-service.dev.longvan.vn/product-service/v1/products"
|
|
30
|
+
image: "https://product-service.dev.longvan.vn/product-service/v1/products",
|
|
31
|
+
paymentV2: "https://payment.dev.longvan.vn/graphql"
|
|
30
32
|
},
|
|
31
33
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const CANCEL_PAYMENT: import("graphql").DocumentNode;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CANCEL_PAYMENT = void 0;
|
|
4
|
+
const graphql_tag_1 = require("graphql-tag");
|
|
5
|
+
exports.CANCEL_PAYMENT = (0, graphql_tag_1.gql) `
|
|
6
|
+
mutation CancelPayment($paymentId: String!, $reason: String!) {
|
|
7
|
+
cancelPayment(paymentId: $paymentId, reason: $reason)
|
|
8
|
+
}
|
|
9
|
+
`;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PAYMENT_METHODS = exports.PAYMENTS_BY_ORDERS = void 0;
|
|
4
|
+
const graphql_tag_1 = require("graphql-tag");
|
|
5
|
+
exports.PAYMENTS_BY_ORDERS = (0, graphql_tag_1.gql) `
|
|
6
|
+
query PaymentsByOrders($orderIds: [String!]!) {
|
|
7
|
+
paymentsByOrders(orderIds: $orderIds) {
|
|
8
|
+
methodCode
|
|
9
|
+
partnerCode
|
|
10
|
+
totalAmount
|
|
11
|
+
fee
|
|
12
|
+
discountAmount
|
|
13
|
+
payDate
|
|
14
|
+
payType
|
|
15
|
+
transactionDate
|
|
16
|
+
orderId
|
|
17
|
+
paymentId
|
|
18
|
+
invoiceId
|
|
19
|
+
orderInfo
|
|
20
|
+
orderType
|
|
21
|
+
locale
|
|
22
|
+
merchantIp
|
|
23
|
+
extraData
|
|
24
|
+
storeID
|
|
25
|
+
bankCode
|
|
26
|
+
appUser
|
|
27
|
+
phone
|
|
28
|
+
email
|
|
29
|
+
address
|
|
30
|
+
statusCode
|
|
31
|
+
statusDescription
|
|
32
|
+
transactionId
|
|
33
|
+
createBy
|
|
34
|
+
methodDescription
|
|
35
|
+
methodMapping
|
|
36
|
+
baseMethodCode
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
`;
|
|
40
|
+
exports.PAYMENT_METHODS = (0, graphql_tag_1.gql) `
|
|
41
|
+
query PaymentMethods($partnerCode: String) {
|
|
42
|
+
paymentMethods(partnerCode: $partnerCode) {
|
|
43
|
+
id
|
|
44
|
+
code
|
|
45
|
+
name
|
|
46
|
+
description
|
|
47
|
+
image
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
`;
|
package/dist/src/lib/SDK.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ import { WarehouseService } from "../lib/warehouse/index";
|
|
|
9
9
|
import { ComputingService } from "../lib/computing/index";
|
|
10
10
|
import { CampaignService } from "./campaign";
|
|
11
11
|
import { ImageService } from "./image";
|
|
12
|
+
import { PaymentServiceV2 } from "./paymentV2";
|
|
12
13
|
export interface Endpoints {
|
|
13
14
|
product: string;
|
|
14
15
|
crm: string;
|
|
@@ -21,6 +22,7 @@ export interface Endpoints {
|
|
|
21
22
|
computing: string;
|
|
22
23
|
campaign: string;
|
|
23
24
|
image: string;
|
|
25
|
+
paymentV2: string;
|
|
24
26
|
}
|
|
25
27
|
export declare class SDK {
|
|
26
28
|
orgId: string;
|
|
@@ -37,6 +39,7 @@ export declare class SDK {
|
|
|
37
39
|
computing: ComputingService;
|
|
38
40
|
campaign: CampaignService;
|
|
39
41
|
image: ImageService;
|
|
42
|
+
paymentV2: PaymentServiceV2;
|
|
40
43
|
token: string | null;
|
|
41
44
|
constructor(orgId: string, storeId: string, environment: "dev" | "live");
|
|
42
45
|
setToken(token: string): void;
|
package/dist/src/lib/SDK.js
CHANGED
|
@@ -14,6 +14,7 @@ const index_8 = require("../lib/warehouse/index");
|
|
|
14
14
|
const index_9 = require("../lib/computing/index");
|
|
15
15
|
const campaign_1 = require("./campaign");
|
|
16
16
|
const image_1 = require("./image");
|
|
17
|
+
const paymentV2_1 = require("./paymentV2");
|
|
17
18
|
class SDK {
|
|
18
19
|
constructor(orgId, storeId, environment) {
|
|
19
20
|
this.orgId = orgId;
|
|
@@ -32,6 +33,7 @@ class SDK {
|
|
|
32
33
|
this.computing = new index_9.ComputingService(endpoints.computing, orgId, storeId);
|
|
33
34
|
this.campaign = new campaign_1.CampaignService(endpoints.campaign, orgId, storeId);
|
|
34
35
|
this.image = new image_1.ImageService(endpoints.image, orgId, storeId);
|
|
36
|
+
this.paymentV2 = new paymentV2_1.PaymentServiceV2(endpoints.paymentV2, orgId, storeId);
|
|
35
37
|
// Initialize other services here
|
|
36
38
|
}
|
|
37
39
|
setToken(token) {
|
|
@@ -47,6 +49,7 @@ class SDK {
|
|
|
47
49
|
this.warehouse.setToken(token);
|
|
48
50
|
this.computing.setToken(token);
|
|
49
51
|
this.image.setToken(token);
|
|
52
|
+
this.paymentV2.setToken(token);
|
|
50
53
|
// Set token for other services here
|
|
51
54
|
}
|
|
52
55
|
// các module export từ serviceSDK.ts set storeId vào serviceSDK.ts
|
|
@@ -62,6 +65,7 @@ class SDK {
|
|
|
62
65
|
this.service.setStoreId(storeId);
|
|
63
66
|
this.warehouse.setStoreId(storeId);
|
|
64
67
|
this.image.setStoreId(storeId);
|
|
68
|
+
this.paymentV2.setStoreId(storeId);
|
|
65
69
|
// Set storeId for other services here
|
|
66
70
|
}
|
|
67
71
|
}
|
|
@@ -448,6 +448,7 @@ export declare class OrderService extends Service {
|
|
|
448
448
|
* @throws If an error occurs while updating the customer and shipping address.
|
|
449
449
|
*/
|
|
450
450
|
deleteNoteWithoutLogin(orderId: string, noteId: string, deletedBy: string): Promise<any>;
|
|
451
|
+
getOrderByIdNoLogin(partnerId: string, storeId: string, orderId: string): Promise<any>;
|
|
451
452
|
updateOrderDescription(orderId: string, description: string): Promise<any>;
|
|
452
453
|
getOrderDetail(orderId: string): Promise<any>;
|
|
453
454
|
createInfoReceiver(ownerId: string, dataRequest: ShippingAddress): Promise<any>;
|
|
@@ -1197,6 +1197,19 @@ class OrderService extends serviceSDK_1.Service {
|
|
|
1197
1197
|
}
|
|
1198
1198
|
});
|
|
1199
1199
|
}
|
|
1200
|
+
getOrderByIdNoLogin(partnerId, storeId, orderId) {
|
|
1201
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1202
|
+
const endpoint = `/front/orders/express/${partnerId}/${storeId}?order_id=${orderId}`;
|
|
1203
|
+
const method = "GET";
|
|
1204
|
+
try {
|
|
1205
|
+
const response = yield this.restApiCallWithNoToken(endpoint, method);
|
|
1206
|
+
return response;
|
|
1207
|
+
}
|
|
1208
|
+
catch (error) {
|
|
1209
|
+
throw error;
|
|
1210
|
+
}
|
|
1211
|
+
});
|
|
1212
|
+
}
|
|
1200
1213
|
updateOrderDescription(orderId, description) {
|
|
1201
1214
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1202
1215
|
const endpoint = `/orders/${this.orgId}/${this.storeId}/${orderId}/description`;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Service } from "../serviceSDK";
|
|
2
|
+
export declare class PaymentServiceV2 extends Service {
|
|
3
|
+
constructor(endpoint: string, orgId: string, storeId: string);
|
|
4
|
+
paymentsByOrders(orderIds: [string]): Promise<any>;
|
|
5
|
+
cancelPayment(paymentId: string, reason: string): Promise<any>;
|
|
6
|
+
paymentMethods(): Promise<any>;
|
|
7
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.PaymentServiceV2 = void 0;
|
|
13
|
+
const serviceSDK_1 = require("../serviceSDK");
|
|
14
|
+
const queries_1 = require("../../graphql/paymentV2/queries");
|
|
15
|
+
const mutations_1 = require("../../graphql/paymentV2/mutations");
|
|
16
|
+
class PaymentServiceV2 extends serviceSDK_1.Service {
|
|
17
|
+
constructor(endpoint, orgId, storeId) {
|
|
18
|
+
super(endpoint, orgId, storeId);
|
|
19
|
+
}
|
|
20
|
+
paymentsByOrders(orderIds) {
|
|
21
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
22
|
+
const query = queries_1.PAYMENTS_BY_ORDERS;
|
|
23
|
+
const variables = {
|
|
24
|
+
orderIds: orderIds,
|
|
25
|
+
};
|
|
26
|
+
try {
|
|
27
|
+
const response = yield this.graphqlQueryV3(query, variables);
|
|
28
|
+
return response.paymentsByOrders;
|
|
29
|
+
}
|
|
30
|
+
catch (error) {
|
|
31
|
+
throw error;
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
cancelPayment(paymentId, reason) {
|
|
36
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
37
|
+
const mutation = mutations_1.CANCEL_PAYMENT;
|
|
38
|
+
const variables = {
|
|
39
|
+
paymentId: paymentId,
|
|
40
|
+
reason: reason,
|
|
41
|
+
};
|
|
42
|
+
try {
|
|
43
|
+
const respone = yield this.graphqlMutationV3(mutation, variables);
|
|
44
|
+
return respone.cancelPayment;
|
|
45
|
+
}
|
|
46
|
+
catch (error) {
|
|
47
|
+
throw error;
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
paymentMethods() {
|
|
52
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
53
|
+
const query = queries_1.PAYMENT_METHODS;
|
|
54
|
+
const variables = {
|
|
55
|
+
partnerCode: this.orgId
|
|
56
|
+
};
|
|
57
|
+
try {
|
|
58
|
+
const response = yield this.graphqlQueryV3(query, variables);
|
|
59
|
+
return response.paymentMethods;
|
|
60
|
+
}
|
|
61
|
+
catch (error) {
|
|
62
|
+
throw error;
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
exports.PaymentServiceV2 = PaymentServiceV2;
|
|
@@ -15,4 +15,6 @@ export declare class Service {
|
|
|
15
15
|
protected restApiCallWithNoToken(path: string, method: "GET" | "POST" | "PUT" | "DELETE", data?: any, headers?: any): Promise<any>;
|
|
16
16
|
protected graphqlQueryV2(query: DocumentNode, variables: any): Promise<any>;
|
|
17
17
|
protected graphqlMutationV2(mutation: DocumentNode, variables: any): Promise<any>;
|
|
18
|
+
protected graphqlQueryV3(query: DocumentNode, variables: any): Promise<any>;
|
|
19
|
+
protected graphqlMutationV3(mutation: DocumentNode, variables: any): Promise<any>;
|
|
18
20
|
}
|
|
@@ -183,5 +183,60 @@ class Service {
|
|
|
183
183
|
}
|
|
184
184
|
});
|
|
185
185
|
}
|
|
186
|
+
graphqlQueryV3(query, variables) {
|
|
187
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
188
|
+
try {
|
|
189
|
+
const { data, errors } = yield this.client.query({
|
|
190
|
+
query: (0, client_1.gql) `
|
|
191
|
+
${query}
|
|
192
|
+
`,
|
|
193
|
+
variables,
|
|
194
|
+
context: {
|
|
195
|
+
method: "POST",
|
|
196
|
+
headers: {
|
|
197
|
+
"Content-Type": "application/json",
|
|
198
|
+
// PartnerId: this.orgId, -> payment bị thừa partnerId -> lỗi
|
|
199
|
+
Authorization: "Bearer " + this.token,
|
|
200
|
+
},
|
|
201
|
+
},
|
|
202
|
+
});
|
|
203
|
+
if (errors) {
|
|
204
|
+
throw new Error(`GraphQL error! errors: ${errors}`);
|
|
205
|
+
}
|
|
206
|
+
return data;
|
|
207
|
+
}
|
|
208
|
+
catch (error) {
|
|
209
|
+
console.log(`Error in graphqlQuery: ${error}`);
|
|
210
|
+
throw error;
|
|
211
|
+
}
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
graphqlMutationV3(mutation, variables) {
|
|
215
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
216
|
+
try {
|
|
217
|
+
const { data, errors } = yield this.client.mutate({
|
|
218
|
+
mutation: (0, client_1.gql) `
|
|
219
|
+
${mutation}
|
|
220
|
+
`,
|
|
221
|
+
variables,
|
|
222
|
+
context: {
|
|
223
|
+
method: "POST",
|
|
224
|
+
headers: {
|
|
225
|
+
"Content-Type": "application/json",
|
|
226
|
+
// PartnerId: this.orgId,
|
|
227
|
+
Authorization: "Bearer " + this.token,
|
|
228
|
+
},
|
|
229
|
+
},
|
|
230
|
+
});
|
|
231
|
+
if (errors) {
|
|
232
|
+
throw new Error(`GraphQL error! errors: ${errors}`);
|
|
233
|
+
}
|
|
234
|
+
return data;
|
|
235
|
+
}
|
|
236
|
+
catch (error) {
|
|
237
|
+
throw error;
|
|
238
|
+
}
|
|
239
|
+
});
|
|
240
|
+
}
|
|
186
241
|
}
|
|
187
242
|
exports.Service = Service;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { ListProduct } from "../../types/warehouse";
|
|
2
1
|
import { Service } from "../serviceSDK";
|
|
3
2
|
export declare class WarehouseService extends Service {
|
|
4
3
|
/**
|
|
@@ -16,5 +15,5 @@ export declare class WarehouseService extends Service {
|
|
|
16
15
|
* @returns A promise that resolves with the created order.
|
|
17
16
|
* @throws If an error occurs while creating the order.
|
|
18
17
|
*/
|
|
19
|
-
getInventory(
|
|
18
|
+
getInventory(sku: string, warehouseId: string): Promise<any>;
|
|
20
19
|
}
|
|
@@ -31,12 +31,12 @@ class WarehouseService extends serviceSDK_1.Service {
|
|
|
31
31
|
* @returns A promise that resolves with the created order.
|
|
32
32
|
* @throws If an error occurs while creating the order.
|
|
33
33
|
*/
|
|
34
|
-
getInventory(
|
|
34
|
+
getInventory(sku, warehouseId) {
|
|
35
35
|
return __awaiter(this, void 0, void 0, function* () {
|
|
36
|
-
const endpoint =
|
|
37
|
-
const method = "
|
|
36
|
+
const endpoint = `/${sku}/${warehouseId}`;
|
|
37
|
+
const method = "GET";
|
|
38
38
|
try {
|
|
39
|
-
const response = yield this.restApiCallWithNoToken(endpoint, method
|
|
39
|
+
const response = yield this.restApiCallWithNoToken(endpoint, method);
|
|
40
40
|
return response;
|
|
41
41
|
}
|
|
42
42
|
catch (error) {
|