Payment_Intent_Handler::update_payment_intent( array $data, WP_Post $order )
Updates an existing payment intent to add any necessary data before confirming the purchase.
Contents
Parameters
- $data
-
(array) (Required) The purchase data received from the front-end.
- $order
-
(WP_Post) (Required) The order object.
Return
(array|WP_Error|null)
Source
File: src/Tickets/Commerce/Gateways/Stripe/Payment_Intent_Handler.php
public function update_payment_intent( $data, \WP_Post $order ) {
$body = [];
$payment_intent_id = $data['payment_intent']['id'];
$stripe_receipt_emails = tribe_get_option( Settings::$option_stripe_receipt_emails );
$payment_intent = Payment_Intent::get( $payment_intent_id );
// Add the Order ID as metadata to the Payment Intent
$metadata = $payment_intent['metadata'];
$metadata['order_id'] = $order->ID;
$metadata['return_url'] = tribe( Webhook_Endpoint::class )->get_route_url();
$body['metadata'] = $metadata;
if ( $stripe_receipt_emails ) {
if ( is_user_logged_in() ) {
$user = wp_get_current_user();
$body['receipt_email'] = $user->get( 'user_email' );
}
if ( ! empty( $data['purchaser']['email'] ) ) {
$body['receipt_email'] = $data['purchaser']['email'];
}
}
return Payment_Intent::update( $payment_intent_id, $body );
}
Changelog
| Version | Description |
|---|---|
| 5.8.1 | Added customer's name / event name to the payment intent description |
| 5.3.0 | Introduced. |