Get spent amounts for current outgoing payment grant
The Get Spent Amounts for Current Outgoing Payment Grant API returns the debit and receive amounts spent against the current outgoing payment grant.
When an outgoing payment grant continuation request is successful, the client receives an access token from the authorization server. The current grant is identified by this access token.
The code snippets below let an authorized client retrieve the spent amounts for the current outgoing payment grant. For grants created with a recurring interval, the amounts returned reflect the current interval only.
Before you begin
Section titled “Before you begin”We recommend creating a wallet account on the test wallet. Creating an account allows you to test your client against the Open Payments APIs by using an ILP-enabled wallet funded with play money.
Get the spent amounts for an outgoing payment grant
Section titled “Get the spent amounts for an outgoing payment grant”Prerequisites
Initial configuration
If you’re using JavaScript, only do the first step.
-
Add
"type": "module"topackage.json. -
Add the following to
tsconfig.json{"compilerOptions": {"target": "ES2022","module": "ES2022"}}
import { createAuthenticatedClient } from '@interledger/open-payments'
// Initialize clientconst client = await createAuthenticatedClient({ walletAddressUrl: CLIENT_WALLET_ADDRESS, privateKey: PRIVATE_KEY_PATH, keyId: KEY_ID})
// Get sender wallet address informationconst walletAddress = await client.walletAddress.get({ url: WALLET_ADDRESS })
// Get spent amountsconst grantSpentAmounts = await client.outgoingPayment.getGrantSpentAmounts({ url: walletAddress.resourceServer, accessToken: OUTGOING_PAYMENT_ACCESS_TOKEN})
// Outputconsole.log('GRANT_SPENT_DEBIT_AMOUNT: ', grantSpentAmounts.spentDebitAmount)// GRANT_SPENT_DEBIT_AMOUNT: { value: '800', assetCode: 'USD', assetScale: 2 }Prerequisites
// Coming soonPrerequisites
// Coming soonPrerequisites
// Coming soonPrerequisites
// Coming soonPrerequisites
// Coming soon