Skip to content
Snippets Groups Projects
Commit fde6da11 authored by Andie Hunt's avatar Andie Hunt
Browse files

set processor_id if it is obvious

parent 87833fda
No related branches found
No related tags found
No related merge requests found
......@@ -68,6 +68,26 @@ class CRM_Stripe_Upgrader extends CRM_Stripe_Upgrader_Base {
CRM_Core_DAO::executeQuery('ALTER TABLE civicrm_stripe_customers ADD COLUMN `processor_id` int(10) DEFAULT NULL COMMENT "ID from civicrm_payment_processor"');
CRM_Core_DAO::executeQuery('ALTER TABLE civicrm_stripe_plans ADD COLUMN `processor_id` int(10) DEFAULT NULL COMMENT "ID from civicrm_payment_processor"');
CRM_Core_DAO::executeQuery('ALTER TABLE civicrm_stripe_subscriptions ADD COLUMN `processor_id` int(10) DEFAULT NULL COMMENT "ID from civicrm_payment_processor"');
try {
// Set processor ID if there's only one.
$processorCount = civicrm_api3('PaymentProcessorType', 'get', array(
'name' => "Stripe",
'api.PaymentProcessor.getcount' => array('is_test' => 0),
));
foreach ($processorCount['values'] as $processorType) {
if (!empty($processorType['api.PaymentProcessor.get']['id'])) {
$p = array(
1 => array($processorType['api.PaymentProcessor.get']['id'], 'Integer'),
);
CRM_Core_DAO::executeQuery('UPDATE civicrm_stripe_customers SET processor_id = %1 where processor_id IS NULL', $p);
CRM_Core_DAO::executeQuery('UPDATE civicrm_stripe_plans SET processor_id = %1 where processor_id IS NULL', $p);
CRM_Core_DAO::executeQuery('UPDATE civicrm_stripe_subscriptions SET processor_id = %1 where processor_id IS NULL', $p);
}
}
}
catch (CiviCRM_API3_Exception $e) {
return TRUE;
}
}
return TRUE;
}
......
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