Development, Infusionsoft Keap · Oct 21, 2022

Infusionsoft / Keap getting Method Matching error for chargeInvoice request (Solved!)

A quick fix for the Infusionsoft / Keap PHP SDK chargeInvoice method matching error where the notes parameter needed to be sent as a boolean instead of a string.

I ran into a strange Infusionsoft / Keap PHP SDK error while trying to run a chargeInvoice request.

The documentation made it look like one thing should work, but the SDK and API response clearly wanted something else.

The Problem

The request was failing with this error:

[critical] Uncaught PHP Exception Infusionsoft\Http\HttpException:
"No method matching arguments: java.lang.String, java.lang.Integer, java.lang.Boolean,
java.lang.String, java.lang.String, java.lang.Boolean"
at .../vendor/infusionsoft/php-sdk/src/Infusionsoft/Http/InfusionsoftSerializer.php ...

The Infusionsoft XML-RPC documentation said the notes parameter should be a string, but the method matching error showed that the API was expecting a boolean value in that position.

Infusionsoft chargeInvoice method matching error screenshot
Infusionsoft XML-RPC invoice payment documentation screenshot

The Solution

Instead of sending a string for $notes, I changed it to a boolean value of true, as the error hinted.

I do not know exactly what that value indicates internally, or what would happen if it were set to false, but I do know the request worked when true was passed.

Updated chargeInvoice request with boolean notes value

After that change, the request ran without an error.

Infusionsoft order page after successful chargeInvoice request

It looks like something was mismatched between the documentation and what the API expected. To make it work, I left the notes value as true.

Final PHP Code

<?php

$notes = true;

$invoicePaid = $infusionsoft->invoices()->chargeInvoice(
    $invoiceID,
    $notes,
    $creditCardID,
    $merchantAccountID,
    $bypassComissions
);

That solved the method matching error for this chargeInvoice request.