Skip to content
GitHub

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.

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”
Authenticated client required

Prerequisites

Initial configuration

If you’re using JavaScript, only do the first step.

  1. Add "type": "module" to package.json.

  2. Add the following to tsconfig.json

    {
    "compilerOptions": {
    "target": "ES2022",
    "module": "ES2022"
    }
    }
import { createAuthenticatedClient } from '@interledger/open-payments'
// Initialize client
const client = await createAuthenticatedClient({
walletAddressUrl: CLIENT_WALLET_ADDRESS,
privateKey: PRIVATE_KEY_PATH,
keyId: KEY_ID
})
// Get sender wallet address information
const walletAddress = await client.walletAddress.get({ url: WALLET_ADDRESS })
// Get spent amounts
const grantSpentAmounts = await client.outgoingPayment.getGrantSpentAmounts({
url: walletAddress.resourceServer,
accessToken: OUTGOING_PAYMENT_ACCESS_TOKEN
})
// Output
console.log('GRANT_SPENT_DEBIT_AMOUNT: ', grantSpentAmounts.spentDebitAmount)
// GRANT_SPENT_DEBIT_AMOUNT: { value: '800', assetCode: 'USD', assetScale: 2 }