I register participants and payments via the API. Step 1: create a contribution for the buyer Step 2: create participants Step 3 create participant_payments linking the above.
The weird thing is that civi adds a line to the fee_level of the first participant stating "Contribution Amount: 1".
Why? Am I doing something wrong?
Following the suggestion of Jon G I have been able to pin this down to something related to price sets. Participants of events that do not use price sets do not get this "contribution amount: 1"-line.
Kind regards,
Janec
The api calls:
1) create participant:
public function createParticipant($civiEventId, $contactId, $customFields = [], $amount, $currency, $fee_level) {
$entity = 'Participant';
// Create filter.
$params = [
'event_id' => $civiEventId,
'contact_id' => $contactId,
'status_id' => "Registered",
'participant_role_id' => "deelnemer",
'participant_fee_level' => $fee_level,
'participant_fee_amount' => $amount,
'participant_fee_currency' => $currency
];
if (count($customFields) > 0 && is_array($customFields)) {
foreach ($customFields as $customFieldKey => $customFieldValue) {
if(is_integer($customFieldKey)){
$customId = "custom_".$customFieldKey;
} else {
$customId = $customFieldKey;
}
$params[$customId] = $customFieldValue;
}
}
$action = "create";
return $this->query($entity, $params, $action);
}
2) create contribution
public function createContribution($financial_type, $total_amount, $civi_id, $mollie_id, $date) {
$entity = 'Contribution';
$action = 'create';
// Create filter.
$params = [
'financial_type_id' => $financial_type,
'total_amount' => $total_amount,
'contact_id' => $civi_id,
'custom_100' => $mollie_id,
'receive_date' => $date,
'currency' => "EUR",
'source' => "Chiro.be via mollie",
];
return $this->query($entity, $params, $action);
}
3) create participantPayment
public function createParticipantPayment($participant_id, $contribution_id) {
$entity = 'ParticipantPayment';
$action = 'create';
// Create filter.
$params = [
'participant_id' => $participant_id,
'contribution_id' => $contribution_id,
];
return $this->query($entity, $params, $action);
}
using version 4.7.27.
default_contribution_amount
Price Set. There might be a param that I don't know of that you can pass to specify the Line Item? Meanwhile I suggest you have a look at the Order API, specifically this example.