: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
* Class for the Stripe API.
* @link https://stripe.com/docs/api
const api_version = '2022-11-15';
const partner_id = 'pp_partner_HHbvqLh1AaO7Am';
const app_name = 'WordPress Contact Form 7';
const app_url = 'https://contactform7.com/stripe-integration/';
* @param string $secret Secret key.
public function __construct( $secret ) {
* Sends a debug information for a remote request to the PHP error log.
* @param string $url URL to retrieve.
* @param array $request Request arguments.
* @param array|WP_Error $response The response or WP_Error on failure.
private function log( $url, $request, $response ) {
wpcf7_log_remote_request( $url, $request, $response );
* Returns default set of HTTP request headers used for Stripe API.
* @link https://stripe.com/docs/building-plugins#setappinfo
* @return array An associative array of headers.
private function default_headers() {
'name' => self::app_name,
'partner_id' => self::partner_id,
'version' => WPCF7_VERSION,
'lang_version' => PHP_VERSION,
'application' => $app_info,
'Authorization' => sprintf( 'Bearer %s', $this->secret ),
'Stripe-Version' => self::api_version,
'X-Stripe-Client-User-Agent' => wp_json_encode( $ua ),
* Creates a Payment Intent.
* @link https://stripe.com/docs/api/payment_intents/create
* @param string|array $args Optional. Arguments to control behavior.
* @return array|bool An associative array if 200 OK, false otherwise.
public function create_payment_intent( $args = '' ) {
$args = wp_parse_args( $args, array(
if ( ! is_email( $args['receipt_email'] ) ) {
unset( $args['receipt_email'] );
$endpoint = 'https://api.stripe.com/v1/payment_intents';
'headers' => $this->default_headers(),
$response = wp_remote_post( sanitize_url( $endpoint ), $request );
if ( 200 != wp_remote_retrieve_response_code( $response ) ) {
$this->log( $endpoint, $request, $response );
$response_body = wp_remote_retrieve_body( $response );
$response_body = json_decode( $response_body, true );
* Retrieve a Payment Intent.
* @link https://stripe.com/docs/api/payment_intents/retrieve
* @param string $id Payment Intent identifier.
* @return array|bool An associative array if 200 OK, false otherwise.
public function retrieve_payment_intent( $id ) {
'https://api.stripe.com/v1/payment_intents/%s',
'headers' => $this->default_headers(),
$response = wp_remote_get( sanitize_url( $endpoint ), $request );
if ( 200 != wp_remote_retrieve_response_code( $response ) ) {
$this->log( $endpoint, $request, $response );
$response_body = wp_remote_retrieve_body( $response );
$response_body = json_decode( $response_body, true );