import { InstanceOptions , IOContext , Maybe } from '../..' ; import { RequestTracingConfig } from '../../HttpClient' ; import { ExternalClient } from './ExternalClient' ; const routes = { callback : ( transactionId , paymentId ) => `${ routes . payment ( transactionId , paymentId ) }/notification` , inbound : ( transactionId , paymentId , action ) => `${ routes . payment ( transactionId , paymentId ) }/inbound-request/${ action }` , payment : ( transactionId , paymentId ) => `/transactions/${ transactionId }/payments/${ paymentId }` , } ; export class PaymentProvider extends ExternalClient { constructor ( protected context , options ? ) { super ( `http://${ context . account }.vtexpayments.com.br/payment-provider` , context , { ... ( options ?? { } ) , headers : { ... ( options ?. headers ?? { } ) , 'X-Vtex-Use-Https' : 'true' , } , } ) ; } public callback = ( transactionId , paymentId , callback , tracingConfig ? ) => { const metric = 'gateway-callback' ; return this . http . post < unknown > ( routes . callback ( transactionId , paymentId ) , callback , { metric , tracing : { requestSpanNameSuffix : metric , ... tracingConfig ?. tracing , } , } ) ; } ; public inbound = < TRequest , TResponse > ( transactionId , paymentId , action , payload , tracingConfig ? ) => { const metric = 'gateway-inbound-request' ; return this . http . post < TResponse > ( routes . inbound ( transactionId , paymentId , action ) , payload , { metric , tracing : { requestSpanNameSuffix : metric , ... tracingConfig ?. tracing , } , } ) ; } ; } export interface AuthorizationCallback { paymentId : string ; status : string ; tid : string ; authorizationId ? : Maybe < string > ; nsu ? : Maybe < string > ; acquirer : string ; paymentUrl ? : Maybe < string > ; paymentAppData ? : Maybe < { appName : string ; payload : string ; } > ; identificationNumber ? : Maybe < string > ; identificationNumberFormatted ? : Maybe < string > ; barCodeImageType ? : Maybe < string > ; barCodeImageNumber ? : Maybe < string > ; code ? : Maybe < string > ; message ? : Maybe < string > ; delayToAutoSettle ? : Maybe < number > ; delayToAutoSettleAfterAntifraud ? : Maybe < number > ; delayToCancel ? : Maybe < number > ; }