WPCF7_Stripe_API::create_payment_intent
Creates 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->create_payment_intent( $args );
- $args(строка|массив)
- Arguments to control behavior.
По умолчанию: ''
Код WPCF7_Stripe_API::create_payment_intent() WPCF7 Stripe API::create payment intent CF7 6.1.4
public function create_payment_intent( $args = '' ) {
$args = wp_parse_args( $args, array(
'amount' => 0,
'currency' => '',
'receipt_email' => '',
) );
if ( ! is_email( $args['receipt_email'] ) ) {
unset( $args['receipt_email'] );
}
$endpoint = 'https://api.stripe.com/v1/payment_intents';
$request = array(
'headers' => $this->default_headers(),
'body' => $args,
);
$response = wp_remote_post( 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;
}