WPCF7_Stripe_API::retrieve_payment_intent()publicCF7 1.0

Retrieve a Payment Intent.

Метод класса: WPCF7_Stripe_API{}

Хуков нет.

Возвращает

Массив|true|false. An associative array if 200 OK, false otherwise.

Использование

$WPCF7_Stripe_API = new WPCF7_Stripe_API();
$WPCF7_Stripe_API->retrieve_payment_intent( $id );
$id(строка) (обязательный)
Payment Intent identifier.

Код WPCF7_Stripe_API::retrieve_payment_intent() CF7 5.9.8

public function retrieve_payment_intent( $id ) {
	$endpoint = sprintf(
		'https://api.stripe.com/v1/payment_intents/%s',
		urlencode( $id )
	);

	$request = array(
		'headers' => $this->default_headers(),
	);

	$response = wp_remote_get( sanitize_url( $endpoint ), $request );

	if ( 200 != wp_remote_retrieve_response_code( $response ) ) {
		if ( WP_DEBUG ) {
			$this->log( $endpoint, $request, $response );
		}

		return false;
	}

	$response_body = wp_remote_retrieve_body( $response );
	$response_body = json_decode( $response_body, true );

	return $response_body;
}