Skip to main content

Class: Request#

"api/request".Request

Class representing a request. Instances of this class can be accepted, paid, refunded, etc. Use the member function getData to access the properties of the Request.

Requests should be created with RequestNetwork.createRequest().

Hierarchy#

  • Request

Constructors#

constructor#

+ new Request(requestId: RequestLogicTypes.RequestId, requestLogic: IRequestLogic, currencyManager: ICurrencyManager, options?: { contentDataExtension?: ContentDataExtension | null ; disableEvents?: boolean ; paymentNetwork?: IPaymentNetwork | null ; requestLogicCreateResult?: IReturnCreateRequest ; skipPaymentDetection?: boolean }): Request

Defined in request-client.js/src/api/request.ts:75

Creates an instance of Request

Parameters:#

NameTypeDescription
requestIdRequestLogicTypes.RequestIdID of the Request
requestLogicIRequestLogicInstance of the request-logic layer
currencyManagerICurrencyManager-
options?{ contentDataExtension?: ContentDataExtension | null ; disableEvents?: boolean ; paymentNetwork?: IPaymentNetwork | null ; requestLogicCreateResult?: IReturnCreateRequest ; skipPaymentDetection?: boolean }options

Returns: Request

Properties#

balance#

Private balance: IBalanceWithEvents | null = null

Defined in request-client.js/src/api/request.ts:61

Balance and payments/refund events


confirmationErrorOccurredAtCreation#

Private confirmationErrorOccurredAtCreation: boolean = false

Defined in request-client.js/src/api/request.ts:36

true if the creation emitted an event 'error'


contentData#

Private contentData: any | null = null

Defined in request-client.js/src/api/request.ts:51

Content data parsed from the extensions data


contentDataExtension#

Private contentDataExtension: ContentDataExtension | null

Defined in request-client.js/src/api/request.ts:30


currencyManager#

Private currencyManager: ICurrencyManager

Defined in request-client.js/src/api/request.ts:75

A list of known tokens


disableEvents#

Private disableEvents: boolean = false

Defined in request-client.js/src/api/request.ts:70

if true, do not send blockchain confirmation events (on creation, approval, etc.)


emitter#

Private emitter: EventEmitter

Defined in request-client.js/src/api/request.ts:31


paymentNetwork#

Private paymentNetwork: IPaymentNetwork | null = null

Defined in request-client.js/src/api/request.ts:29


pendingData#

Private pendingData: RequestLogicTypes.IPendingRequest | null = null

Defined in request-client.js/src/api/request.ts:46

Pending data of the request (see request-logic)


requestData#

Private requestData: IRequest | null = null

Defined in request-client.js/src/api/request.ts:41

Data of the request (see request-logic)


requestId#

Readonly requestId: RequestLogicTypes.RequestId

Defined in request-client.js/src/api/request.ts:26

Unique ID of the request


requestLogic#

Private requestLogic: IRequestLogic

Defined in request-client.js/src/api/request.ts:28


requestMeta#

Private requestMeta: IReturnMeta | null = null

Defined in request-client.js/src/api/request.ts:56

Meta data of the request (e.g: where the data have been retrieved from)


skipPaymentDetection#

Private skipPaymentDetection: boolean = false

Defined in request-client.js/src/api/request.ts:66

if true, skip the payment detection

Methods#

accept#

accept(signerIdentity: IIdentity, refundInformation?: any): Promise<IRequestDataWithEvents>

Defined in request-client.js/src/api/request.ts:159

Accepts a request

Parameters:#

NameTypeDescription
signerIdentityIIdentityIdentity of the signer. The identity type must be supported by the signature provider.
refundInformation?anyRefund information to add (any because it is specific to the payment network used by the request)

Returns: Promise<IRequestDataWithEvents>

The updated request


addDeclarativeDelegate#

addDeclarativeDelegate(delegate: IIdentity, signerIdentity: IIdentity): Promise<IRequestDataWithEvents>

Defined in request-client.js/src/api/request.ts:565

