22 type PendingGrant ,
33 type WalletAddress ,
44 type AuthenticatedClient ,
5+ type OutgoingPayment ,
56 type Quote ,
67 type Grant ,
78 isFinalizedGrant ,
@@ -11,7 +12,7 @@ import {
1112import { getWalletAddress } from '@shared/utils'
1213import {
1314 createHeaders ,
14- timeout ,
15+ sleep ,
1516 createHTTPException ,
1617 urlWithParams
1718} from './utils.js'
@@ -193,7 +194,7 @@ export class OpenPaymentsService {
193194 debitAmount : Amount
194195 receiveAmount : Amount
195196 redirectUrl : string
196- } ) : Promise < PendingGrant > {
197+ } ) : Promise < { grant : PendingGrant ; paymentId : string } > {
197198 const clientNonce = crypto . randomUUID ( )
198199 const paymentId = createId ( )
199200
@@ -206,7 +207,7 @@ export class OpenPaymentsService {
206207 redirectUrl : args . redirectUrl
207208 } )
208209
209- return outgoingPaymentGrant
210+ return { grant : outgoingPaymentGrant , paymentId }
210211 }
211212
212213 async finishPaymentProcess (
@@ -419,22 +420,20 @@ export class OpenPaymentsService {
419420 }
420421
421422 private async checkOutgoingPayment (
422- finishPaymentUrl : string ,
423+ outgoingPaymentId : OutgoingPayment [ 'id' ] ,
423424 continuationAccessToken : string ,
424425 incomingPaymentGrant : Grant ,
425426 incomingPaymentId : string
426427 ) : Promise < CheckPaymentResult > {
427- await timeout ( 3000 )
428+ await sleep ( 3000 )
428429
429- // get outgoing payment, to check if there was enough balance
430- const checkOutgoingPaymentResponse = await this . client ! . outgoingPayment . get (
431- {
432- url : finishPaymentUrl ,
433- accessToken : continuationAccessToken
434- }
435- )
430+ const outgoingPayment = await this . client ! . outgoingPayment . get ( {
431+ url : outgoingPaymentId ,
432+ accessToken : continuationAccessToken
433+ } )
436434
437- if ( ! ( Number ( checkOutgoingPaymentResponse . sentAmount . value ) > 0 ) ) {
435+ // get outgoing payment, to check if there was enough balance
436+ if ( ! ( Number ( outgoingPayment . sentAmount . value ) > 0 ) ) {
438437 return {
439438 success : false ,
440439 error : {
0 commit comments