File "CustomerSubscriptionDeleted.php"
Full path: C:/Inetpub/vhosts/drshti.com/httpdocs/wp-content/plugins/wpforms-lite/src/Integrations/Stripe/Api/Webhooks/CustomerSubscriptionDeleted.php
File
size: 930 B (930 B bytes)
MIME-type: text/x-php
Charset: utf-8
Download Open Edit Advanced Editor &nnbsp; Back
<?php
namespace WPForms\Integrations\Stripe\Api\Webhooks;
use RuntimeException;
use WPForms\Db\Payments\UpdateHelpers;
/**
* Webhook customer.subscription.deleted class.
*
* @since 1.8.4
*/
class CustomerSubscriptionDeleted extends Base {
/**
* Handle the Webhook's data.
*
* @since 1.8.4
*
* @throws RuntimeException If payment not found or not updated.
*
* @return bool
*/
public function handle() {
$payment = wpforms()->obj( 'payment' )->get_by( 'subscription_id', $this->data->object->id );
if ( ! $payment ) {
return false;
}
if ( isset( $this->data->object->metadata->canceled_by ) && $this->data->object->metadata->canceled_by === 'wpforms_dashboard' ) {
return false;
}
if ( ! UpdateHelpers::cancel_subscription( $payment->id, 'Stripe subscription cancelled from the Stripe dashboard.' ) ) {
throw new RuntimeException( 'Payment not updated' );
}
return true;
}
}