@longvansoftware/service-js-client 1.2.0 → 1.2.2

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.
@@ -0,0 +1,2 @@
1
+ export declare const CANCEL_PAYMENT: import("graphql").DocumentNode;
2
+ export declare const CONFIRM_PAID_MANUAL: import("graphql").DocumentNode;
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CONFIRM_PAID_MANUAL = 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(
7
+ $paymentId: String!
8
+ $reason: String!
9
+ $createBy: String
10
+ ) {
11
+ cancelPayment(paymentId: $paymentId, reason: $reason, createBy: $createBy)
12
+ }
13
+ `;
14
+ exports.CONFIRM_PAID_MANUAL = (0, graphql_tag_1.gql) `
15
+ mutation ConfirmPaidManual($paymentId: String!, $confirmBy: String) {
16
+ confirmPaidManual(paymentId: $paymentId, confirmBy: $confirmBy) {
17
+ code
18
+ message
19
+ data
20
+ qrCodeUrl
21
+ deeplink
22
+ deeplinkMiniApp
23
+ }
24
+ }
25
+ `;
@@ -1 +1,2 @@
1
1
  export declare const PAYMENTS_BY_ORDERS: import("graphql").DocumentNode;
2
+ export declare const GET_TRANSFER_INFO: import("graphql").DocumentNode;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PAYMENTS_BY_ORDERS = void 0;
3
+ exports.GET_TRANSFER_INFO = exports.PAYMENTS_BY_ORDERS = void 0;
4
4
  const graphql_tag_1 = require("graphql-tag");
5
5
  exports.PAYMENTS_BY_ORDERS = (0, graphql_tag_1.gql) `
6
6
  query PaymentsByOrders($orderIds: [String!]!) {
@@ -37,3 +37,14 @@ exports.PAYMENTS_BY_ORDERS = (0, graphql_tag_1.gql) `
37
37
  }
38
38
  }
39
39
  `;
40
+ exports.GET_TRANSFER_INFO = (0, graphql_tag_1.gql) `
41
+ query GetTransferInfor($partnerId: String! $storeId: String!){
42
+ getTransferInfo(partnerId: $partnerId, storeId: $storeId) {
43
+ bankCode
44
+ bankName
45
+ accountNumber
46
+ accountName
47
+ description
48
+ }
49
+ }
50
+ `;
@@ -3,4 +3,7 @@ export declare class PaymentLVService extends Service {
3
3
  constructor(endpoint: string, orgId: string, storeId: string);
4
4
  setToken(token: string): void;
5
5
  paymentsByOrders(orderIds: [string]): Promise<any>;
6
+ getTransferInfo(): Promise<any>;
7
+ cancelPayment(paymentId: string, reason: string, createBy: string): Promise<any>;
8
+ confirmPaidManual(paymentId: string, confirmBy: string): Promise<any>;
6
9
  }
@@ -10,6 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.PaymentLVService = void 0;
13
+ const mutations_1 = require("../../graphql/paymentLV/mutations");
13
14
  const queries_1 = require("../../graphql/paymentLV/queries");
14
15
  const serviceSDK_1 = require("../serviceSDK");
15
16
  class PaymentLVService extends serviceSDK_1.Service {
@@ -27,7 +28,9 @@ class PaymentLVService extends serviceSDK_1.Service {
27
28
  };
28
29
  // const headers = { PartnerId: this.orgId };
29
30
  try {
30
- const response = yield this.graphqlQueryCustomHeader(query, variables);
31
+ const response = yield this.graphqlQueryCustomHeader(query, variables
32
+ // headers
33
+ );
31
34
  return response.paymentsByOrders;
32
35
  }
33
36
  catch (error) {
@@ -36,5 +39,57 @@ class PaymentLVService extends serviceSDK_1.Service {
36
39
  }
37
40
  });
38
41
  }
