wp-pay-gateways /
ems-e-commerce
| 1 | <?php |
||
| 2 | |||
| 3 | namespace Pronamic\WordPress\Pay\Gateways\EMS\ECommerce; |
||
| 4 | |||
| 5 | use Pronamic\WordPress\Pay\Gateways\Common\AbstractIntegration; |
||
| 6 | |||
| 7 | /** |
||
| 8 | * Title: EMS e-Commerce integration |
||
| 9 | * Description: |
||
| 10 | * Copyright: 2005-2019 Pronamic |
||
| 11 | * Company: Pronamic |
||
| 12 | * |
||
| 13 | * @author Reüel van der Steege |
||
| 14 | * @version 2.0.3 |
||
| 15 | * @since 1.0.0 |
||
| 16 | */ |
||
| 17 | class Integration extends AbstractIntegration { |
||
| 18 | public function __construct() { |
||
| 19 | $this->id = 'ems-ecommerce'; |
||
| 20 | $this->name = 'EMS e-Commerce'; |
||
| 21 | $this->product_url = ''; |
||
| 22 | $this->dashboard_url = array( |
||
| 23 | __( 'test', 'pronamic_ideal' ) => 'https://test.ipg-online.com/vt/login', |
||
| 24 | __( 'live', 'pronamic_ideal' ) => 'https://www.ipg-online.com/vt/login', |
||
| 25 | ); |
||
| 26 | $this->provider = 'ems'; |
||
| 27 | $this->supports = array( |
||
| 28 | 'webhook', |
||
| 29 | 'webhook_log', |
||
| 30 | 'webhook_no_config', |
||
| 31 | ); |
||
| 32 | |||
| 33 | $this->set_manual_url( __( 'https://www.pronamic.eu/support/how-to-connect-ems-with-wordpress-via-pronamic-pay/', 'pronamic_ideal' ) ); |
||
|
0 ignored issues
–
show
|
|||
| 34 | |||
| 35 | // Actions |
||
| 36 | $function = array( __NAMESPACE__ . '\Listener', 'listen' ); |
||
| 37 | |||
| 38 | if ( ! has_action( 'wp_loaded', $function ) ) { |
||
| 39 | add_action( 'wp_loaded', $function ); |
||
| 40 | } |
||
| 41 | } |
||
| 42 | |||
| 43 | public function get_settings_fields() { |
||
| 44 | $fields = array(); |
||
| 45 | |||
| 46 | // Storename. |
||
| 47 | $fields[] = array( |
||
| 48 | 'section' => 'general', |
||
| 49 | 'filter' => FILTER_UNSAFE_RAW, |
||
| 50 | 'meta_key' => '_pronamic_gateway_ems_ecommerce_storename', |
||
| 51 | 'title' => _x( 'Storename', 'ems', 'pronamic_ideal' ), |
||
| 52 | 'type' => 'text', |
||
| 53 | 'classes' => array( 'code' ), |
||
| 54 | ); |
||
| 55 | |||
| 56 | // Shared secret. |
||
| 57 | $fields[] = array( |
||
| 58 | 'section' => 'general', |
||
| 59 | 'filter' => FILTER_UNSAFE_RAW, |
||
| 60 | 'meta_key' => '_pronamic_gateway_ems_ecommerce_secret', |
||
| 61 | 'title' => _x( 'Shared Secret', 'ems', 'pronamic_ideal' ), |
||
| 62 | 'type' => 'text', |
||
| 63 | 'classes' => array( 'large-text', 'code' ), |
||
| 64 | ); |
||
| 65 | |||
| 66 | // Purchase ID. |
||
| 67 | $fields[] = array( |
||
| 68 | 'section' => 'advanced', |
||
| 69 | 'filter' => array( |
||
| 70 | 'filter' => FILTER_SANITIZE_STRING, |
||
| 71 | 'flags' => FILTER_FLAG_NO_ENCODE_QUOTES, |
||
| 72 | ), |
||
| 73 | 'meta_key' => '_pronamic_gateway_ems_ecommerce_order_id', |
||
| 74 | 'title' => __( 'Order ID', 'pronamic_ideal' ), |
||
| 75 | 'type' => 'text', |
||
| 76 | 'classes' => array( 'regular-text', 'code' ), |
||
| 77 | 'tooltip' => sprintf( |
||
| 78 | /* translators: %s: <code>{orderId}</code> */ |
||
| 79 | __( 'The EMS e-Commerce %s parameter.', 'pronamic_ideal' ), |
||
| 80 | sprintf( '<code>%s</code>', 'orderId' ) |
||
| 81 | ), |
||
| 82 | 'description' => sprintf( |
||
| 83 | '%s %s<br />%s', |
||
| 84 | __( 'Available tags:', 'pronamic_ideal' ), |
||
| 85 | sprintf( |
||
| 86 | '<code>%s</code> <code>%s</code>', |
||
| 87 | '{order_id}', |
||
| 88 | '{payment_id}' |
||
| 89 | ), |
||
| 90 | sprintf( |
||
| 91 | /* translators: %s: {order_id} */ |
||
| 92 | __( 'Default: <code>%s</code>', 'pronamic_ideal' ), |
||
| 93 | '{order_id}' |
||
| 94 | ) |
||
| 95 | ), |
||
| 96 | ); |
||
| 97 | |||
| 98 | // Notification URL. |
||
| 99 | $fields[] = array( |
||
| 100 | 'section' => 'feedback', |
||
| 101 | /* translators: Translate 'notification' the same as in the EMS e-Commerce dashboard. */ |
||
| 102 | 'title' => _x( 'Notification URL', 'EMS e-Commerce', 'pronamic_ideal' ), |
||
| 103 | 'type' => 'text', |
||
| 104 | 'classes' => array( 'large-text', 'code' ), |
||
| 105 | 'value' => home_url( '/' ), |
||
| 106 | 'readonly' => true, |
||
| 107 | /* translators: Translate 'notification' the same as in the EMS e-Commerce dashboard. */ |
||
| 108 | 'tooltip' => _x( |
||
| 109 | 'The Notification URL as sent with each transaction to receive automatic payment status updates on.', |
||
| 110 | 'EMS e-Commerce', |
||
| 111 | 'pronamic_ideal' |
||
| 112 | ), |
||
| 113 | ); |
||
| 114 | |||
| 115 | return $fields; |
||
| 116 | } |
||
| 117 | |||
| 118 | public function get_config( $post_id ) { |
||
| 119 | $config = new Config(); |
||
| 120 | |||
| 121 | $config->storename = get_post_meta( $post_id, '_pronamic_gateway_ems_ecommerce_storename', true ); |
||
| 122 | $config->secret = get_post_meta( $post_id, '_pronamic_gateway_ems_ecommerce_secret', true ); |
||
| 123 | $config->mode = get_post_meta( $post_id, '_pronamic_gateway_mode', true ); |
||
|
0 ignored issues
–
show
It seems like
get_post_meta($post_id, ...ic_gateway_mode', true) can also be of type false. However, the property $mode is declared as type string. Maybe add an additional type check?
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 Either this assignment is in error or a type check should be added for that assignment. class Id
{
public $id;
public function __construct($id)
{
$this->id = $id;
}
}
class Account
{
/** @var Id $id */
public $id;
}
$account_id = false;
if (starsAreRight()) {
$account_id = new Id(42);
}
$account = new Account();
if ($account instanceof Id)
{
$account->id = $account_id;
}
Loading history...
|
|||
| 124 | $config->order_id = get_post_meta( $post_id, '_pronamic_gateway_ems_ecommerce_order_id', true ); |
||
| 125 | |||
| 126 | return $config; |
||
| 127 | } |
||
| 128 | |||
| 129 | /** |
||
| 130 | * Get gateway. |
||
| 131 | * |
||
| 132 | * @param int $post_id Post ID. |
||
| 133 | * @return Gateway |
||
| 134 | */ |
||
| 135 | public function get_gateway( $post_id ) { |
||
| 136 | return new Gateway( $this->get_config( $post_id ) ); |
||
| 137 | } |
||
| 138 | } |
||
| 139 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.