Answers.Body: <p>Each contribution should have one or more payments.</p>
  <ol>
  <li><p>When you are creating contribution using contribution api with completed status a payment is recorded automatically.</p>
  </li>
  <li><p>If you creating contribution with pending status eg incase of check payments then when you receive payment from bank you use payment api to record payment for the pending contribution</p>
  </li>
  </ol>
  <p>In your case if you recording membership via code then i would suggest you to use Order api where you can pass membership and contribution params in the api params and it will create all required records in one call. You can refer <a href="https://github.com/civicrm/civicrm-core/blob/master/api/v3/examples/Order/Create.php" rel="nofollow noreferrer">here</a> on how you can use order api to create membership or participant records with its payment in one call.</p>
  <p>Cheers</p>
  <p>Pradeep</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-07-04T20:41:40.150Z
Answers.LastActivityDate: 2019-07-04T20:41:40.150Z
Answers.LastEditDate: 2020-06-17T09:00:50.810Z
Answers.UserDisplayName: Pradeep Nayak
Body: <p>I'm using the API to create Contacts start Memberships through a signup form. We are offering 1-year memberships at various price points, and I have those set up in CiviMember. My code successfully creates Memberships.</p>
  
  <p>What I'm trying to figure out are the API options for payments. There are API options for creating both a <code>Contribution</code> or a <code>Payment</code>.</p>
  
  <p><strong>Do I need to create both in my API call?</strong></p>
  
  <p>What I found was that a <code>Payment</code> requires a <code>contribution_id</code>, so it seems like they're connected. In another question I saw it's possible to associate multiple <code>Payment</code>s with one <code>Contribution</code>. It just seems these two concepts duplicate a lot. Is it correct then that a <code>Contribution</code> just records that a <code>Membership</code> price was agreed to, so it's like an itemized bill at a restaurant? And then that a <code>Payment</code> can be $20 in cash and the rest on a card (one or multiple <code>Payment</code>s)?</p>
  
  <p>Also, we accept checks, so I noticed that a <code>Contribution</code> can be marked with <code>is_pay_later</code> to capture that. Would that flow for a person registering with a check be that I create a <code>Contribution</code> with the API at first-signup to record their agreed-upon "bill," and upon receiving the check later a person manually enters the <code>Payment</code> in the backend?</p>
  
Tags: <civicontribute><api><contributions><payment>
Title: API Contributions and Payments
ThreadText: # API Contributions and Payments
  
  (Asked by: username_0 on 2019-07-04)
  
  I'm using the API to create Contacts start Memberships through a signup form. We are offering 1-year memberships at various price points, and I have those set up in CiviMember. My code successfully creates Memberships.
  
  What I'm trying to figure out are the API options for payments. There are API options for creating both a `Contribution` or a `Payment`.
  
  **Do I need to create both in my API call?**
  
  What I found was that a `Payment` requires a `contribution_id`, so it seems like they're connected. In another question I saw it's possible to associate multiple `Payment`s with one `Contribution`. It just seems these two concepts duplicate a lot. Is it correct then that a `Contribution` just records that a `Membership` price was agreed to, so it's like an itemized bill at a restaurant? And then that a `Payment` can be $20 in cash and the rest on a card (one or multiple `Payment`s)?
  
  Also, we accept checks, so I noticed that a `Contribution` can be marked with `is_pay_later` to capture that. Would that flow for a person registering with a check be that I create a `Contribution` with the API at first-signup to record their agreed-upon "bill," and upon receiving the check later a person manually enters the `Payment` in the backend?
  
  **Tags:** civicontribute, api, contributions, payment
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2019-07-04. Score: 1
  
  Each contribution should have one or more payments.
  
  1. When you are creating contribution using contribution api with completed status a payment is recorded automatically.
  2. If you creating contribution with pending status eg incase of check payments then when you receive payment from bank you use payment api to record payment for the pending contribution
  
  In your case if you recording membership via code then i would suggest you to use Order api where you can pass membership and contribution params in the api params and it will create all required records in one call. You can refer [here](https://github.com/civicrm/civicrm-core/blob/master/api/v3/examples/Order/Create.php) on how you can use order api to create membership or participant records with its payment in one call.
  
  Cheers
  
  Pradeep
  
  
  ---
  
  