Hello,
I’m trying to create a code snippet that will be executed when a user completed a booking payment : I need to add some conditions depending of the payment gateway used for the order.
I tried something like that (for Paypal) :
add_action( 'hp_booking_payment_completed', 'update_booking_status', 10, 2 );
function update_booking_status( $booking_id, $payment_gateway ) {
if ( ! $booking_id ) {
return;
}
$booking = hp_booking_get( $booking_id );
if ( $payment_gateway === 'ppcp-gateway' && $booking->get_status() === 'processing' ) {
$booking->set_status( 'completed' );
$booking->save();
wp_redirect( hp_booking_get_permalink( $booking_id ) );
exit;
}
}
But, it looks that the hook itself isn’t right.
Thanks for your help!