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