| Conditions | 3 |
| Paths | 3 |
| Total Lines | 38 |
| Code Lines | 21 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 12 |
| Changes | 5 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 23 | public static function listen() { |
||
| 24 | $variable_names = array( |
||
| 25 | 'Status', |
||
| 26 | 'StatusCode', |
||
| 27 | 'Merchant', |
||
| 28 | 'OrderID', |
||
| 29 | 'PaymentID', |
||
| 30 | 'Reference', |
||
| 31 | 'TransactionID', |
||
| 32 | 'Checksum', |
||
| 33 | ); |
||
| 34 | |||
| 35 | if ( ! Util::input_has_vars( INPUT_POST, $variable_names ) ) { |
||
| 36 | return; |
||
| 37 | } |
||
| 38 | |||
| 39 | $reference = filter_input( INPUT_POST, 'OrderID', FILTER_SANITIZE_STRING ); |
||
| 40 | |||
| 41 | $payment = get_pronamic_payment( $reference ); |
||
| 42 | |||
| 43 | if ( null === $payment ) { |
||
| 44 | return; |
||
| 45 | } |
||
| 46 | |||
| 47 | // Add note. |
||
| 48 | $note = sprintf( |
||
| 49 | /* translators: %s: payment provider name */ |
||
| 50 | __( 'Webhook requested by %s.', 'pronamic_ideal' ), |
||
| 51 | __( 'ICEPAY', 'pronamic_ideal' ) |
||
| 52 | ); |
||
| 53 | |||
| 54 | $payment->add_note( $note ); |
||
| 55 | |||
| 56 | // Log webhook request. |
||
| 57 | do_action( 'pronamic_pay_webhook_log_payment', $payment ); |
||
| 58 | |||
| 59 | // Update payment. |
||
| 60 | Plugin::update_payment( $payment ); |
||
| 61 | } |
||
| 63 |