Skip to content
Snippets Groups Projects
Commit bf043de0 authored by mattwire's avatar mattwire
Browse files

Merge branch 'master' into 'master'

Fixes some issues in test mode

Closes #34

See merge request !19
parents a5a60915 c112f611
No related branches found
No related tags found
1 merge request!19Fixes some issues in test mode
......@@ -449,23 +449,29 @@ class CRM_Core_Payment_StripeIPN extends CRM_Core_Payment_BaseIPN {
// Additional processing of values is only relevant if there is a subscription id.
if ($this->subscription_id) {
// Get info related to recurring contributions.
// Get the recurring contribution record associated with the Stripe subscription.
try {
$contributionRecur = civicrm_api3('ContributionRecur', 'getsingle', ['trxn_id' => $this->subscription_id]);
$this->contribution_recur_id = $contributionRecur['id'];
// Same approach as api repeattransaction. Find last contribution associated
// with our recurring contribution.
}
catch (Exception $e) {
$this->exception('Cannot find recurring contribution for subscription ID: ' . $this->subscription_id . '. ' . $e->getMessage());
}
}
// If a recurring contribution has been found, get the most recent contribution belonging to it.
if ($this->contribution_recur_id) {
try {
// Same approach as api repeattransaction.
$contribution = civicrm_api3('contribution', 'getsingle', array(
'return' => array('id', 'contribution_status_id', 'total_amount', 'trxn_id'),
'contribution_recur_id' => $this->contribution_recur_id,
'contribution_test' => $this->_paymentProcessor['is_test'],
'contribution_test' => isset($this->_paymentProcessor['is_test']) && $this->_paymentProcessor['is_test'] ? 1 : 0,
'options' => array('limit' => 1, 'sort' => 'id DESC'),
));
$this->previous_contribution = $contribution;
}
catch (Exception $e) {
$this->exception('Cannot find recurring contribution for subscription ID: ' . $this->subscription_id . '. ' . $e->getMessage());
$this->exception('Cannot find any contributions with recurring contribution ID: ' . $this->contribution_recur_id . '. ' . $e->getMessage());
}
}
}
......
......@@ -22,9 +22,10 @@ class CRM_Stripe_Customer {
}
$queryParams = [
1 => [$params['contact_id'], 'String'],
2 => [$params['is_live'], 'Boolean'],
2 => [$params['is_live'] ? 1 : 0, 'Boolean'],
3 => [$params['processor_id'], 'Positive'],
];
return CRM_Core_DAO::singleValueQuery("SELECT id
FROM civicrm_stripe_customers
......
  • A couple of spots where $params['is_live'] needs processing, it's still missing. I'm using following patch:

    diff --git a/CRM/Stripe/Customer.php b/CRM/Stripe/Customer.php
    index 67d821b..b3adf78 100644
    --- a/CRM/Stripe/Customer.php
    +++ b/CRM/Stripe/Customer.php
    @@ -50,7 +50,7 @@ class CRM_Stripe_Customer {
         $queryParams = [
           1 => [$params['contact_id'], 'String'],
           2 => [$params['customer_id'], 'String'],
    -      3 => [$params['is_live'], 'Boolean'],
    +      3 => [$params['is_live'] ? 1 : 0, 'Boolean'],
           4 => [$params['processor_id'], 'Integer'],
         ];
         CRM_Core_DAO::executeQuery("INSERT INTO civicrm_stripe_customers
    @@ -124,7 +124,7 @@ class CRM_Stripe_Customer {
    
         $queryParams = [
           1 => [$params['contact_id'], 'String'],
    -      2 => [$params['is_live'], 'Boolean'],
    +      2 => [$params['is_live'] ? 1 : 0, 'Boolean'],
           3 => [$params['processor_id'], 'Integer'],
         ];
         $sql = "DELETE FROM civicrm_stripe_customers
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