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, options?
: { contentDataExtension?: ContentDataExtension | null ; paymentNetwork?: IPaymentNetwork | null ; requestLogicCreateResult?: IReturnCreateRequest ; skipPaymentDetection?: boolean }): Request
Defined in request-client.js/src/api/request.ts:62
Creates an instance of Request
Parameters:
Name | Type | Description |
---|---|---|
requestId | RequestLogicTypes.RequestId | ID of the Request |
requestLogic | IRequestLogic | Instance of the request-logic layer |
options? | { contentDataExtension?: ContentDataExtension | null ; 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:57
Balance and payments/refund events
confirmationErrorOccurredAtCreation
• Private
confirmationErrorOccurredAtCreation: boolean = false
Defined in request-client.js/src/api/request.ts:32
true if the creation emitted an event 'error'
contentData
• Private
contentData: any | null = null
Defined in request-client.js/src/api/request.ts:47
Content data parsed from the extensions data
contentDataExtension
• Private
contentDataExtension: ContentDataExtension | null
Defined in request-client.js/src/api/request.ts:26
emitter
• Private
emitter: EventEmitter
Defined in request-client.js/src/api/request.ts:27
paymentNetwork
• Private
paymentNetwork: IPaymentNetwork | null = null
Defined in request-client.js/src/api/request.ts:25
pendingData
• Private
pendingData: RequestLogicTypes.IPendingRequest | null = null
Defined in request-client.js/src/api/request.ts:42
Pending data of the request (see request-logic)
requestData
• Private
requestData: IRequest | null = null
Defined in request-client.js/src/api/request.ts:37
Data of the request (see request-logic)
requestId
• Readonly
requestId: RequestLogicTypes.RequestId
Defined in request-client.js/src/api/request.ts:22
Unique ID of the request
requestLogic
• Private
requestLogic: IRequestLogic
Defined in request-client.js/src/api/request.ts:24
requestMeta
• Private
requestMeta: IReturnMeta | null = null
Defined in request-client.js/src/api/request.ts:52
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:62
if true, skip the payment detection
Methods
accept
▸ accept(signerIdentity
: IIdentity, refundInformation?
: any): Promise<IRequestDataWithEvents>
Defined in request-client.js/src/api/request.ts:137
Accepts a request
Parameters:
Name | Type | Description |
---|---|---|
signerIdentity | IIdentity | Identity of the signer. The identity type must be supported by the signature provider. |
refundInformation? | any | Refund information to add (any because it is specific to the payment network used by the request) |
Returns: Promise<IRequestDataWithEvents>
The updated request
addPaymentInformation
▸ addPaymentInformation(paymentInformation
: any, signerIdentity
: IIdentity): Promise<IRequestDataWithEvents>
Defined in request-client.js/src/api/request.ts:317
Adds payment information
Parameters:
Name | Type | Description |
---|---|---|
paymentInformation | any | Payment information to add (any because it is specific to the payment network used by the request) |
signerIdentity | IIdentity | Identity 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:363
Adds refund information
Parameters:
Name | Type | Description |
---|---|---|
refundInformation | any | Refund information to add (any because it is specific to the payment network used by the request) |
signerIdentity | IIdentity | Identity 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:178
Cancels a request
Parameters:
Name | Type | Description |
---|---|---|
signerIdentity | IIdentity | Identity of the signer. The identity type must be supported by the signature provider. |
refundInformation? | any | refund 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): Promise<IRequestDataWithEvents>
Defined in request-client.js/src/api/request.ts:525
Declare a payment is received for the declarative payment network
Parameters:
Name | Type | Description |
---|---|---|
amount | RequestLogicTypes.Amount | Amount received |
note | string | Note from payee about the received payment |
signerIdentity | IIdentity | Identity of the signer. The identity type must be supported by the signature provider. |
Returns: Promise<IRequestDataWithEvents>
The updated request
declareReceivedRefund
▸ declareReceivedRefund(amount
: RequestLogicTypes.Amount, note
: string, signerIdentity
: IIdentity): Promise<IRequestDataWithEvents>
Defined in request-client.js/src/api/request.ts:584
Declare a refund is received for the declarative payment network
Parameters:
Name | Type | Description |
---|---|---|
amount | RequestLogicTypes.Amount | Amount received |
note | string | Note from payer about the received refund |
signerIdentity | IIdentity | Identity of the signer. The identity type must be supported by the signature provider. |
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:410
Declare a payment is sent for the declarative payment network
Parameters:
Name | Type | Description |
---|---|---|
amount | RequestLogicTypes.Amount | Amount sent |
note | string | Note from payer about the sent payment |
signerIdentity | IIdentity | Identity 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:466
Declare a refund is sent for the declarative payment network
Parameters:
Name | Type | Description |
---|---|---|
amount | RequestLogicTypes.Amount | Amount sent |
note | string | Note from payee about the sent refund |
signerIdentity | IIdentity | Identity 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:733
Disables the payment detection
Returns: void
enablePaymentDetection
▸ enablePaymentDetection(): void
Defined in request-client.js/src/api/request.ts:726
Enables the payment detection
Returns: void
getData
▸ getData(): IRequestDataWithEvents
Defined in request-client.js/src/api/request.ts:640
Gets the request data
Returns: IRequestDataWithEvents
The updated request data
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:
Name | Type | Description |
---|---|---|
deltaAmount | RequestLogicTypes.Amount | Amount by which to increase the expected amount |
signerIdentity | IIdentity | Identity of the signer. The identity type must be supported by the signature provider. |
refundInformation? | any | Refund 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:110
Listen the confirmation of the creation
Type parameters:
Name | Type |
---|---|
K | keyof IRequestEvents |
Parameters:
Name | Type |
---|---|
event | K |
listener | IRequestEvents[K] |
Returns: this
this
reduceExpectedAmountRequest
▸ reduceExpectedAmountRequest(deltaAmount
: RequestLogicTypes.Amount, signerIdentity
: IIdentity, paymentInformation?
: any): Promise<IRequestDataWithEvents>
Defined in request-client.js/src/api/request.ts:269
Reduces the expected amount of the request. This can be called by the payee e.g. to apply discounts or special offers.
Parameters:
Name | Type | Description |
---|---|---|
deltaAmount | RequestLogicTypes.Amount | Amount by which to reduce the expected amount |
signerIdentity | IIdentity | Identity of the signer. The identity type must be supported by the signature provider. |
paymentInformation? | any | Payment 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:671
Refresh the request data and balance from the network (check if new events happened - e.g: accept, payments etc..) and return these data
Parameters:
Name | Type | Description |
---|---|---|
requestAndMeta? | IReturnGetRequestFromId | return 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:713
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:123
Wait for the confirmation
Returns: Promise<IRequestDataWithEvents>
the request data