/home/vianto5/heredit.mx/wp-content/plugins/wpforms/src/Integrations/PayPalCommerce
NameSizeModeActions
Admin/-0755rm
Api/-0755rm
Fields/-0755rm
Frontend/-0755rm
Integrations/-0755rm
PaymentMethods/-0755rm
Process/-0755rm
Traits/-0755rm
AddonCompatibility.php14770644editdlrm
Connection.php84690644editdlrm
Helpers.php119000644editdlrm
PayPalCommerce.php83690644editdlrm
WebhooksHealthCheck.php75450644editdlrm
Edit: /home/vianto5/heredit.mx/wp-content/plugins/wpforms/src/Integrations/PayPalCommerce/Connection.php (8469B)
access_token = $data['access_token']; } if ( ! empty( $data['access_token_expires_in'] ) ) { $this->access_token_expires_in = $data['access_token_expires_in']; } if ( ! empty( $data['client_token'] ) ) { $this->client_token = $data['client_token']; } if ( ! empty( $data['client_token_expires_in'] ) ) { $this->client_token_expires_in = $data['client_token_expires_in']; } if ( ! empty( $data['sdk_client_token'] ) ) { $this->sdk_client_token = $data['sdk_client_token']; } if ( ! empty( $data['sdk_client_token_expires_in'] ) ) { $this->sdk_client_token_expires_in = $data['sdk_client_token_expires_in']; } if ( ! empty( $data['client_id'] ) ) { $this->client_id = $data['client_id']; } if ( ! empty( $data['partner_merchant_id'] ) ) { $this->partner_merchant_id = $data['partner_merchant_id']; } if ( ! empty( $data['merchant_id'] ) ) { $this->merchant_id = $data['merchant_id']; } if ( ! empty( $data['type'] ) ) { $this->type = $data['type']; } if ( ! empty( $data['secret'] ) ) { $this->secret = $data['secret']; } $this->is_live_mode = ! empty( $data['mode'] ) ? $data['mode'] === Helpers::PRODUCTION : Helpers::is_production_mode(); $this->set_status( empty( $data['status'] ) ? self::STATUS_VALID : $data['status'] ); } /** * Retrieve a connection instance if it exists. * * @since 1.10.0 * * @param string $mode PayPal Commerce mode. * * @return Connection|null */ public static function get( string $mode = '' ) { $mode = Helpers::validate_mode( $mode ); $connections = self::get_connections(); if ( empty( $connections[ $mode ] ) ) { return null; } // Default to the current class. $class = static::class; if ( Helpers::is_pro() && Helpers::is_legacy() ) { // phpcs:ignore WPForms.PHP.BackSlash.UseShortSyntax $class = \WPFormsPaypalCommerce\Connection::class; } $connection_data = (array) $connections[ $mode ]; $connection_data['mode'] = $mode; return new $class( $connection_data ); } /** * Update the connection status for the current PayPal Commerce mode. * * The option is updated only when the status value has changed to avoid * unnecessary database writes and update_option hooks. * * @since 1.10.0 * * @param string $status New connection status value. */ public function update_connection_status( string $status ): void { $connections = (array) get_option( 'wpforms_paypal_commerce_connections', [] ); $mode = $this->get_mode(); $current = $connections[ $mode ]['status'] ?? null; // Do not update if the value is unchanged. if ( $current === $status ) { return; } $connections[ $mode ]['status'] = $status; update_option( 'wpforms_paypal_commerce_connections', $connections ); } /** * Retrieve a connection in array format, similar to the `toArray` method. * * @since 1.10.0 * * @return array */ private function get_data(): array { return [ 'access_token' => $this->access_token, 'access_token_expires_in' => $this->access_token_expires_in, 'client_token' => $this->client_token, 'client_token_expires_in' => $this->client_token_expires_in, 'sdk_client_token' => $this->sdk_client_token, 'sdk_client_token_expires_in' => $this->sdk_client_token_expires_in, 'client_id' => $this->client_id, 'partner_merchant_id' => $this->partner_merchant_id, 'merchant_id' => $this->merchant_id, 'secret' => $this->secret, 'status' => $this->status, 'type' => $this->type, ]; } /** * Set an access token. * * @since 1.10.0 * * @param string $token Token. * * @return Connection */ public function set_access_token( string $token ): Connection { $this->access_token = $token; return $this; } /** * Set access token expires in time. * * @since 1.10.0 * * @param int $expires_in Expires in time. * * @return Connection */ public function set_access_token_expires_in( int $expires_in ): Connection { $this->access_token_expires_in = $expires_in; return $this; } /** * Set the client token. * * @since 1.10.0 * * @param string $token Token. * * @return Connection */ public function set_client_token( string $token ): Connection { $this->client_token = $token; return $this; } /** * Set client token expires in time. * * @since 1.10.0 * * @param int $expires_in Expires in time. * * @return Connection */ public function set_client_token_expires_in( int $expires_in ): Connection { $this->client_token_expires_in = $expires_in; return $this; } /** * Retrieve a secret of the authorized merchant. * * @since 1.10.0 * * @return string */ public function get_secret(): string { return $this->secret; } /** * Set a connection status. * * @since 1.10.0 * * @param string $status The connection status. * * @return Connection */ public function set_status( string $status ): Connection { $this->status = $status; return $this; } /** * Get connections from DB. * * @since 1.10.0 * * @return array Connections. */ private static function get_connections(): array { return (array) get_option( self::OPTION_NAME_CONNECTIONS, [] ); } /** * Refresh expired tokens. * * @since 1.10.0 */ public function refresh_expired_tokens(): Connection { if ( $this->is_access_token_expired() ) { Connect::refresh_access_token( $this ); } if ( $this->is_client_token_expired() ) { Connect::refresh_client_token( $this ); } if ( $this->is_sdk_client_token_expired() ) { Connect::refresh_sdk_client_token( $this ); } return $this; } }