I created a PHP 7 script that uses an API Call to get some information about a specific Contribution with a $contributionID that has been defined before. The code (below) works and correctly returns payment_processor_id. BUT I cannot reproduce this in CiviCRM API Explorer v3.

My code is:

 $result2 = civicrm_api3('Contribution', 'get', [
            'sequential' => "1",
            'return' => ["payment_processor","instrument_id","payment_instrument_id","payment_processor_id"],
            'id' => $contributionID,
        $payment_instrument_id = $result2["values"]["0"]["payment_instrument_id"];
        $payment_processor_id = $result2["values"]["0"]["payment_processor_id"];
        echo "instrument ID: ";
        echo "processor ID: ";

where the resulting array does correctly contain a value for payment_instrument_id. When I try to reproduce this in API Explorer v3, I get an array response with the following structure:

    "is_error": 0,
    "version": 3,
    "count": 1,
    "id": 885,
    "values": [
            "contact_id": "2700",
            "contribution_id": "885",
            "payment_instrument_id": "8",
            "payment_instrument": "Lastschrift",
            "instrument_id": "8",
            "id": "885"

Obviously, there is no payment_processor_id here. So it is a big puzzle for me how the PHP API call can access an attribute that is not even there.

I entered the following values in API Explorer: Api explorer screenshot

You can see that the PHP code the API Explorer produces is exactly the same as I am using in the script. Does anybody have any idea why this difference occurs?

EDIT: If @Pradeep's answer is correct, wouldn't it be logical to add this 'check_permissions' => TRUE parameter in the PHP section of API Explorer? From my perspective, the code snippets in API Explorer should represent as exactly as possible the code that is actually executed.

  • The API explorer only returns the fields that has a non empty value in it. Eg if trxn_id for the contribution is empty, it will not return this value in the API explorer. Commented Sep 27, 2021 at 12:55
  • @jitendra The value is not empty, as the PHP API Call returns a value for the exact same Contribution ID.
    – emma
    Commented Sep 27, 2021 at 13:30
  • Are checking the results for same contribution ID? Commented Sep 27, 2021 at 13:55
  • Yes, I am checking for the exact same Contribution ID.
    – emma
    Commented Sep 27, 2021 at 14:00

1 Answer 1


From api explorer the results are retrieved using rest api where check_permissions is always set to TRUE by default even though its been explicitly set via api params.

If you have check_permissions set to TRUE than api returns only those fields which are defined for the the entity. In your case the fields would be

civicrm_api('Contribution', 'getfields', ['version' => 3, 'action' => 'get']);

Try adding 'check_permissions' => TRUE as a api parameter in your php code, it should return exact same results you get in api explorer.



  • This worked (once). But when I removed the check_permissions param again (or set it to FALSE) I couldn't get back the old value with my PHP script. Instead, an empty string or NULL appears in the payment_processor_id attribute of API result now.
    – emma
    Commented Sep 28, 2021 at 10:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.