Add a delegate for the declarative payment network

Parameters:#

NameTypeDescription
delegateIIdentityIdentity of the delegate
signerIdentityIIdentityIdentity of the signer. The identity type must be supported by the signature provider.

Returns: Promise<IRequestDataWithEvents>

The updated request


addPaymentInformation#

addPaymentInformation(paymentInformation: any, signerIdentity: IIdentity): Promise<IRequestDataWithEvents>

Defined in request-client.js/src/api/request.ts:295

Adds payment information

Parameters:#

NameTypeDescription
paymentInformationanyPayment information to add (any because it is specific to the payment network used by the request)
signerIdentityIIdentityIdentity of the signer. The identity type must be supported by the signature provider.

Returns: Promise<IRequestDataWithEvents>

The updated request


addRefundInformation#

addRefundInformation(refundInformation: any, signerIdentity: IIdentity): Promise<IRequestDataWithEvents>

Defined in request-client.js/src/api/request.ts:330

Adds refund information

Parameters:#

NameTypeDescription
refundInformationanyRefund information to add (any because it is specific to the payment network used by the request)
signerIdentityIIdentityIdentity of the signer. The identity type must be supported by the signature provider.

Returns: Promise<IRequestDataWithEvents>

The updated request


cancel#

cancel(signerIdentity: IIdentity, refundInformation?: any): Promise<IRequestDataWithEvents>

Defined in request-client.js/src/api/request.ts:189

Cancels a request

Parameters:#

NameTypeDescription
signerIdentityIIdentityIdentity of the signer. The identity type must be supported by the signature provider.
refundInformation?anyrefund information to add (any because it is specific to the payment network used by the request)

Returns: Promise<IRequestDataWithEvents>

The updated request


declareReceivedPayment#

declareReceivedPayment(amount: RequestLogicTypes.Amount, note: string, signerIdentity: IIdentity, txHash?: string, network?: string): Promise<IRequestDataWithEvents>

Defined in request-client.js/src/api/request.ts:462

Declare a payment is received for the declarative payment network

Parameters:#

NameTypeDescription
amountRequestLogicTypes.AmountAmount received
notestringNote from payee about the received payment
signerIdentityIIdentityIdentity of the signer. The identity type must be supported by the signature provider.
txHash?stringtransaction hash
network?stringnetwork of the transaction

Returns: Promise<IRequestDataWithEvents>

The updated request


declareReceivedRefund#

declareReceivedRefund(amount: RequestLogicTypes.Amount, note: string, signerIdentity: IIdentity, txHash?: string, network?: string): Promise<IRequestDataWithEvents>

Defined in request-client.js/src/api/request.ts:515

Declare a refund is received for the declarative payment network

Parameters:#

NameTypeDescription
amountRequestLogicTypes.AmountAmount received
notestringNote from payer about the received refund
signerIdentityIIdentityIdentity of the signer. The identity type must be supported by the signature provider.
txHash?stringtransaction hash
network?stringnetwork of the transaction

Returns: Promise<IRequestDataWithEvents>

The updated request


declareSentPayment#

declareSentPayment(amount: RequestLogicTypes.Amount, note: string, signerIdentity: IIdentity): Promise<IRequestDataWithEvents>

Defined in request-client.js/src/api/request.ts:366

Declare a payment is sent for the declarative payment network

Parameters:#

NameTypeDescription
amountRequestLogicTypes.AmountAmount sent
notestringNote from payer about the sent payment
signerIdentityIIdentityIdentity of the signer. The identity type must be supported by the signature provider.

Returns: Promise<IRequestDataWithEvents>

The updated request


declareSentRefund#

declareSentRefund(amount: RequestLogicTypes.Amount, note: string, signerIdentity: IIdentity): Promise<IRequestDataWithEvents>

Defined in request-client.js/src/api/request.ts:413

Declare a refund is sent for the declarative payment network

Parameters:#

