@a-tech.jo/atech_payment 1.0.17 → 1.0.18
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/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.LICENSE.txt +1 -0
- package/dist/src/config.d.ts +13 -0
- package/dist/src/config.d.ts.map +1 -0
- package/dist/src/hyperpay/hyperpayOrder.d.ts +5 -0
- package/dist/src/hyperpay/hyperpayOrder.d.ts.map +1 -0
- package/dist/src/index.d.ts +8 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/meps/mepsOrder.d.ts +5 -0
- package/dist/src/meps/mepsOrder.d.ts.map +1 -0
- package/dist/src/network/networkOrder.d.ts +5 -0
- package/dist/src/network/networkOrder.d.ts.map +1 -0
- package/dist/src/paypal/paypalOrder.d.ts +5 -0
- package/dist/src/paypal/paypalOrder.d.ts.map +1 -0
- package/dist/src/shared/config.d.ts +7 -0
- package/dist/src/shared/config.d.ts.map +1 -0
- package/dist/src/shared/requests/backendConnector.d.ts +9 -0
- package/dist/src/shared/requests/backendConnector.d.ts.map +1 -0
- package/dist/src/shared/requests/stripeConnector.d.ts +13 -0
- package/dist/src/shared/requests/stripeConnector.d.ts.map +1 -0
- package/dist/src/stripe/stripeOrder.d.ts +5 -0
- package/dist/src/stripe/stripeOrder.d.ts.map +1 -0
- package/dist/src/types/index.d.ts +70 -0
- package/dist/src/types/index.d.ts.map +1 -0
- package/dist/tsup.config.d.ts +3 -0
- package/dist/tsup.config.d.ts.map +1 -0
- package/package.json +27 -19
- package/.babelrc +0 -4
- package/.env.example +0 -1
- package/build/index.js +0 -2
- package/build/index.js.LICENSE.txt +0 -11
- package/documentation/hyperpay.md +0 -18
- package/example/hyperpay/requests/createOrder.json +0 -37
- package/example/hyperpay/use.js +0 -0
- package/example/paypal.js +0 -0
- package/index.html +0 -12
- package/index.js +0 -44
- package/src/hyperpay/hyperpayOrder.js +0 -100
- package/src/paypal/buttonWrapper.js +0 -76
- package/src/paypal/paypalOrder.js +0 -33
- package/src/shared/config.js +0 -20
- package/src/shared/paypalService.js +0 -16
- package/src/shared/requests/backendConnector.js +0 -24
- package/src/shared/requests/hyperpayConnector.js +0 -56
- package/src/shared/requests/request.js +0 -92
- package/webpack.config.js +0 -47
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
// Services
|
|
2
|
-
import config from "../config.js";
|
|
3
|
-
import request from "./request.js";
|
|
4
|
-
import axios from "axios";
|
|
5
|
-
|
|
6
|
-
class HyperpayConnector {
|
|
7
|
-
constructor() {
|
|
8
|
-
this.BASEURL = config.BACKEND_BASE_URL;
|
|
9
|
-
axios.defaults.baseURL = config.BACKEND_BASE_URL;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
defaultHeaders = (data) => {
|
|
13
|
-
const headers = {
|
|
14
|
-
"Content-Type": "application/x-www-form-urlencoded",
|
|
15
|
-
"Content-Length": data?.length,
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
return headers;
|
|
19
|
-
};
|
|
20
|
-
async createHyperpayOrder(data) {
|
|
21
|
-
// Create an order and return checkoutID
|
|
22
|
-
const headers = this.defaultHeaders();
|
|
23
|
-
const url = "/hyperpay/orders/create-order";
|
|
24
|
-
const requestConfig = {
|
|
25
|
-
url: url,
|
|
26
|
-
data,
|
|
27
|
-
headers: headers,
|
|
28
|
-
};
|
|
29
|
-
console.log("requestConfig", requestConfig);
|
|
30
|
-
const result = await request.post(requestConfig);
|
|
31
|
-
console.log("result", result);
|
|
32
|
-
return result;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
async getOrderStatus(checkoutId, resourcePath) {
|
|
36
|
-
const headers = this.defaultHeaders();
|
|
37
|
-
const requestConfig = {
|
|
38
|
-
url: `/hyperpay/orders/get-order?resourcePath=${resourcePath}&id=${checkoutId}`,
|
|
39
|
-
headers,
|
|
40
|
-
};
|
|
41
|
-
const result = await request.get(requestConfig);
|
|
42
|
-
return result;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
async captureOrder(orderId) {
|
|
46
|
-
const headers = this.defaultHeaders();
|
|
47
|
-
const requestConfig = {
|
|
48
|
-
url: `/hyperpay/orders/capture-order/${orderId}`,
|
|
49
|
-
headers,
|
|
50
|
-
};
|
|
51
|
-
const result = await request.post(requestConfig);
|
|
52
|
-
return result;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export default new HyperpayConnector();
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import axios from "axios";
|
|
2
|
-
// CONFIG
|
|
3
|
-
import config from "../config.js";
|
|
4
|
-
|
|
5
|
-
class Request {
|
|
6
|
-
constructor() {}
|
|
7
|
-
|
|
8
|
-
async handleRequests(finalConfig) {
|
|
9
|
-
try {
|
|
10
|
-
axios.defaults.baseURL = config.BACKEND_BASE_URL;
|
|
11
|
-
const response = await axios.request(finalConfig);
|
|
12
|
-
|
|
13
|
-
return response.data;
|
|
14
|
-
} catch (err) {
|
|
15
|
-
console.log("err", err);
|
|
16
|
-
if (err.response) {
|
|
17
|
-
if (err.response.status === 401) {
|
|
18
|
-
return (window.location.href = "/login");
|
|
19
|
-
}
|
|
20
|
-
return err.response.data;
|
|
21
|
-
} else if (err.request) {
|
|
22
|
-
return {
|
|
23
|
-
success: false,
|
|
24
|
-
message: "No response received, please try again later.",
|
|
25
|
-
};
|
|
26
|
-
} else {
|
|
27
|
-
return {
|
|
28
|
-
success: false,
|
|
29
|
-
message: "An unexpected error occurred.",
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
async post(config) {
|
|
36
|
-
const defaultConfig = {
|
|
37
|
-
method: "post",
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
const finalConfig = {
|
|
41
|
-
...defaultConfig,
|
|
42
|
-
...config,
|
|
43
|
-
};
|
|
44
|
-
return await this.handleRequests(finalConfig);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
async get(config = {}) {
|
|
48
|
-
const defaultConfig = {
|
|
49
|
-
method: "get",
|
|
50
|
-
};
|
|
51
|
-
const finalConfig = {
|
|
52
|
-
...defaultConfig,
|
|
53
|
-
...config,
|
|
54
|
-
};
|
|
55
|
-
return await this.handleRequests(finalConfig);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
async put(config) {
|
|
59
|
-
const defaultConfig = {
|
|
60
|
-
method: "put",
|
|
61
|
-
};
|
|
62
|
-
const finalConfig = {
|
|
63
|
-
...defaultConfig,
|
|
64
|
-
...config,
|
|
65
|
-
};
|
|
66
|
-
return await this.handleRequests(finalConfig);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
async patch(config) {
|
|
70
|
-
const defaultConfig = {
|
|
71
|
-
method: "patch",
|
|
72
|
-
};
|
|
73
|
-
const finalConfig = {
|
|
74
|
-
...defaultConfig,
|
|
75
|
-
...config,
|
|
76
|
-
};
|
|
77
|
-
return await this.handleRequests(finalConfig);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
async delete(config) {
|
|
81
|
-
const defaultConfig = {
|
|
82
|
-
method: "delete",
|
|
83
|
-
};
|
|
84
|
-
const finalConfig = {
|
|
85
|
-
...defaultConfig,
|
|
86
|
-
...config,
|
|
87
|
-
};
|
|
88
|
-
return await this.handleRequests(finalConfig);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
export default new Request();
|
package/webpack.config.js
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
// webpack.config.js
|
|
2
|
-
import path from "path";
|
|
3
|
-
import Dotenv from "dotenv-webpack";
|
|
4
|
-
|
|
5
|
-
const isProduction = process.env.NODE_ENV === "production";
|
|
6
|
-
|
|
7
|
-
const config = {
|
|
8
|
-
entry: "./index.js",
|
|
9
|
-
output: {
|
|
10
|
-
path: path.resolve("build"),
|
|
11
|
-
filename: "index.js",
|
|
12
|
-
},
|
|
13
|
-
devServer: {
|
|
14
|
-
open: true,
|
|
15
|
-
host: "localhost",
|
|
16
|
-
},
|
|
17
|
-
module: {
|
|
18
|
-
rules: [
|
|
19
|
-
{
|
|
20
|
-
test: /\.(js|jsx)$/i,
|
|
21
|
-
exclude: /node_modules\/(?!@a-tech.jo\/atech_payment)/,
|
|
22
|
-
loader: "babel-loader",
|
|
23
|
-
},
|
|
24
|
-
{
|
|
25
|
-
test: /\.(eot|svg|ttf|woff|woff2|png|jpg|gif)$/i,
|
|
26
|
-
type: "asset",
|
|
27
|
-
},
|
|
28
|
-
],
|
|
29
|
-
},
|
|
30
|
-
plugins: [
|
|
31
|
-
new Dotenv({
|
|
32
|
-
path: "./.env",
|
|
33
|
-
// Use `true` for production mode (only load .env)
|
|
34
|
-
// Use `false` for development mode (load .env and .env.local)
|
|
35
|
-
safe: isProduction ? true : false,
|
|
36
|
-
}),
|
|
37
|
-
],
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
export default () => {
|
|
41
|
-
if (isProduction) {
|
|
42
|
-
config.mode = "production";
|
|
43
|
-
} else {
|
|
44
|
-
config.mode = "development";
|
|
45
|
-
}
|
|
46
|
-
return config;
|
|
47
|
-
};
|