Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php
/**
* This api cleans up old data / tables in Stripe.
*
* This api should only be used if you have read the documentation and understand what it does.
*/
/**
* Stripe.Cleanup API specification
*
* @param array $spec description of fields supported by this API call
*
* @return void
*/
function _civicrm_api3_stripe_Cleanup_spec(&$spec) {
$spec['confirm'] = [
'api.required' => TRUE,
'type' => CRM_Utils_Type::T_BOOLEAN,
'title' => 'Set this to TRUE to execute this API function',
];
}
/**
* Stripe.Cleanup API
*
* @param $params
*
* @return array
* @throws \CiviCRM_API3_Exception
*/
function civicrm_api3_stripe_Cleanup($params) {
if (empty($params['confirm'])) {
throw new CiviCRM_API3_Exception('You must set the parameter "confirm" to run the Stripe.cleanup API');
}
CRM_Core_DAO::executeQuery('DROP TABLE IF EXISTS civicrm_stripe_plans');
CRM_Core_DAO::executeQuery('DROP TABLE IF EXISTS civicrm_stripe_subscriptions');
if (CRM_Core_BAO_SchemaHandler::checkIfFieldExists('civicrm_stripe_customers', 'is_live')) {
CRM_Core_DAO::executeQuery('ALTER TABLE `civicrm_stripe_customers` DROP COLUMN `is_live`');
}
if (CRM_Core_BAO_SchemaHandler::checkIfFieldExists('civicrm_stripe_customers', 'email')) {
CRM_Core_DAO::executeQuery('ALTER TABLE `civicrm_stripe_customers` DROP COLUMN `email`');
}
return civicrm_api3_create_success([]);
}