Skip to content

Commit 47f2964

Browse files
authored
🤖 Merge PR DefinitelyTyped#73214 Type created to support sabpaisa-react-lite plugin by @lokesheywa
1 parent a500ce5 commit 47f2964

File tree

5 files changed

+135
-0
lines changed

5 files changed

+135
-0
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
*
2+
!**/*.d.ts
3+
!**/*.d.cts
4+
!**/*.d.mts
5+
!**/*.d.*.ts
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
export interface SabpaisaSuccessResponse {
2+
razorpay_signature: string;
3+
razorpay_order_id: string;
4+
razorpay_payment_id: string;
5+
}
6+
7+
export interface SabpaisaErrorResponse {
8+
code: number;
9+
description: string;
10+
error: {
11+
field?: string;
12+
source: string;
13+
step: string;
14+
reason: string;
15+
metadata: {
16+
payment_id?: string;
17+
order_id: string;
18+
};
19+
};
20+
}
21+
22+
export interface SabpaisaCheckoutOptions {
23+
first_name: string;
24+
last_name: string;
25+
currency: string;
26+
mobile_number: string;
27+
email_id: string;
28+
client_code: string;
29+
aes_iv: string;
30+
aes_key: string;
31+
user_name: string;
32+
password: string;
33+
env: string;
34+
txn_id: string;
35+
amount: string;
36+
}
37+
38+
declare const SabPaisaCheckout: {
39+
open: (
40+
options: SabpaisaCheckoutOptions,
41+
successCallback?: (data: SabpaisaSuccessResponse) => void,
42+
errorCallback?: (data: SabpaisaErrorResponse) => void,
43+
) => Promise<SabpaisaSuccessResponse>;
44+
onExternalWalletSelection: (externalWalletCallback: (data: unknown) => void) => void;
45+
};
46+
47+
export default SabPaisaCheckout;
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"private": true,
3+
"name": "@types/sabpaisa-react-lite",
4+
"version": "2.4.9999",
5+
"projects": [
6+
"https://www.npmjs.com/package/sabpaisa-react-lite"
7+
],
8+
"devDependencies": {
9+
"@types/sabpaisa-react-lite": "workspace:.",
10+
"react-native": "*"
11+
},
12+
"owners": [
13+
{
14+
"name": "Lokesh D",
15+
"githubUsername": "lokesheywa"
16+
}
17+
],
18+
"dependencies": {
19+
"@types/react": "*"
20+
}
21+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import * as React from "react";
2+
import { Button } from "react-native";
3+
import SabPaisaCheckout, { SabpaisaErrorResponse } from "sabpaisa-react-lite";
4+
5+
6+
const SabpaisaCheckoutOptions = {
7+
first_name: 'firstnamereact',
8+
last_name: 'lastnamereact',
9+
currency: 'INR',
10+
mobile_number: '9999999999',
11+
email_id: '[email protected]',
12+
client_code: '<client_code>',
13+
aes_iv: '<aes_iv>',
14+
aes_key: '<aes_key>',
15+
user_name: '<user_name>',
16+
password: '<password>',
17+
env: 'staging',
18+
txn_id: '11223344343',
19+
amount: '100'
20+
};
21+
22+
const Test = () => {
23+
return (
24+
<>
25+
<Button
26+
title="Pay"
27+
onPress={() => {
28+
SabPaisaCheckout.open(SabpaisaCheckoutOptions)
29+
.then(data => {
30+
// type should match SuccessResponse definition
31+
console.log(data);
32+
})
33+
.catch((error: SabpaisaErrorResponse) => {
34+
// type should match ErrorResponse definition
35+
// type valid for errors after successful API integration
36+
console.log(error);
37+
});
38+
}}
39+
/>
40+
</>
41+
);
42+
};
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"compilerOptions": {
3+
"module": "commonjs",
4+
"lib": [
5+
"es6"
6+
],
7+
"noImplicitAny": true,
8+
"noImplicitThis": true,
9+
"strictNullChecks": true,
10+
"strictFunctionTypes": true,
11+
"types": [],
12+
"noEmit": true,
13+
"forceConsistentCasingInFileNames": true,
14+
"jsx": "react-native"
15+
},
16+
"files": [
17+
"index.d.ts",
18+
"sabpaisa-reactlite-tests.tsx"
19+
]
20+
}

0 commit comments

Comments
 (0)