function _stripe_customer_delete in Stripe 7
Delete a Stripe customer and update its status in the database.
Parameters
string $customer_id: The known Stripe Customer ID.
Return value
bool If the customer was deleted, return TRUE.
File
- stripe_customer/
stripe_customer.module, line 259 - Provides integration with Stripe and Drupal Users as Customers.
Code
function _stripe_customer_delete($customer_id) {
stripe_load_library();
try {
$customer = _stripe_customer_retrieve($customer_id);
$customer
->delete();
if (!empty($customer->deleted)) {
// Do not delete the customer from the database, but change its status.
// Deleted customers still exist on Stripe for historical purposes.
db_query("UPDATE {stripe_customers} set status = :deleted WHERE customer_id = :id", array(
':deleted' => STRIPE_CUSTOMER_INACTIVE,
':id' => $customer_id,
));
return TRUE;
}
} catch (\Stripe\Error\InvalidRequest $e) {
drupal_set_message(t('There was an error deleting this customer: :error', array(
':error' => $e
->getMessage(),
)), 'error');
}
}