wp-pay-gateways /
targetpay
| 1 | <?php |
||
| 2 | |||
| 3 | namespace Pronamic\WordPress\Pay\Gateways\TargetPay; |
||
| 4 | |||
| 5 | use Pronamic\WordPress\Pay\AbstractGatewayIntegration; |
||
| 6 | |||
| 7 | /** |
||
| 8 | * Title: TargetPay integration |
||
| 9 | * Description: |
||
| 10 | * Copyright: 2005-2021 Pronamic |
||
| 11 | * Company: Pronamic |
||
| 12 | * |
||
| 13 | * @author Remco Tolsma |
||
| 14 | * @version 2.2.0 |
||
| 15 | * @since 1.0.0 |
||
| 16 | */ |
||
| 17 | class Integration extends AbstractGatewayIntegration { |
||
| 18 | /** |
||
| 19 | * Construct TargetPay integration. |
||
| 20 | * |
||
| 21 | * @param array $args Arguments. |
||
| 22 | */ |
||
| 23 | public function __construct( $args = array() ) { |
||
| 24 | $args = wp_parse_args( |
||
| 25 | $args, |
||
| 26 | array( |
||
| 27 | 'id' => 'targetpay-ideal', |
||
| 28 | 'name' => 'TargetPay - iDEAL', |
||
| 29 | 'product_url' => \__( 'https://www.targetpay.com/info/ideal?setlang=en', 'pronamic_ideal' ), |
||
| 30 | 'dashboard_url' => 'https://www.targetpay.com/login', |
||
| 31 | 'provider' => 'targetpay', |
||
| 32 | 'manual_url' => \__( 'https://www.pronamic.eu/support/how-to-connect-targetpay-with-wordpress-via-pronamic-pay/', 'pronamic_ideal' ), |
||
| 33 | 'deprecated' => true, |
||
| 34 | ) |
||
| 35 | ); |
||
| 36 | |||
| 37 | parent::__construct( $args ); |
||
| 38 | } |
||
| 39 | |||
| 40 | /** |
||
| 41 | * Get settings fields. |
||
| 42 | * |
||
| 43 | * @return array |
||
| 44 | */ |
||
| 45 | public function get_settings_fields() { |
||
| 46 | $fields = array(); |
||
| 47 | |||
| 48 | // Intro. |
||
| 49 | $fields[] = array( |
||
| 50 | 'section' => 'general', |
||
| 51 | 'type' => 'html', |
||
| 52 | 'html' => sprintf( |
||
| 53 | /* translators: 1: payment provider name */ |
||
| 54 | __( 'Account details are provided by %1$s after registration. These settings need to match with the %1$s dashboard.', 'pronamic_ideal' ), |
||
| 55 | __( 'TargetPay', 'pronamic_ideal' ) |
||
| 56 | ), |
||
| 57 | ); |
||
| 58 | |||
| 59 | // Layout Code. |
||
| 60 | $fields[] = array( |
||
| 61 | 'section' => 'general', |
||
| 62 | 'filter' => FILTER_SANITIZE_STRING, |
||
| 63 | 'meta_key' => '_pronamic_gateway_targetpay_layoutcode', |
||
| 64 | 'title' => __( 'Layout Code', 'pronamic_ideal' ), |
||
| 65 | 'type' => 'text', |
||
| 66 | 'tooltip' => __( 'Layout code as mentioned at <strong>Sub accounts</strong> in the TargetPay dashboard.', 'pronamic_ideal' ), |
||
| 67 | ); |
||
| 68 | |||
| 69 | return $fields; |
||
| 70 | } |
||
| 71 | |||
| 72 | public function get_config( $post_id ) { |
||
| 73 | $config = new Config(); |
||
| 74 | |||
| 75 | $config->layoutcode = get_post_meta( $post_id, '_pronamic_gateway_targetpay_layoutcode', true ); |
||
| 76 | $config->mode = get_post_meta( $post_id, '_pronamic_gateway_mode', true ); |
||
|
0 ignored issues
–
show
|
|||
| 77 | |||
| 78 | return $config; |
||
| 79 | } |
||
| 80 | |||
| 81 | /** |
||
| 82 | * Get gateway. |
||
| 83 | * |
||
| 84 | * @param int $post_id Post ID. |
||
| 85 | * @return Gateway |
||
| 86 | */ |
||
| 87 | public function get_gateway( $post_id ) { |
||
| 88 | return new Gateway( $this->get_config( $post_id ) ); |
||
| 89 | } |
||
| 90 | } |
||
| 91 |
Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.
For example, imagine you have a variable
$accountIdthat can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to theidproperty of an instance of theAccountclass. This class holds a proper account, so the id value must no longer be false.Either this assignment is in error or a type check should be added for that assignment.