File tree Expand file tree Collapse file tree 5 files changed +99
-0
lines changed
Expand file tree Collapse file tree 5 files changed +99
-0
lines changed Original file line number Diff line number Diff line change 1+ *
2+ ! ** /* .d.ts
3+ ! ** /* .d.cts
4+ ! ** /* .d.mts
5+ ! ** /* .d. * .ts
Original file line number Diff line number Diff line change 1+ export interface MidtransClientOptions {
2+ isProduction : boolean ;
3+ serverKey : string ;
4+ clientKey : string ;
5+ }
6+
7+ export interface TransactionDetails {
8+ order_id : string ;
9+ gross_amount : number ;
10+ }
11+
12+ export interface SnapTransactionParameters {
13+ transaction_details : TransactionDetails ;
14+ }
15+
16+ export interface SnapTransactionResponse {
17+ token : string ;
18+ redirect_url : string ;
19+ }
20+
21+ export class Snap {
22+ constructor ( options : MidtransClientOptions ) ;
23+ createTransaction ( parameter : SnapTransactionParameters ) : Promise < SnapTransactionResponse > ;
24+ }
25+
26+ export class CoreApi {
27+ constructor ( options : MidtransClientOptions ) ;
28+ charge ( parameter : any ) : Promise < any > ;
29+ }
Original file line number Diff line number Diff line change 1+ import * as midtransClient from 'midtrans-client' ;
2+
3+ const snap = new midtransClient . Snap ( {
4+ isProduction : false ,
5+ serverKey : 'YOUR_SERVER_KEY' ,
6+ clientKey : 'YOUR_CLIENT_KEY' ,
7+ } ) ;
8+
9+ const parameters : midtransClient . SnapTransactionParameters = {
10+ transaction_details : {
11+ order_id : 'ORDER-ID-' + new Date ( ) . getTime ( ) ,
12+ gross_amount : 200000 ,
13+ } ,
14+ } ;
15+
16+ snap . createTransaction ( parameters ) . then ( ( transaction : midtransClient . SnapTransactionResponse ) => {
17+ const token : string = transaction . token ;
18+ const redirectUrl : string = transaction . redirect_url ;
19+ } ) ;
20+
21+ const core = new midtransClient . CoreApi ( {
22+ isProduction : false ,
23+ serverKey : 'YOUR_SERVER_KEY' ,
24+ clientKey : 'YOUR_CLIENT_KEY' ,
25+ } ) ;
26+
27+ core . charge ( { } ) . then ( ( chargeResponse : any ) => {
28+ const response = chargeResponse ;
29+ } ) ;
Original file line number Diff line number Diff line change 1+ {
2+ "private" : true ,
3+ "name" : " @types/midtrans-client" ,
4+ "version" : " 1.4.9999" ,
5+ "projects" : [
6+ " https://github.com/midtrans/midtrans-nodejs-client"
7+ ],
8+ "devDependencies" : {
9+ "@types/midtrans-client" : " workspace:."
10+ },
11+ "owners" : [
12+ {
13+ "name" : " MystiaFin" ,
14+ "githubUsername" : " MystiaFin"
15+ }
16+ ]
17+ }
Original file line number Diff line number Diff line change 1+ {
2+ "compilerOptions" : {
3+ "module" : " commonjs" ,
4+ "lib" : [
5+ " es6"
6+ ],
7+ "noImplicitAny" : true ,
8+ "noImplicitThis" : true ,
9+ "strictFunctionTypes" : true ,
10+ "strictNullChecks" : true ,
11+ "types" : [],
12+ "noEmit" : true ,
13+ "forceConsistentCasingInFileNames" : true
14+ },
15+ "files" : [
16+ " index.d.ts" ,
17+ " midtrans-client-tests.ts"
18+ ]
19+ }
You can’t perform that action at this time.
0 commit comments