@helpdice/sdk 0.1.1 → 0.1.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.
- package/dist/payment/start.d.ts +20 -7
- package/dist/payment/start.js +9 -35
- package/dist/payment/start.js.map +1 -1
- package/package.json +1 -1
package/dist/payment/start.d.ts
CHANGED
|
@@ -1,8 +1,21 @@
|
|
|
1
|
+
import type { AxiosRequestConfig } from "axios";
|
|
2
|
+
declare global {
|
|
3
|
+
interface Window {
|
|
4
|
+
Razorpay: any;
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
interface PaymentData {
|
|
8
|
+
amount: number;
|
|
9
|
+
currency: string;
|
|
10
|
+
paymentService: string;
|
|
11
|
+
[key: string]: any;
|
|
12
|
+
}
|
|
13
|
+
interface StartOptions {
|
|
14
|
+
config?: AxiosRequestConfig | null;
|
|
15
|
+
onLoading?: (isLoading: boolean) => void;
|
|
16
|
+
onSuccess?: (data: any) => void;
|
|
17
|
+
onError?: (error: any) => void;
|
|
18
|
+
onSettled?: () => void;
|
|
19
|
+
}
|
|
20
|
+
declare function start(data: PaymentData, { config, onLoading, onSuccess, onError, onSettled, }?: StartOptions): void;
|
|
1
21
|
export default start;
|
|
2
|
-
declare function start(data: any, { config, onLoading, onSuccess, onError, onSettled }?: {
|
|
3
|
-
config: null;
|
|
4
|
-
onLoading: (isLoading: any) => void;
|
|
5
|
-
onSuccess: (data: any) => void;
|
|
6
|
-
onError: (error: any) => void;
|
|
7
|
-
onSettled: () => void;
|
|
8
|
-
}): void;
|
package/dist/payment/start.js
CHANGED
|
@@ -1,16 +1,7 @@
|
|
|
1
1
|
import { post } from "../config/axios.js";
|
|
2
2
|
import { getUrl } from "../config/route.js";
|
|
3
3
|
import handler from "../utils/handler.js";
|
|
4
|
-
|
|
5
|
-
// import type { VerifyPayment } from "./types.js";
|
|
6
|
-
// import verify from "./verify.js";
|
|
7
|
-
function start(data, { config, onLoading, onSuccess, onError, onSettled } = {
|
|
8
|
-
config: null,
|
|
9
|
-
onLoading: (isLoading) => { },
|
|
10
|
-
onSuccess: (data) => { },
|
|
11
|
-
onError: (error) => { },
|
|
12
|
-
onSettled: () => { },
|
|
13
|
-
}) {
|
|
4
|
+
function start(data, { config = null, onLoading = () => { }, onSuccess = () => { }, onError = () => { }, onSettled = () => { }, } = {}) {
|
|
14
5
|
return handler({
|
|
15
6
|
promise: post(getUrl("payment", "v1", "create"), {
|
|
16
7
|
...data,
|
|
@@ -18,37 +9,20 @@ function start(data, { config, onLoading, onSuccess, onError, onSettled } = {
|
|
|
18
9
|
label: data.paymentService,
|
|
19
10
|
currency: data.currency,
|
|
20
11
|
},
|
|
21
|
-
}, config),
|
|
12
|
+
}, config || undefined),
|
|
22
13
|
onLoading,
|
|
23
|
-
onError,
|
|
24
|
-
onSuccess: (
|
|
25
|
-
if (
|
|
26
|
-
|
|
27
|
-
const rzp1 = new window.Razorpay(data.options);
|
|
28
|
-
const options = data.options;
|
|
14
|
+
onError: (error) => onError(error),
|
|
15
|
+
onSuccess: (responseData) => {
|
|
16
|
+
if (responseData?.method === "Razor Pay") {
|
|
17
|
+
const options = responseData.options;
|
|
29
18
|
options.handler = async (response) => {
|
|
30
|
-
console.log("Payment Success
|
|
19
|
+
console.log("Payment Success:", response);
|
|
31
20
|
onSuccess(response);
|
|
32
|
-
//
|
|
33
|
-
// method: 'POST',
|
|
34
|
-
// body: JSON.stringify(body),
|
|
35
|
-
// headers: {
|
|
36
|
-
// 'Content-Type': 'application/json'
|
|
37
|
-
// }
|
|
38
|
-
// });
|
|
39
|
-
// const jsonRes = await validateRes.json();
|
|
40
|
-
// console.log(jsonRes);
|
|
21
|
+
// Validation call (if needed)
|
|
41
22
|
};
|
|
23
|
+
const rzp1 = new window.Razorpay(options);
|
|
42
24
|
rzp1.on("payment.failed", (response) => {
|
|
43
|
-
// console.log('Payment Failed :', response);
|
|
44
25
|
onError(response);
|
|
45
|
-
// alert(response.error.code);
|
|
46
|
-
// alert(response.error.description);
|
|
47
|
-
// alert(response.error.source);
|
|
48
|
-
// alert(response.error.step);
|
|
49
|
-
// alert(response.error.reason);
|
|
50
|
-
// alert(response.error.metadata.order_id);
|
|
51
|
-
// alert(response.error.metadata.payment_id);
|
|
52
26
|
});
|
|
53
27
|
rzp1.open();
|
|
54
28
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"start.js","sourceRoot":"","sources":["../../src/payment/start.
|
|
1
|
+
{"version":3,"file":"start.js","sourceRoot":"","sources":["../../src/payment/start.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,OAAO,MAAM,qBAAqB,CAAC;AA2B1C,SAAS,KAAK,CACb,IAAiB,EACjB,EACC,MAAM,GAAG,IAAI,EACb,SAAS,GAAG,GAAG,EAAE,GAAE,CAAC,EACpB,SAAS,GAAG,GAAG,EAAE,GAAE,CAAC,EACpB,OAAO,GAAG,GAAG,EAAE,GAAE,CAAC,EAClB,SAAS,GAAG,GAAG,EAAE,GAAE,CAAC,MACH,EAAE;IAEpB,OAAO,OAAO,CAAC;QACd,OAAO,EAAE,IAAI,CACZ,MAAM,CAAC,SAAS,EAAE,IAAI,EAAE,QAAQ,CAAC,EACjC;YACC,GAAG,IAAI;YACP,MAAM,EAAE;gBACP,KAAK,EAAE,IAAI,CAAC,cAAc;gBAC1B,QAAQ,EAAE,IAAI,CAAC,QAAQ;aACvB;SACD,EACD,MAAM,IAAI,SAAS,CACnB;QACD,SAAS;QACT,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC;QAClC,SAAS,EAAE,CAAC,YAAiB,EAAE,EAAE;YAChC,IAAI,YAAY,EAAE,MAAM,KAAK,WAAW,EAAE,CAAC;gBAC1C,MAAM,OAAO,GAAG,YAAY,CAAC,OAAO,CAAC;gBACrC,OAAO,CAAC,OAAO,GAAG,KAAK,EAAE,QAAa,EAAE,EAAE;oBACzC,OAAO,CAAC,GAAG,CAAC,kBAAkB,EAAE,QAAQ,CAAC,CAAC;oBAC1C,SAAS,CAAC,QAAQ,CAAC,CAAC;oBACpB,8BAA8B;gBAC/B,CAAC,CAAC;gBAEF,MAAM,IAAI,GAAG,IAAI,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;gBAE1C,IAAI,CAAC,EAAE,CAAC,gBAAgB,EAAE,CAAC,QAAa,EAAE,EAAE;oBAC3C,OAAO,CAAC,QAAQ,CAAC,CAAC;gBACnB,CAAC,CAAC,CAAC;gBAEH,IAAI,CAAC,IAAI,EAAE,CAAC;YACb,CAAC;QACF,CAAC;QACD,SAAS;KACT,CAAC,CAAC;AACJ,CAAC;AAED,eAAe,KAAK,CAAC"}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@helpdice/sdk",
|
|
3
3
|
"type": "module",
|
|
4
4
|
"description": "A backend API-based SDK (Software Development Kit) provides developers with pre-built tools and libraries to interact seamlessly with a backend server or service. It simplifies the process of integrating external functionality, such as authentication, data storage, or third-party services, into applications. The SDK typically includes API endpoints, functions, and documentation, allowing developers to make requests, handle responses, and manage errors efficiently. By abstracting complex backend logic, it speeds up development, reduces coding errors, and ensures consistent interactions with the backend, making it easier to build scalable, secure, and feature-rich applications.",
|
|
5
|
-
"version": "0.1.
|
|
5
|
+
"version": "0.1.2",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
8
8
|
"repository": {
|