NameTypeDescription
amountRequestLogicTypes.AmountAmount sent
notestringNote from payee about the sent refund
signerIdentityIIdentityIdentity of the signer. The identity type must be supported by the signature provider.

Returns: Promise<IRequestDataWithEvents>

The updated request


disablePaymentDetection#

disablePaymentDetection(): void

Defined in request-client.js/src/api/request.ts:738

Disables the payment detection

Returns: void


enablePaymentDetection#

enablePaymentDetection(): void

Defined in request-client.js/src/api/request.ts:731

Enables the payment detection

Returns: void


getData#

getData(): IRequestDataWithEvents

Defined in request-client.js/src/api/request.ts:629

Gets the request data

Returns: IRequestDataWithEvents

The updated request data


getEscrowData#

getEscrowData(paymentReference: string, network: string): Promise<PaymentTypes.EscrowChainData>

Defined in request-client.js/src/api/request.ts:655

Parameters:#

NameType
paymentReferencestring
networkstring

Returns: Promise<PaymentTypes.EscrowChainData>


handleRequestDataEvents#

ProtectedhandleRequestDataEvents(eventEmitter: EventEmitter): Promise<IRequestDataWithEvents>

Defined in request-client.js/src/api/request.ts:602

Parameters:#

NameType
eventEmitterEventEmitter

Returns: Promise<IRequestDataWithEvents>


increaseExpectedAmountRequest#

increaseExpectedAmountRequest(deltaAmount: RequestLogicTypes.Amount, signerIdentity: IIdentity, refundInformation?: any): Promise<IRequestDataWithEvents>

Defined in request-client.js/src/api/request.ts:221

Increases the expected amount of the request.

Parameters:#

NameTypeDescription
deltaAmountRequestLogicTypes.AmountAmount by which to increase the expected amount
signerIdentityIIdentityIdentity of the signer. The identity type must be supported by the signature provider.
refundInformation?anyRefund information to add (any because it is specific to the payment network used by the request)

Returns: Promise<IRequestDataWithEvents>

The updated request


on#

on<K>(event: K, listener: IRequestEvents[K]): this

Defined in request-client.js/src/api/request.ts:132

Listen the confirmation of the creation

Type parameters:#

NameType
Kkeyof IRequestEvents

Parameters:#

NameType
eventK
listenerIRequestEvents[K]

Returns: this

this


reduceExpectedAmountRequest#

reduceExpectedAmountRequest(deltaAmount: RequestLogicTypes.Amount, signerIdentity: IIdentity, paymentInformation?: any): Promise<IRequestDataWithEvents>

Defined in request-client.js/src/api/request.ts:258

Reduces the expected amount of the request. This can be called by the payee e.g. to apply discounts or special offers.

Parameters:#

NameTypeDescription
deltaAmountRequestLogicTypes.AmountAmount by which to reduce the expected amount
signerIdentityIIdentityIdentity of the signer. The identity type must be supported by the signature provider.
paymentInformation?anyPayment information to add (any because it is specific to the payment network used by the request)

Returns: Promise<IRequestDataWithEvents>

The updated request


refresh#

refresh(requestAndMeta?: IReturnGetRequestFromId): Promise<IRequestDataWithEvents>

Defined in request-client.js/src/api/request.ts:677

Refresh the request data and balance from the network (check if new events happened - e.g: accept, payments etc..) and return these data

Parameters:#

NameTypeDescription
requestAndMeta?IReturnGetRequestFromIdreturn from getRequestFromId to avoid asking twice

Returns: Promise<IRequestDataWithEvents>

Refreshed request data


refreshBalance#

refreshBalance(): Promise<IBalanceWithEvents<any> | null>

Defined in request-client.js/src/api/request.ts:719

Refresh only the balance of the request and return it

Returns: Promise<IBalanceWithEvents<any> | null>

return the balance


waitForConfirmation#

waitForConfirmation(): Promise<IRequestDataWithEvents>

Defined in request-client.js/src/api/request.ts:145

Wait for the confirmation

Returns: Promise<IRequestDataWithEvents>

the request data