: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
namespace WPForms\Integrations\Stripe\Api\Webhooks;
use WPForms\Db\Payments\ValueValidator;
* Webhook customer.subscription.updated class.
class CustomerSubscriptionUpdated extends Base {
* Handle the Webhook's data.
* @throws RuntimeException If payment not found or not updated.
public function handle() {
( isset( $this->data->metadata->canceled_by ) && $this->data->metadata->canceled_by === 'wpforms_dashboard' ) ||
! ValueValidator::is_valid( $this->data->status, 'status' )
$payment = wpforms()->get( 'payment' )->get_by( 'subscription_id', $this->data->id );
$payment->subscription_status === $this->data->status ||
( ! empty( $this->data->previous_attributes->status ) && $this->data->previous_attributes->status !== $payment->subscription_status )
if ( ! wpforms()->get( 'payment' )->update( $payment->id, [ 'subscription_status' => $this->data->status ] ) ) {
throw new RuntimeException( 'Payment not updated' );
wpforms()->get( 'payment_meta' )->add_log(
sprintf( 'Stripe subscription was set to %1$s.', $this->data->status )