@@ -46,6 +46,7 @@ import {
46
46
} from '../../src/iden3comm/types/protocol/payment' ;
47
47
import { Contract , ethers , JsonRpcProvider } from 'ethers' ;
48
48
import fetchMock from '@gr2m/fetch-mock' ;
49
+ import { fail } from 'assert' ;
49
50
50
51
describe ( 'payment-request handler' , ( ) => {
51
52
let packageMgr : IPackageManager ;
@@ -95,17 +96,16 @@ describe('payment-request handler', () => {
95
96
}
96
97
] ;
97
98
98
- const paymentIntegrationHandlerFunc = async (
99
- data : PaymentRequestDataInfo ,
100
- txParams : unknown [ ]
101
- ) : Promise < string > => {
102
- const rpcProvider = new JsonRpcProvider ( RPC_URL ) ;
103
- const ethSigner = new ethers . Wallet ( WALLET_KEY , rpcProvider ) ;
104
- const payContract = new Contract ( data . address , payContractAbi , ethSigner ) ;
105
- const options = { value : data . amount } ;
106
- const txData = await payContract . pay ( ...txParams , options ) ;
107
- return txData . hash ;
108
- } ;
99
+ const paymentIntegrationHandlerFunc =
100
+ ( sessionId : string , did : string ) =>
101
+ async ( data : PaymentRequestDataInfo ) : Promise < string > => {
102
+ const rpcProvider = new JsonRpcProvider ( RPC_URL ) ;
103
+ const ethSigner = new ethers . Wallet ( WALLET_KEY , rpcProvider ) ;
104
+ const payContract = new Contract ( data . address , payContractAbi , ethSigner ) ;
105
+ const options = { value : data . amount } ;
106
+ const txData = await payContract . pay ( sessionId , did , options ) ;
107
+ return txData . hash ;
108
+ } ;
109
109
110
110
const paymentCheckIntegrationHandlerFunc = async (
111
111
txId : string ,
@@ -130,7 +130,7 @@ describe('payment-request handler', () => {
130
130
type : PaymentRequestDataType . Iden3PaymentRequestCryptoV1 ,
131
131
amount : '1000000000000000' ,
132
132
id : 12432 ,
133
- chainID : 80002 ,
133
+ chainId : 80002 ,
134
134
address : '0x2C2007d72f533FfD409F0D9f515983e95bF14992'
135
135
} ,
136
136
expiration : 2125558127 ,
@@ -196,9 +196,11 @@ describe('payment-request handler', () => {
196
196
{ }
197
197
) ;
198
198
const agentMessageBytes = await paymentHandler . handlePaymentRequest ( msgBytesRequest , {
199
- paymentHandler : paymentHandlerFuncMock ,
200
- txParams : [ '<session-id-hash>' , '<issuer-did-hash>' ]
199
+ paymentHandler : paymentHandlerFuncMock
201
200
} ) ;
201
+ if ( ! agentMessageBytes ) {
202
+ fail ( 'handlePaymentRequest is not expected null response' ) ;
203
+ }
202
204
const { unpackedMessage : agentMessage } = await packageManager . unpack ( agentMessageBytes ) ;
203
205
204
206
expect ( ( agentMessage as BasicMessage ) . type ) . to . be . eq (
@@ -216,8 +218,7 @@ describe('payment-request handler', () => {
216
218
{ }
217
219
) ;
218
220
const agentMessageBytes = await paymentHandler . handlePaymentRequest ( msgBytesRequest , {
219
- paymentHandler : paymentHandlerFuncMock ,
220
- txParams : [ '<session-id-hash>' , '<issuer-did-hash>' ]
221
+ paymentHandler : paymentHandlerFuncMock
221
222
} ) ;
222
223
expect ( agentMessageBytes ) . to . be . null ;
223
224
} ) ;
@@ -250,9 +251,11 @@ describe('payment-request handler', () => {
250
251
{ }
251
252
) ;
252
253
const agentMessageBytes = await paymentHandler . handlePaymentRequest ( msgBytesRequest , {
253
- paymentHandler : paymentIntegrationHandlerFunc ,
254
- txParams : [ '<session-id-hash>' , '<issuer-did-hash>' ]
254
+ paymentHandler : paymentIntegrationHandlerFunc ( '<session-id-hash>' , '<issuer-did-hash>' )
255
255
} ) ;
256
+ if ( ! agentMessageBytes ) {
257
+ fail ( 'handlePaymentRequest is not expected null response' ) ;
258
+ }
256
259
const { unpackedMessage : agentMessage } = await packageManager . unpack ( agentMessageBytes ) ;
257
260
258
261
expect ( ( agentMessage as BasicMessage ) . type ) . to . be . eq (
0 commit comments