42
+ getTransferInfo() {
43
+ return __awaiter(this, void 0, void 0, function* () {
44
+ const query = queries_1.GET_TRANSFER_INFO;
45
+ const variables = {
46
+ partnerId: this.orgId,
47
+ storeId: this.storeId,
48
+ };
49
+ try {
50
+ const response = yield this.graphqlQueryCustomHeader(query, variables);
51
+ return response.getTransferInfo;
52
+ }
53
+ catch (error) {
54
+ console.log(`Error fetching get getTransferInfo method: ${error}`);
55
+ throw error;
56
+ }
57
+ });
58
+ }
59
+ cancelPayment(paymentId, reason, createBy) {
60
+ return __awaiter(this, void 0, void 0, function* () {
61
+ const mutation = mutations_1.CANCEL_PAYMENT;
62
+ const variables = {
63
+ paymentId,
64
+ reason,
65
+ createBy,
66
+ };
67
+ try {
68
+ const response = yield this.graphqlMutationCustomHeader(mutation, variables);
69
+ return response.cancelPayment;
70
+ }
71
+ catch (error) {
72
+ console.log(`Error fetching get cancelPayment method: ${error}`);
73
+ throw error;
74
+ }
75
+ });
76
+ }
77
+ confirmPaidManual(paymentId, confirmBy) {
78
+ return __awaiter(this, void 0, void 0, function* () {
79
+ const mutation = mutations_1.CONFIRM_PAID_MANUAL;
80
+ const variables = {
81
+ paymentId,
82
+ confirmBy,
83
+ };
84
+ try {
85
+ const response = yield this.graphqlMutationCustomHeader(mutation, variables);
86
+ return response.confirmPaidManual;
87
+ }
88
+ catch (error) {
89
+ console.log(`Error fetching get confirmPaidManual method: ${error}`);
90
+ throw error;
91
+ }
92
+ });
93
+ }
39
94
  }
40
95
  exports.PaymentLVService = PaymentLVService;
@@ -16,4 +16,5 @@ export declare class Service {
16
16
  protected graphqlQueryV2(query: DocumentNode, variables: any): Promise<any>;
17
17
  protected graphqlMutationV2(mutation: DocumentNode, variables: any): Promise<any>;
18
18
  protected graphqlQueryCustomHeader(query: DocumentNode, variables: any, additionalHeaders?: Record<string, string>): Promise<any>;
19
+ protected graphqlMutationCustomHeader(mutation: DocumentNode, variables: any, additionalHeaders?: Record<string, string>): Promise<any>;
19
20
  }
@@ -194,7 +194,7 @@ class Service {
194
194
  variables,
195
195
  context: {
196
196
  method: "POST",
197
- headers
197
+ headers,
198
198
  },
199
199
  });
200
200
  if (errors) {
@@ -208,5 +208,30 @@ class Service {
208
208
  }
209
209
  });
210
210
  }
211
+ graphqlMutationCustomHeader(mutation_1, variables_1) {
212
+ return __awaiter(this, arguments, void 0, function* (mutation, variables, additionalHeaders = {}) {
213
+ try {
214
+ const headers = Object.assign({ "Content-Type": "application/json" }, additionalHeaders);
215
+ const { data, errors } = yield this.client.mutate({
216
+ mutation: (0, client_1.gql) `
217
+ ${mutation}
218
+ `,
219
+ variables,
220
+ context: {
221
+ method: "POST",
222
+ headers,
223
+ },
224
+ });
225
+ if (errors) {
226
+ throw new Error(`GraphQL error! errors: ${errors}`);
227
+ }
228
+ return data;
229
+ }
230
+ catch (error) {
231
+ console.log(`Error in graphqlMutation: ${error}`);
232
+ throw error.message;
233
+ }
234
+ });
235
+ }
211
236
  }
212
237
  exports.Service = Service;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@longvansoftware/service-js-client",
3
- "version": "1.2.0",
3
+ "version": "1.2.2",
4
4
  "main": "dist/src/index.js",
5
5
  "types": "dist/src/index.d.ts",
6
6
  "files": [