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

Add Stripe.cleanup API, remove NOT NULL constraint on is_live field

parent 307d80b9
No related branches found
No related tags found
1 merge request!40Add Stripe.cleanup API, remove NOT NULL constraint on is_live field
......@@ -397,4 +397,14 @@ class CRM_Stripe_Upgrader extends CRM_Stripe_Upgrader_Base {
return TRUE;
}
public function upgrade_5022() {
$this->ctx->log->info('Applying Stripe update 5021. Remove is_live NOT NULL constraint as we don\'t use this parameter any more');
if (CRM_Core_BAO_SchemaHandler::checkIfFieldExists('civicrm_stripe_customers', 'is_live', FALSE)) {
CRM_Core_DAO::executeQuery('ALTER TABLE `civicrm_stripe_customers`
MODIFY COLUMN `is_live` tinyint(4) COMMENT "Whether this is a live or test transaction"');
}
return TRUE;
}
}
<?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([]);
}
......@@ -3,19 +3,23 @@ This extension comes with several APIs to help you troubleshoot problems. These
The api commands are:
* `Listevents`: Events are the notifications that Stripe sends to the Webhook. Listevents will list all notifications that have been sent. You can further restrict them with the following parameters:
* `ppid` - Use the given Payment Processor ID. By default, uses the saved, live Stripe payment processor and throws an error if there is more than one.
* `type` - Limit to the given Stripe events type. By default, show invoice.payment_succeeded. Change to 'all' to show all.
* `output` - What information to show. Defaults to 'brief' which provides a summary. Alternatively use raw to get the raw JSON returned by Stripe.
* `limit` - Limit number of results returned (100 is max, 10 is default).
* `starting_after` - Only return results after this event id. This can be used for paging purposes - if you want to retreive more than 100 results.
* `Populatelog`: If you are running a version of CiviCRM that supports the SystemLog - then this API call will populate your SystemLog with all of your past Stripe Events. You can safely re-run and not create duplicates. With a populated SystemLog - you can selectively replay events that may have caused errors the first time or otherwise not been properly recorded. Parameters:
* `ppid` - Use the given Payment Processor ID. By default, uses the saved, live Stripe payment processor and throws an error if there is more than one.
* `Ipn`: Replay a given Stripe Event. Parameters. This will always fetch the chosen Event from Stripe before replaying.
* `id` - The id from the SystemLog of the event to replay.
* `evtid` - The Event ID as provided by Stripe.
* `ppid` - Use the given Payment Processor ID. By default, uses the saved, live Stripe payment processor and throws an error if there is more than one.
* `noreceipt` - Set to 1 if you want to suppress the generation of receipts or set to 0 or leave out to send receipts normally.
* `Listevents`: Events are the notifications that Stripe sends to the Webhook. Listevents will list all notifications that have been sent. You can further restrict them with the following parameters:
* `ppid` - Use the given Payment Processor ID. By default, uses the saved, live Stripe payment processor and throws an error if there is more than one.
* `type` - Limit to the given Stripe events type. By default, show invoice.payment_succeeded. Change to 'all' to show all.
* `output` - What information to show. Defaults to 'brief' which provides a summary. Alternatively use raw to get the raw JSON returned by Stripe.
* `limit` - Limit number of results returned (100 is max, 10 is default).
* `starting_after` - Only return results after this event id. This can be used for paging purposes - if you want to retreive more than 100 results.
* `Populatelog`: If you are running a version of CiviCRM that supports the SystemLog - then this API call will populate your SystemLog with all of your past Stripe Events. You can safely re-run and not create duplicates. With a populated SystemLog - you can selectively replay events that may have caused errors the first time or otherwise not been properly recorded. Parameters:
* `ppid` - Use the given Payment Processor ID. By default, uses the saved, live Stripe payment processor and throws an error if there is more than one.
* `Ipn`: Replay a given Stripe Event. Parameters. This will always fetch the chosen Event from Stripe before replaying.
* `id` - The id from the SystemLog of the event to replay.
* `evtid` - The Event ID as provided by Stripe.
* `ppid` - Use the given Payment Processor ID. By default, uses the saved, live Stripe payment processor and throws an error if there is more than one.
* `noreceipt` - Set to 1 if you want to suppress the generation of receipts or set to 0 or leave out to send receipts normally.
* `Cleanup`: Cleanup and remove old database tables/fields that are no longer required.
## StripeCustomer
......
/* Remove Stripe tables on uninstall. */
DROP TABLE civicrm_stripe_customers;
DROP TABLE IF EXISTS civicrm_stripe_customers;
DROP TABLE IF EXISTS civicrm_stripe_plans;
DROP TABLE IF EXISTS civicrm_stripe_subscriptions;
\ No newline at end of file
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