Answers.Body: <p>Below query should give you all pending contributions from payment processor</p>
  <pre><code>SELECT cc.id, cc.contact_id, cc.total_amount, cpp.title, 
    cc.receive_date, cft.trxn_date, cc.invoice_id, cc.invoice_number, cc.trxn_id
  FROM civicrm_contribution cc 
    INNER JOIN civicrm_entity_financial_trxn ceft
      ON ceft.entity_id = cc.id AND ceft.entity_table = 'civicrm_contribution'
    INNER JOIN civicrm_financial_trxn cft
      ON cft.id = ceft.financial_trxn_id
    INNER JOIN civicrm_payment_processor cpp
      ON cpp.id = cft.payment_processor_id
  WHERE cc.contribution_status_id = 2 AND cc.is_pay_later = 0;
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-08-07T19:42:34.987Z
Answers.Text: The above query doesn't work for me... returns zero records. I'm finding that only 'Completed' transactions have records in the `civicrm_entity_financial_trxn` table.
Answers.UserDisplayName: Martin_W
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-08-07T18:49:31.687Z
Answers.LastActivityDate: 2020-08-07T18:49:31.687Z
Answers.UserDisplayName: Pradeep Nayak
Body: <p>Is there a way to determine the Payment Processor for &quot;pending&quot; transactions? Our site has both Authorize.Net and PayPal Standard configured as payment methods, and I'm seeing and trying to debug lots of &quot;pending&quot; transactions (running on WordPress v.5.4.2, Civi v.5.25.0 -- just upgraded to 5.28.0, but the pending transactions have been happening since before then).</p>
  <p>Or: should all of the &quot;pending&quot; transactions always only be from PayPal, since Auth.Net should complete immediately without IPN callback? And even for Auth.Net recurring transactions? (Since in principle one can configure and use multiple PayPal Payment Processors, it would still be helpful to be able to disambiguate pending transactions for those.)</p>
  <p>I've explored the database, and I see that once a transaction has completed, I can get the Payment Processor via the <code>civicrm_financial_trxn</code> table (SQL below). But for 'pending', I haven't been able to track anything down.</p>
  <pre><code>select y.name `Payment Processor`
      , p.title
      , c.receive_date
      , c.id `contrib_id`
      , c.contribution_recur_id
      , c.invoice_id
      , c.trxn_id
      , case when c.contribution_status_id = 1 then 'Completed'
          when c.contribution_status_id = 2 then 'Pending'
          when c.contribution_status_id = 4 then 'Failed'
          else c.contribution_status_id end `Contrib Status`
      , t.payment_processor_id
      , y.url_site `Processor URL`
      , c.contact_id
      , c.total_amount
      , c.fee_amount
      , c.net_amount
      from civicrm_contribution c
      inner join civicrm_contribution_page p on p.id = c.contribution_page_id
      left join civicrm_financial_trxn t on t.trxn_id = c.trxn_id
      left join civicrm_payment_processor y on t.payment_processor_id = y.id
      where c.receive_date &gt;= '2020-06-01'
      and c.is_test = 0 and c.is_pay_later = 0
      and t.from_financial_account_id is null
      order by c.contribution_status_id, c.receive_date, y.name, c.id desc;
  </code></pre>
  <p>(The <code>t.from_financial_account_id is null</code> clause prevents multiple matches with <code>civicrm_financial_trxn</code> table, since has multiple records for a single transaction when there are transaction fees.)</p>
  
Tags: <civicontribute><payment-processor><pending>
Title: How to determine Payment Processor for "pending" transactions (via SQL or otherwise)?
ThreadText: # How to determine Payment Processor for "pending" transactions (via SQL or otherwise)?
  
  (Asked by: username_0 on 2020-08-07)
  
  Is there a way to determine the Payment Processor for "pending" transactions? Our site has both Authorize.Net and PayPal Standard configured as payment methods, and I'm seeing and trying to debug lots of "pending" transactions (running on WordPress v.5.4.2, Civi v.5.25.0 -- just upgraded to 5.28.0, but the pending transactions have been happening since before then).
  Or: should all of the "pending" transactions always only be from PayPal, since Auth.Net should complete immediately without IPN callback? And even for Auth.Net recurring transactions? (Since in principle one can configure and use multiple PayPal Payment Processors, it would still be helpful to be able to disambiguate pending transactions for those.)
  I've explored the database, and I see that once a transaction has completed, I can get the Payment Processor via the civicrm_financial_trxn table (SQL below). But for 'pending', I haven't been able to track anything down.
  select y.name `Payment Processor`
      , p.title
      , c.receive_date
      , c.id `contrib_id`
      , c.contribution_recur_id
      , c.invoice_id
      , c.trxn_id
      , case when c.contribution_status_id = 1 then 'Completed'
          when c.contribution_status_id = 2 then 'Pending'
          when c.contribution_status_id = 4 then 'Failed'
          else c.contribution_status_id end `Contrib Status`
      , t.payment_processor_id
      , y.url_site `Processor URL`
      , c.contact_id
      , c.total_amount
      , c.fee_amount
      , c.net_amount
      from civicrm_contribution c
      inner join civicrm_contribution_page p on p.id = c.contribution_page_id
      left join civicrm_financial_trxn t on t.trxn_id = c.trxn_id
      left join civicrm_payment_processor y on t.payment_processor_id = y.id
      where c.receive_date >= '2020-06-01'
      and c.is_test = 0 and c.is_pay_later = 0
      and t.from_financial_account_id is null
      order by c.contribution_status_id, c.receive_date, y.name, c.id desc;
  
  (The t.from_financial_account_id is null clause prevents multiple matches with civicrm_financial_trxn table, since has multiple records for a single transaction when there are transaction fees.)
  
  **Tags:** civicontribute, payment-processor, pending
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2020-08-07. Score: 0
  
  Below query should give you all pending contributions from payment processor
  SELECT cc.id, cc.contact_id, cc.total_amount, cpp.title, 
    cc.receive_date, cft.trxn_date, cc.invoice_id, cc.invoice_number, cc.trxn_id
  FROM civicrm_contribution cc 
    INNER JOIN civicrm_entity_financial_trxn ceft
      ON ceft.entity_id = cc.id AND ceft.entity_table = 'civicrm_contribution'
    INNER JOIN civicrm_financial_trxn cft
      ON cft.id = ceft.financial_trxn_id
    INNER JOIN civicrm_payment_processor cpp
      ON cpp.id = cft.payment_processor_id
  WHERE cc.contribution_status_id = 2 AND cc.is_pay_later = 0;
  
  > **Comments:**
  > **username_0**: The above query doesn't work for me... returns zero records. I'm finding that only 'Completed' transactions have records in the `civicrm_entity_financial_trxn` table.  
  
  ---
  
  