Skip to main content

PaymentRequest

@node-fi/sdk-core / Exports / PaymentRequest

Class: PaymentRequest<MetaDataShape>

Class representation of a Payment request. Facilitates queries and fulfillment

Type parameters

NameType
MetaDataShapeextends Record<string, unknown> = Record<string, unknown>

Table of contents

Constructors

Properties

Accessors

Methods

Constructors

constructor

new PaymentRequest<MetaDataShape>(_id, _payer, _payee, _amount, _totalAmount, _metadata?, _requestedOn?, _fulfilledOn?, _deadline?)

Type parameters

NameType
MetaDataShapeextends Record<string, unknown> = Record<string, unknown>

Parameters

NameType
_idnumber
_payerstring
_payeestring
_amountTokenAmount
_totalAmountTokenAmount
_metadata?MetaDataShape
_requestedOn?Date
_fulfilledOn?Date
_deadline?Date

Defined in

packages/sdk-core/src/PaymentRequest/PaymentRequest.ts:62

Properties

_amount

Private _amount: TokenAmount

Defined in

packages/sdk-core/src/PaymentRequest/PaymentRequest.ts:66


_deadline

Private Optional _deadline: Date

Defined in

packages/sdk-core/src/PaymentRequest/PaymentRequest.ts:71


_fulfilledOn

Private Optional _fulfilledOn: Date

Defined in

packages/sdk-core/src/PaymentRequest/PaymentRequest.ts:70


_id

Private _id: number

Defined in

packages/sdk-core/src/PaymentRequest/PaymentRequest.ts:63


_metadata

Private Optional _metadata: MetaDataShape

Defined in

packages/sdk-core/src/PaymentRequest/PaymentRequest.ts:68


_onFulfill

Private Optional _onFulfill: (req?: PaymentRequest<Record<string, unknown>>) => unknown

Type declaration

▸ (req?): unknown

Parameters
NameType
req?PaymentRequest<Record<string, unknown>>
Returns

unknown

Defined in

packages/sdk-core/src/PaymentRequest/PaymentRequest.ts:60


_payee

Private _payee: string

Defined in

packages/sdk-core/src/PaymentRequest/PaymentRequest.ts:65


_payer

Private _payer: string

Defined in

packages/sdk-core/src/PaymentRequest/PaymentRequest.ts:64


_requestedOn

Private Optional _requestedOn: Date

Defined in

packages/sdk-core/src/PaymentRequest/PaymentRequest.ts:69


_totalAmount

Private _totalAmount: TokenAmount

Defined in

packages/sdk-core/src/PaymentRequest/PaymentRequest.ts:67

Accessors

deadline

get deadline(): undefined | Date

Deadline of payment request

Returns

undefined | Date

Defined in

packages/sdk-core/src/PaymentRequest/PaymentRequest.ts:97


fulfilledOn

get fulfilledOn(): undefined | Date

Date of request fulfillment

Returns

undefined | Date

Defined in

packages/sdk-core/src/PaymentRequest/PaymentRequest.ts:111


info

get info(): PaymentRequestData

Basic info on the given payment request

Returns

PaymentRequestData

Defined in

packages/sdk-core/src/PaymentRequest/PaymentRequest.ts:77


metadata

get metadata(): undefined | MetaDataShape

Custom metadata as defined in the request origination. Shape influences Payment request.

Returns

undefined | MetaDataShape

Defined in

packages/sdk-core/src/PaymentRequest/PaymentRequest.ts:90


requestedOn

get requestedOn(): undefined | Date

Date of request origination

Returns

undefined | Date

Defined in

packages/sdk-core/src/PaymentRequest/PaymentRequest.ts:104

Methods

fulfill

fulfill(transactionHash): Promise<{ receipt: { amountCredited: TokenAmount ; hash: string ; isFullyRepaid: boolean ; rid: number ; time: number } ; request: PaymentRequest<MetaDataShape> }>

Parameters

NameTypeDescription
transactionHashstringHash where payment was sen

Returns

