PaymentRequest
@node-fi/sdk-core / Exports / PaymentRequest
Class: PaymentRequest<MetaDataShape>
Class representation of a Payment request. Facilitates queries and fulfillment
Type parameters
Name | Type |
---|---|
MetaDataShape | extends 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
Name | Type |
---|---|
MetaDataShape | extends Record <string , unknown > = Record <string , unknown > |
Parameters
Name | Type |
---|---|
_id | number |
_payer | string |
_payee | string |
_amount | TokenAmount |
_totalAmount | TokenAmount |
_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
Name | Type |
---|---|
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
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
Name | Type | Description |
---|---|---|
transactionHash | string | Hash 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
Name | Type | Description |
---|---|---|
field | keyof MetaDataShape | Field 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
Name | Type | Description |
---|---|---|
f | (req? : PaymentRequest <Record <string , unknown >>) => unknown | Function 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
Name | Type |
---|---|
_type | string |
amount | string |
deadline | string |
fulfilledOn | string |
metadata | string |
payee | string |
payer | string |
requestedOn | string |
rid | number |
totalAmount | string |
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
Name | Type |
---|---|
MetaDataShape | extends Record <string , unknown > = Record <string , unknown > |
Parameters
Name | Type | Description |
---|---|---|
payee | string | Address of wallet where payments should be sent |
payer | string | Address of wallet where payments should originate |
amount | TokenAmount | Token and amount to be request |
signer | Wallet <Signer > | Wallet object to authorize the request |
opts? | Object | optionally declare a deadline for the request, or set metadata for the request |
opts.deadline? | number | Date | - |
opts.metadata? | MetaDataShape | - |
apiKey? | string | Optional 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
Name | Type |
---|---|
MetaDataShape | extends Record <string , unknown > = Record <string , unknown > |
Parameters
Name | Type | Description |
---|---|---|
json | PaymentRequestPayload | JSON-representation to serialize |
getToken | (address : string ) => Token | method 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
Name | Type |
---|---|
MetaDataShape | extends Record <string , unknown > = Record <string , unknown > |
Parameters
Name | Type | Description |
---|---|---|
id | number | ID of payment request to fetch |
getToken | (adress : string ) => Token | Helper method to fetch a token given its address |
apiKey? | string | Optional 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
Name | Type | Description |
---|---|---|
obj? | unknown | Object 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
Name | Type |
---|---|
__namedParameters | SerializedPaymentRequest |
Returns
PaymentRequest
<Record
<string
, unknown
>>