| Conditions | 5 |
| Paths | 4 |
| Total Lines | 28 |
| Code Lines | 13 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 30 |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 29 | public static function listen() { |
||
| 30 | if ( ! filter_has_var( INPUT_GET, 'ing_kassa_compleet_webhook' ) ) { |
||
| 31 | return; |
||
| 32 | } |
||
| 33 | |||
| 34 | $data = json_decode( file_get_contents( 'php://input' ) ); |
||
| 35 | |||
| 36 | if ( is_object( $data ) && isset( $data->order_id ) ) { |
||
| 37 | $payment = get_pronamic_payment_by_transaction_id( $data->order_id ); |
||
| 38 | |||
| 39 | if ( null === $payment ) { |
||
| 40 | return; |
||
| 41 | } |
||
| 42 | |||
| 43 | // Add note. |
||
| 44 | $note = sprintf( |
||
| 45 | /* translators: %s: payment provider name */ |
||
| 46 | __( 'Webhook requested by %s.', 'pronamic_ideal' ), |
||
| 47 | __( 'ING', 'pronamic_ideal' ) |
||
| 48 | ); |
||
| 49 | |||
| 50 | $payment->add_note( $note ); |
||
| 51 | |||
| 52 | // Log webhook request. |
||
| 53 | do_action( 'pronamic_pay_webhook_log_payment', $payment ); |
||
| 54 | |||
| 55 | // Update payment. |
||
| 56 | Plugin::update_payment( $payment, false ); |
||
| 57 | } |
||
| 60 |