wp-pay-gateways /
omnikassa
| 1 | <?php |
||
| 2 | |||
| 3 | namespace Pronamic\WordPress\Pay\Gateways\OmniKassa; |
||
| 4 | |||
| 5 | use Pronamic\WordPress\Pay\Gateways\Common\AbstractIntegration; |
||
| 6 | |||
| 7 | /** |
||
| 8 | * Title: OmniKassa integration |
||
| 9 | * Description: |
||
| 10 | * Copyright: 2005-2020 Pronamic |
||
| 11 | * Company: Pronamic |
||
| 12 | * |
||
| 13 | * @author Remco Tolsma |
||
| 14 | * @version 2.0.3 |
||
| 15 | * @since 1.0.0 |
||
| 16 | */ |
||
| 17 | class Integration extends AbstractIntegration { |
||
| 18 | public function __construct() { |
||
| 19 | parent::__construct(); |
||
| 20 | |||
| 21 | $this->id = 'rabobank-omnikassa'; |
||
| 22 | $this->name = 'Rabobank - OmniKassa'; |
||
| 23 | $this->product_url = 'https://www.rabobank.nl/bedrijven/betalen/geld-ontvangen/rabo-omnikassa/'; |
||
| 24 | $this->dashboard_url = array( |
||
| 25 | __( 'admin', 'pronamic_ideal' ) => 'https://dashboard.omnikassa.rabobank.nl/', |
||
| 26 | __( 'download', 'pronamic_ideal' ) => 'https://download.omnikassa.rabobank.nl/', |
||
| 27 | ); |
||
| 28 | $this->provider = 'rabobank'; |
||
| 29 | $this->deprecated = true; |
||
|
0 ignored issues
–
show
Bug
Best Practice
introduced
by
Loading history...
|
|||
| 30 | |||
| 31 | // Actions |
||
| 32 | $function = array( __NAMESPACE__ . '\Listener', 'listen' ); |
||
| 33 | |||
| 34 | if ( ! has_action( 'wp_loaded', $function ) ) { |
||
| 35 | add_action( 'wp_loaded', $function ); |
||
| 36 | } |
||
| 37 | } |
||
| 38 | |||
| 39 | /** |
||
| 40 | * Get settings fields. |
||
| 41 | * |
||
| 42 | * @return array |
||
| 43 | */ |
||
| 44 | public function get_settings_fields() { |
||
| 45 | $fields = array(); |
||
| 46 | |||
| 47 | // Merchant ID |
||
| 48 | $fields[] = array( |
||
| 49 | 'section' => 'general', |
||
| 50 | 'filter' => FILTER_SANITIZE_STRING, |
||
| 51 | 'meta_key' => '_pronamic_gateway_omnikassa_merchant_id', |
||
| 52 | 'title' => __( 'Merchant ID', 'pronamic_ideal' ), |
||
| 53 | 'type' => 'text', |
||
| 54 | 'classes' => array( 'code' ), |
||
| 55 | ); |
||
| 56 | |||
| 57 | // Secret Key |
||
| 58 | $fields[] = array( |
||
| 59 | 'section' => 'general', |
||
| 60 | 'filter' => FILTER_SANITIZE_STRING, |
||
| 61 | 'meta_key' => '_pronamic_gateway_omnikassa_secret_key', |
||
| 62 | 'title' => __( 'Secret Key', 'pronamic_ideal' ), |
||
| 63 | 'type' => 'text', |
||
| 64 | 'classes' => array( 'large-text', 'code' ), |
||
| 65 | ); |
||
| 66 | |||
| 67 | // Key Version |
||
| 68 | $fields[] = array( |
||
| 69 | 'section' => 'general', |
||
| 70 | 'filter' => FILTER_SANITIZE_STRING, |
||
| 71 | 'meta_key' => '_pronamic_gateway_omnikassa_key_version', |
||
| 72 | 'title' => __( 'Key Version', 'pronamic_ideal' ), |
||
| 73 | 'type' => 'text', |
||
| 74 | 'classes' => array( 'code' ), |
||
| 75 | 'size' => 5, |
||
| 76 | 'description' => sprintf( __( 'You can find the key version in the <a href="%s" target="_blank">OmniKassa Download Dashboard</a>.', 'pronamic_ideal' ), 'https://download.omnikassa.rabobank.nl/' ), |
||
| 77 | ); |
||
| 78 | |||
| 79 | // Purchase ID |
||
| 80 | $fields[] = array( |
||
| 81 | 'section' => 'advanced', |
||
| 82 | 'filter' => FILTER_SANITIZE_STRING, |
||
| 83 | 'meta_key' => '_pronamic_gateway_omnikassa_order_id', |
||
| 84 | 'title' => __( 'Order ID', 'pronamic_ideal' ), |
||
| 85 | 'type' => 'text', |
||
| 86 | 'classes' => array( 'regular-text', 'code' ), |
||
| 87 | 'tooltip' => sprintf( |
||
| 88 | __( 'The OmniKassa %s parameter.', 'pronamic_ideal' ), |
||
| 89 | sprintf( '<code>%s</code>', 'orderId' ) |
||
| 90 | ), |
||
| 91 | 'description' => sprintf( |
||
| 92 | '%s %s<br />%s', |
||
| 93 | __( 'Available tags:', 'pronamic_ideal' ), |
||
| 94 | sprintf( |
||
| 95 | '<code>%s</code> <code>%s</code>', |
||
| 96 | '{order_id}', |
||
| 97 | '{payment_id}' |
||
| 98 | ), |
||
| 99 | sprintf( |
||
| 100 | __( 'Default: <code>%s</code>', 'pronamic_ideal' ), |
||
| 101 | '{payment_id}' |
||
| 102 | ) |
||
| 103 | ), |
||
| 104 | ); |
||
| 105 | |||
| 106 | return $fields; |
||
| 107 | } |
||
| 108 | |||
| 109 | public function get_config( $post_id ) { |
||
| 110 | $config = new Config(); |
||
| 111 | |||
| 112 | $config->merchant_id = get_post_meta( $post_id, '_pronamic_gateway_omnikassa_merchant_id', true ); |
||
| 113 | $config->secret_key = get_post_meta( $post_id, '_pronamic_gateway_omnikassa_secret_key', true ); |
||
| 114 | $config->key_version = get_post_meta( $post_id, '_pronamic_gateway_omnikassa_key_version', true ); |
||
| 115 | $config->order_id = get_post_meta( $post_id, '_pronamic_gateway_omnikassa_order_id', true ); |
||
| 116 | $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...
|
|||
| 117 | |||
| 118 | return $config; |
||
| 119 | } |
||
| 120 | |||
| 121 | /** |
||
| 122 | * Get gateway. |
||
| 123 | * |
||
| 124 | * @param int $post_id Post ID. |
||
| 125 | * @return Gateway |
||
| 126 | */ |
||
| 127 | public function get_gateway( $post_id ) { |
||
| 128 | return new Gateway( $this->get_config( $post_id ) ); |
||
| 129 | } |
||
| 130 | } |
||
| 131 |