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: ";
var_dump($payment_instrument_id);
echo "processor ID: ";
var_dump($payment_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:
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.