Promise<{ receipt: { amountCredited: TokenAmount ; hash: string ; isFullyRepaid: boolean ; rid: number ; time: number } ; request: PaymentRequest<MetaDataShape> }>

Receipt of payment being counted in the wallet service

Defined in

packages/sdk-core/src/PaymentRequest/PaymentRequest.ts:137


get

get(field, defaultValue?): unknown

Parameters

NameTypeDescription
fieldkeyof MetaDataShapeField to access
defaultValue?unknown-

Returns

unknown

corresponding value in the metadata

Defined in

packages/sdk-core/src/PaymentRequest/PaymentRequest.ts:120


setOnFulfillCallback

setOnFulfillCallback(f): void

Parameters

NameTypeDescription
f(req?: PaymentRequest<Record<string, unknown>>) => unknownFunction to call when payment is fulfilled

Returns

void

Defined in

packages/sdk-core/src/PaymentRequest/PaymentRequest.ts:128


toJSON

toJSON(): Object

Returns

Object

JSON representation of the payment request

NameType
_typestring
amountstring
deadlinestring
fulfilledOnstring
metadatastring
payeestring
payerstring
requestedOnstring
ridnumber
totalAmountstring

Defined in

packages/sdk-core/src/PaymentRequest/PaymentRequest.ts:222


create

Static create<MetaDataShape>(payee, payer, amount, signer, opts?, apiKey?): Promise<PaymentRequest<MetaDataShape>>

Type parameters

NameType
MetaDataShapeextends Record<string, unknown> = Record<string, unknown>

Parameters

NameTypeDescription
payeestringAddress of wallet where payments should be sent
payerstringAddress of wallet where payments should originate
amountTokenAmountToken and amount to be request
signerWallet<Signer>Wallet object to authorize the request
opts?Objectoptionally declare a deadline for the request, or set metadata for the request
opts.deadline?number | Date-
opts.metadata?MetaDataShape-
apiKey?stringOptional api key for Node Finance

Returns

Promise<PaymentRequest<MetaDataShape>>

PaymentRequest object of newly-created request

Defined in

packages/sdk-core/src/PaymentRequest/PaymentRequest.ts:302


deserialize

Static deserialize<MetaDataShape>(json, getToken): PaymentRequest<MetaDataShape>

Type parameters

NameType
MetaDataShapeextends Record<string, unknown> = Record<string, unknown>

Parameters

NameTypeDescription
jsonPaymentRequestPayloadJSON-representation to serialize
getToken(address: string) => Tokenmethod to fetch a token given a token address

Returns

PaymentRequest<MetaDataShape>

PaymenRequest object populated with fields from json

Defined in

packages/sdk-core/src/PaymentRequest/PaymentRequest.ts:241


fetch

Static fetch<MetaDataShape>(id, getToken, apiKey?): Promise<PaymentRequest<MetaDataShape>>

Type parameters

NameType
MetaDataShapeextends Record<string, unknown> = Record<string, unknown>

Parameters

NameTypeDescription
idnumberID of payment request to fetch
getToken(adress: string) => TokenHelper method to fetch a token given its address
apiKey?stringOptional api key

Returns

Promise<PaymentRequest<MetaDataShape>>

PaymentRequest object of corresponding ID

Defined in

packages/sdk-core/src/PaymentRequest/PaymentRequest.ts:277


isSerializedPaymentRequest

Static isSerializedPaymentRequest(obj?): obj is SerializedPaymentRequest

Parameters

NameTypeDescription
obj?unknownObject to check

Returns

obj is SerializedPaymentRequest

True if object is a serialized payment request

Defined in

packages/sdk-core/src/PaymentRequest/PaymentRequest.ts:188


parseJson

Static parseJson(__namedParameters): PaymentRequest<Record<string, unknown>>

Parameters

NameType
__namedParametersSerializedPaymentRequest

Returns

PaymentRequest<Record<string, unknown>>

Defined in

packages/sdk-core/src/PaymentRequest/PaymentRequest.ts:195