@@ 580-607 (lines=28) @@ | ||
577 | * @since 4.0.6 |
|
578 | * @param object $notification |
|
579 | */ |
|
580 | public function process_review_opened( $notification ) { |
|
581 | if ( isset( $notification->data->object->payment_intent ) ) { |
|
582 | $order = WC_Stripe_Helper::get_order_by_intent_id( $notification->data->object->payment_intent ); |
|
583 | ||
584 | if ( ! $order ) { |
|
585 | WC_Stripe_Logger::log( '[Review Opened] Could not find order via intent ID: ' . $notification->data->object->payment_intent ); |
|
586 | return; |
|
587 | } |
|
588 | } else { |
|
589 | $order = WC_Stripe_Helper::get_order_by_charge_id( $notification->data->object->charge ); |
|
590 | ||
591 | if ( ! $order ) { |
|
592 | WC_Stripe_Logger::log( '[Review Opened] Could not find order via charge ID: ' . $notification->data->object->charge ); |
|
593 | return; |
|
594 | } |
|
595 | } |
|
596 | ||
597 | $order->update_meta_data( '_stripe_status_before_hold', $order->get_status() ); |
|
598 | ||
599 | /* translators: 1) The URL to the order. 2) The reason type. */ |
|
600 | $message = sprintf( __( 'A review has been opened for this order. Action is needed. Please go to your <a href="%1$s" title="Stripe Dashboard" target="_blank">Stripe Dashboard</a> to review the issue. Reason: (%2$s)', 'woocommerce-gateway-stripe' ), $this->get_transaction_url( $order ), $notification->data->object->reason ); |
|
601 | ||
602 | if ( apply_filters( 'wc_stripe_webhook_review_change_order_status', true, $order, $notification ) && ! $order->get_meta( '_stripe_status_final', false ) ) { |
|
603 | $order->update_status( 'on-hold', $message ); |
|
604 | } else { |
|
605 | $order->add_order_note( $message ); |
|
606 | } |
|
607 | } |
|
608 | ||
609 | /** |
|
610 | * Process webhook reviews that are closed. i.e Radar. |
|
@@ 615-644 (lines=30) @@ | ||
612 | * @since 4.0.6 |
|
613 | * @param object $notification |
|
614 | */ |
|
615 | public function process_review_closed( $notification ) { |
|
616 | if ( isset( $notification->data->object->payment_intent ) ) { |
|
617 | $order = WC_Stripe_Helper::get_order_by_intent_id( $notification->data->object->payment_intent ); |
|
618 | ||
619 | if ( ! $order ) { |
|
620 | WC_Stripe_Logger::log( '[Review Closed] Could not find order via intent ID: ' . $notification->data->object->payment_intent ); |
|
621 | return; |
|
622 | } |
|
623 | } else { |
|
624 | $order = WC_Stripe_Helper::get_order_by_charge_id( $notification->data->object->charge ); |
|
625 | ||
626 | if ( ! $order ) { |
|
627 | WC_Stripe_Logger::log( '[Review Closed] Could not find order via charge ID: ' . $notification->data->object->charge ); |
|
628 | return; |
|
629 | } |
|
630 | } |
|
631 | ||
632 | /* translators: 1) The reason type. */ |
|
633 | $message = sprintf( __( 'The opened review for this order is now closed. Reason: (%s)', 'woocommerce-gateway-stripe' ), $notification->data->object->reason ); |
|
634 | ||
635 | if ( |
|
636 | $order->has_status( 'on-hold' ) && |
|
637 | apply_filters( 'wc_stripe_webhook_review_change_order_status', true, $order, $notification ) && |
|
638 | ! $order->get_meta( '_stripe_status_final', false ) |
|
639 | ) { |
|
640 | $order->update_status( $order->get_meta( '_stripe_status_before_hold', 'processing' ), $message ); |
|
641 | } else { |
|
642 | $order->add_order_note( $message ); |
|
643 | } |
|
644 | } |
|
645 | ||
646 | /** |
|
647 | * Checks if capture is partial. |