A Wallet is a place where money is stored. We've modeled it like a wallet in real life: each wallet has “pockets” whose usefulness we'll detail later. For now, we'll consider that we have just one “main pocket”.
When you register with FPay, we automatically create a wallet for you: This is your main wallet..
You feed any wallet with your classic Deposit, Transfer, QuasiTransfer and FundRequest operations. Every time you create one of the previous items, if you don't specify anything, your main account will be used. For example, if you make a deposit without specifying the destination of the money, the money will default to your main account. Similarly, if you transfer money without specifying its source, the money will default to your main account.
mainPocket.balance.available field. A special feature of wallet balances is the availability of 2 additional balances: The balance of locked amounts currently entering the wallet, and the balance of amounts currently leaving the wallet. These balances can be accessed using the mainPocket.balance.lockedOut field and the mainPocket.balance.lockedIn field. These amounts are always positive. They allow you to show your customer the amounts of future transactions on his account: simply make a difference between the last 2 balances.mainPocket.volume.inputmainPocket.volume.totalmainPocket.volume.outputWallet use case is explained on the use case page if you're managing money on behalf of third parties.create Create a new Wallet object and return the newly created object.
This operation takes the following parameters as input:
CreateWalletFormnamestringdescriptionstring | undefinedforeignDatastring | undefinedforeignIdstring | undefinedHere's an example of code for creating a Wallet object:
const walletPromise =
fPay.wallet.create({
name: "My First Wallet",
description: "My description",
foreignData: "{\"myKey\": 19, \"myOtherKey\": \"myOtherValue\"}",
foreignId: "123456789"
});get Returns an object Wallet found by an identifier.
You can use a unique ID specific to your system. To use your own ID instead of the one generated by FPay, you need to specify the foreignId field when creating the object. This will enable you to retrieve the object via the foreignId field, which must be unique for all Wallet objects. Here are all the fields whose values can be used as identifiers for this operation:
idforeignIdmars.alphaman.alphaconst walletPromise = fPay.wallet.get("identifier");list Returns a collection of Wallet objects, possibly filtered and/or sorted. Here are the parameters supported by this operation.
| NAME | TYPE | DESCRIPTION | DEFAULT VALUE |
|---|---|---|---|
filter | string | undefined | Condition to be met by any object returned in this collection | |
sortBy | string | undefined | Specify the field and the order (ascending or descending) by which returned objects will be sorted | |
limit | number | undefined | Total number of results to return in this collection | |
Here are a few examples of code to execute a listing to return a collection of Wallet objects:
const walletsCollectionPromise = fPay.wallet.listAll();const walletsCollectionPromise =
fPay.wallet.list({
sortBy: "id:ASC"
});const walletsCollectionPromise =
fPay.wallet.list({
limit: 5
});const walletsCollectionPromise =
fPay.wallet.list({
filter: "id in {'31234', '5678', '9990'}"
});const walletsCollectionPromise =
fPay.wallet.list({
filter: "createdTime isBefore Yesterday",
sortBy: "foreignId:DESC"
});const walletsCollectionPromise =
fPay.wallet.list({
filter: "id startsWith abcd",
sortBy: "createdTime:ASC",
limit: 25
});fetchPage When you fetch a list of Wallet, the results returned by the server can be paginated, i.e. they will be arranged on several pages. This fetchPage function allows you to navigate from page to page, iterating over all the elements. Consequently, this function returns a collection of Wallet.
Let's say you've retrieved a collection of Wallet with the following code:
const walletsCollectionPromise = fPay.wallet.listAll();If the result is spread over several pages, to go to the next page, you should do:
walletsCollectionPromise.then(walletCollection => {
if(walletCollection.hasNextPage()) {
const nextWalletPromise = fPay.wallet.fetchPage(walletCollection.pagination.nextPage);
}
});update Modify a Wallet object and return the modified version.
Here are all the fields whose values can be used as identifiers for this operation:
idforeignIdmars.alphaman.alphaWallet objects:| NAME | TYPE | DESCRIPTION |
|---|---|---|
description | string | undefined | Can be updated Can be Deleted |
foreignData | string | undefined | Can be updated Can be Deleted |
name | string | Can be updated |
Here are a few examples of code to execute an update:
walletPromise =
fPay.wallet.update({
id: "<id | foreignId>",
change: {
description: "<new value>",
foreignData: "<new value>",
name: "<new value>"
}
});walletPromise =
fPay.wallet.update({
id: "<id | foreignId>",
change: {
description: "<new value>"
},
'remove': ['foreignData']
});walletPromise =
fPay.wallet.update({
id: "<id | foreignId>",
'remove': ['description', 'foreignData']
});When you retrieve a list, here are the fields you can use for filtering and sorting. as well as sorting.
| NAME | TYPE | DESCRIPTION |
|---|---|---|
createdTime | string | |
createdTime.iso8601 | string | |
createdTime.timestamp.milliseconds | number | |
createdTime.timestamp.seconds | number | |
creator | string | |
creator._type | string | |
creator.accountId | string | |
creator.authAccessId | string | |
creator.personId | string | |
description | string | |
foreignId | string | |
id | string | |
isMain | boolean | |
mainPocket.balance | number | |
mainPocket.balance.available | number | |
mainPocket.balance.lockedIn | number | |
mainPocket.balance.lockedOut | number | |
mainPocket.volume.input | number | |
mainPocket.volume.output | number | |
mainPocket.volume.total | number | |
man.alpha | string | |
mars.alpha | string | |
name | string |
Code examples are available on the Audit & Dashboard page
WalletcreatedTimeUTCDateTimeiso8601stringtimestampTimestampmillisecondsnumbersecondsDoublecreatorCreatorCreator.ApiApi_typestringaccountIdstringauthAccessIdstringCreator.UiUi_typestringaccountIdstringpersonIdstringdescriptionstring | undefinedforeignDatastring | undefinedforeignIdstring | undefinedidstringisMainbooleanmainPocketPocketbalanceBalanceavailablenumberlockedInnumberlockedOutnumbervolumeVolumeinputnumberoutputnumbertotalnumbermanManalphastringmarsMarsalphastringnamestringurlstring