| Conditions | 3 |
| Paths | 4 |
| Total Lines | 30 |
| Code Lines | 14 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 12 |
| Changes | 0 | ||
| 1 | <?php |
||
| 29 | public static function update_payment( Payment $payment, PaymentResultResponse $response ) { |
||
| 30 | // Add note. |
||
| 31 | $note = sprintf( |
||
| 32 | '<p>%1$s</p><pre>%2$s</pre>', |
||
| 33 | sprintf( |
||
| 34 | /* translators: %s: payment provider name */ |
||
| 35 | __( 'Verified payment result.', 'pronamic_ideal' ), |
||
| 36 | __( 'Adyen', 'pronamic_ideal' ) |
||
| 37 | ), |
||
| 38 | wp_json_encode( $response->get_json(), JSON_PRETTY_PRINT ) |
||
|
|
|||
| 39 | ); |
||
| 40 | |||
| 41 | $payment->add_note( $note ); |
||
| 42 | |||
| 43 | // PSP reference. |
||
| 44 | $psp_reference = $response->get_psp_reference(); |
||
| 45 | |||
| 46 | if ( null !== $psp_reference ) { |
||
| 47 | $payment->set_transaction_id( $psp_reference ); |
||
| 48 | } |
||
| 49 | |||
| 50 | // Result code. |
||
| 51 | $result_code = $response->get_result_code(); |
||
| 52 | |||
| 53 | if ( null !== $result_code ) { |
||
| 54 | $payment->set_status( ResultCode::transform( $result_code ) ); |
||
| 55 | } |
||
| 56 | |||
| 57 | // Payment save. |
||
| 58 | $payment->save(); |
||
| 59 | } |
||
| 61 |