Skip to content
Snippets Groups Projects
Commit 2eedc5b8 authored by Rich's avatar Rich
Browse files

Order API - more WIP work

parent 1593f73c
No related branches found
No related tags found
No related merge requests found
The Order API is intended to be used as the primary API for adding, updating, and deleting orders.
The Order API is intended to be used as the primary API for adding, updating, and deleting orders.
An 'order' is a non-CiviCRM term that corresponds to how CiviCRM uses its contribution object in terms of handling the full life-cycle of a purchase of memberships, event registrations or making a donation. Unlike most APIs, there is no table directly associated with the Order API.
An 'order' is a non-CiviCRM term that corresponds to how CiviCRM uses its contribution object in terms of handling the full life-cycle of a purchase of memberships, event registrations or making a donation. Unlike most APIs, there is no table directly associated with the Order API.
Donations, memberships and event registrations are all potential line items in an order/contribution. Pledge payments via a contribution's line item are a potential future enhancement.
The Order API wraps the creation of associated objects like memberships and event registrations. In other words, don't create the objects first before adding them as an array of `line_item`.create parameters; instead rely on the Order API to create them for you.
The Order API wraps the creation of associated objects like memberships and event registrations. In other words, don't create the objects first before adding them as an array of `line_item`.create parameters; instead rely on the Order API to create them for you.
On creation, the status of contribution and any related memberships or event registrations is Pending if the contribution is pending.
On creation, the status of contribution and any related memberships or event registrations is Pending if the contribution is pending.
If you later remove a line item for a membership or event registration on an update to an order, the Order API will look after changing the status for the related membership and event registration objects.
......@@ -198,14 +198,122 @@ Contribution, with a Pending Membership.
}
```
After this, when we call `Payment.create` to complete the transaction the membership status will be recalculated to 'New';
After this, when we call `Payment.create` to complete the transaction the membership becomes live and its status will be recalculated (e.g. to 'New').
The `Order.get` request returns all the information about the contribution, the line items and the related membership:
```json
{
"contact_id": "202",
"contact_type": "Individual",
"contact_sub_type": "",
"sort_name": "Wilma",
"display_name": "Wilma",
"contribution_id": "101",
"currency": "USD",
"contribution_recur_id": "",
"contribution_status_id": "1",
"contribution_campaign_id": "",
"payment_instrument_id": "4",
"receive_date": "2019-10-09 17:13:10",
"non_deductible_amount": "0.00",
"total_amount": "100.00",
"fee_amount": "0.00",
"net_amount": "100.00",
"trxn_id": "",
"invoice_id": "",
"invoice_number": "",
"contribution_cancel_date": "",
"cancel_reason": "",
"receipt_date": "2019-10-09 17:13:10",
"thankyou_date": "",
"contribution_source": "",
"amount_level": "",
"is_test": "0",
"is_pay_later": "0",
"contribution_check_number": "",
"financial_account_id": "2",
"accounting_code": "4400",
"campaign_id": "",
"contribution_campaign_title": "",
"financial_type_id": "2",
"contribution_note": "",
"contribution_batch": "",
"civicrm_value_donor_information_3_id": "",
"custom_6": "",
"custom_5": "",
"contribution_recur_status": "Completed",
"payment_instrument": "Check",
"contribution_status": "Completed",
"financial_type": "Member Dues",
"check_number": "",
"instrument_id": "4",
"cancel_date": "",
"id": "101",
"contribution_type_id": "2",
"line_items": [
{
"id": "103",
"entity_table": "civicrm_membership",
"entity_id": "33",
"contribution_id": "101",
"price_field_id": "4",
"qty": "1.00",
"unit_price": "100.00",
"line_total": "100.00",
"price_field_value_id": "7",
"financial_type_id": "2",
"non_deductible_amount": "0.00",
"contribution_type_id": "2"
}
]
}
```
## Sample Order.create for Single Event Registration
@todo
Here is how to create an order for a single ticket purchase for an event.
```json
{
"contact_id": 202,
"total_amount": 1000.00,
"financial_type_id": "Event fee",
"receive_date": "2019-10-08",
"contribution_status_id": "Pending",
"line_items" : [
{
"params": {
"event_id": 3,
"contact_id": 202,
"role_id": "Attendee",
"status_id": "Pending from incomplete transaction"
},
"line_item": [
{
"entity_table":"civicrm_participant",
"price_field_id":"7",
"price_field_value_id":"14",
"qty":"1",
"unit_price":"1000.00",
"line_total":"1000.00"
}
]
}
]
}
```
Here is how to create an order for a single ticket purchase for an event. [Rich to provide]
Notes:
1. As with the other examples, we call it with `contribution_status_id` `Pending`.
2. The `params` define the participant.
3. The `line_item` entry defines the price field and its value.
4. On calling `Payment.create` for this order, the participant's status would be changed to Registered.
!!! bug
Curently you must pass in `"status_id": "Pending from incomplete transaction"` otherwise the participant is created as Registered even before the paymnet has been made.
## Sample Order.create for 4 line items
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment