Redeeming an Access Token for CAF

The account information access permissions you specify in your access token request are reflected in the access token generated. Consequently, if you don't ask for access to the FUNDS_CONFIRMATIONS resource type in your access token request, it won't be granted in the access token.

Keeping this in mind, the server-side call forAccessToken() is used to get the object — called a representing your customer-user. You can then make a confirmFunds() call on the Representable object— cbpiiMember — pursuant to the FUNDS_CONFIRMATIONS permission granted in the access token.

The confirmFunds() call generates the Boolean value (true/false) concerning availability of sufficient funds in the user-specified bank account. No other values or conditions are returned.

Here's the form for a funds confirmation access token redemption:

private static boolean confirmFunds(String tokenId) {

    // use access token's permissions from now on, set true if customer initiated request

    String accountId = cbpiiMember.getTokenBlocking(tokenId)

        .getPayload()

        .getAccess()

        .getResources(0)

        .getFundsConfirmation()

        .getAccountId();

    Representable representable = cbpiiMember.forAccessToken(tokenId, false);

    return representable.confirmFundsBlocking(accountId, AMOUNT, CURRENCY);

}

The account number is found in the redemption payload as token.payload.access.resources[0].funds_confirmation.account_id. This will be different than the account you provided in the original token request.

Tip for PISPs: Payment Service Providers are advised to create a standard TransferTokenRequest using the setConfirmFunds() function to indicate that should be performed prior to transfer token redemption. However, not all banks support CAF as part of a transfer request. In these cases, setConfirmFunds() is ignored when included in the transfer token request.