: 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\Queries;
use WPForms\Integrations\Stripe\Helpers;
* Webhook charge.succeeded class.
class ChargeSucceeded extends Base {
* Handle the Webhook's data.
* @throws RuntimeException If payment not found or not updated.
public function handle() {
if ( ! $this->db_payment ) {
// Handle a case when charge.succeeded was sent before invoice.payment_succeeded to update a payment method details.
if ( ! empty( $this->data->invoice ) ) {
$db_renewal = ( new Queries() )->get_renewal_by_invoice_id( $this->data->invoice );
if ( is_null( $db_renewal ) || empty( $this->data->payment_method_details ) ) {
$this->update_payment_method_details( $db_renewal->id, $this->data->payment_method_details );
// Update payment method details to keep them up to date.
if ( ! empty( $this->data->payment_method_details ) ) {
$this->update_payment_method_details( $this->db_payment->id, $this->data->payment_method_details );
if ( $this->db_payment->status !== 'processed' ) {
$currency = strtoupper( $this->data->currency );
$db_amount = wpforms_format_amount( $this->db_payment->total_amount );
$amount = wpforms_format_amount( $this->data->amount_captured / Helpers::get_decimals_amount( $currency ) );
if ( $amount !== $db_amount || ! $this->data->paid ) {
if ( ! $this->is_previous_statuses_matched() ) {
$updated_payment = wpforms()->get( 'payment' )->update(
'date_updated_gmt' => gmdate( 'Y-m-d H:i:s' ),
if ( ! $updated_payment ) {
throw new RuntimeException( 'Payment not updated' );
wpforms()->get( 'payment_meta' )->add_log(
'Stripe payment was completed.'