wp-pay-gateways /
sisow
| 1 | <?php |
||
| 2 | /** |
||
| 3 | * Integration |
||
| 4 | * |
||
| 5 | * @author Pronamic <[email protected]> |
||
| 6 | * @copyright 2005-2020 Pronamic |
||
| 7 | * @license GPL-3.0-or-later |
||
| 8 | * @package Pronamic\WordPress\Pay\Payments |
||
| 9 | */ |
||
| 10 | |||
| 11 | namespace Pronamic\WordPress\Pay\Gateways\Sisow; |
||
| 12 | |||
| 13 | use Pronamic\WordPress\Pay\Gateways\Common\AbstractIntegration; |
||
| 14 | use Pronamic\WordPress\Pay\Payments\Payment; |
||
| 15 | |||
| 16 | /** |
||
| 17 | * Title: Sisow integration |
||
| 18 | * Description: |
||
| 19 | * Copyright: 2005-2020 Pronamic |
||
| 20 | * Company: Pronamic |
||
| 21 | * |
||
| 22 | * @author Remco Tolsma |
||
| 23 | * @version 2.0.4 |
||
| 24 | * @since 1.0.0 |
||
| 25 | */ |
||
| 26 | class Integration extends AbstractIntegration { |
||
| 27 | /** |
||
| 28 | * Construct integration. |
||
| 29 | */ |
||
| 30 | public function __construct() { |
||
| 31 | parent::__construct(); |
||
| 32 | |||
| 33 | $this->id = 'sisow-ideal'; |
||
| 34 | $this->name = 'Sisow'; |
||
| 35 | $this->url = 'https://www.sisow.nl/'; |
||
| 36 | $this->product_url = 'https://www.sisow.nl/epay-online-betaalmogelijkheden/epay-informatie'; |
||
| 37 | $this->dashboard_url = 'https://www.sisow.nl/Sisow/iDeal/Login.aspx'; |
||
| 38 | $this->register_url = 'https://www.sisow.nl/Sisow/iDeal/Aanmelden.aspx?r=120872'; |
||
|
0 ignored issues
–
show
Bug
Best Practice
introduced
by
Loading history...
|
|||
| 39 | $this->provider = 'sisow'; |
||
| 40 | $this->supports = array( |
||
| 41 | 'webhook', |
||
| 42 | 'webhook_log', |
||
| 43 | 'webhook_no_config', |
||
| 44 | ); |
||
| 45 | |||
| 46 | $this->set_manual_url( __( 'https://www.pronamic.eu/support/how-to-connect-sisow-with-wordpress-via-pronamic-pay/', 'pronamic_ideal' ) ); |
||
| 47 | |||
| 48 | \add_filter( 'pronamic_pay_return_should_redirect', array( $this, 'return_should_redirect' ), 10, 2 ); |
||
| 49 | } |
||
| 50 | |||
| 51 | /** |
||
| 52 | * Filter whether or not to redirect when handling return. |
||
| 53 | * |
||
| 54 | * @param bool $should_redirect Whether or not to redirect. |
||
| 55 | * @param Payment $payment Payment. |
||
| 56 | * |
||
| 57 | * @return bool |
||
| 58 | */ |
||
| 59 | public function return_should_redirect( $should_redirect, Payment $payment ) { |
||
| 60 | // Check if the request is a callback request. |
||
| 61 | if ( filter_has_var( \INPUT_GET, 'callback' ) && filter_input( \INPUT_GET, 'callback', \FILTER_VALIDATE_BOOLEAN ) ) { |
||
| 62 | $should_redirect = false; |
||
| 63 | } |
||
| 64 | |||
| 65 | // Check if the request is a notify request. |
||
| 66 | if ( filter_has_var( \INPUT_GET, 'notify' ) && filter_input( \INPUT_GET, 'notify', \FILTER_VALIDATE_BOOLEAN ) ) { |
||
| 67 | // Log webhook request. |
||
| 68 | do_action( 'pronamic_pay_webhook_log_payment', $payment ); |
||
| 69 | |||
| 70 | $should_redirect = false; |
||
| 71 | } |
||
| 72 | |||
| 73 | return $should_redirect; |
||
| 74 | } |
||
| 75 | |||
| 76 | /** |
||
| 77 | * Get settings fields. |
||
| 78 | * |
||
| 79 | * @return array |
||
| 80 | */ |
||
| 81 | public function get_settings_fields() { |
||
| 82 | $fields = array(); |
||
| 83 | |||
| 84 | // Intro. |
||
| 85 | $fields[] = array( |
||
| 86 | 'section' => 'general', |
||
| 87 | 'type' => 'html', |
||
| 88 | 'html' => sprintf( |
||
| 89 | /* translators: %s: Sisow */ |
||
| 90 | __( 'Account details are provided by %1$s after registration. These settings need to match with the %1$s dashboard.', 'pronamic_ideal' ), |
||
| 91 | __( 'Sisow', 'pronamic_ideal' ) |
||
| 92 | ), |
||
| 93 | ); |
||
| 94 | |||
| 95 | // Merchant ID. |
||
| 96 | $fields[] = array( |
||
| 97 | 'section' => 'general', |
||
| 98 | 'filter' => FILTER_SANITIZE_STRING, |
||
| 99 | 'methods' => array( 'sisow' ), |
||
| 100 | 'meta_key' => '_pronamic_gateway_sisow_merchant_id', |
||
| 101 | 'title' => _x( 'Merchant ID', 'sisow', 'pronamic_ideal' ), |
||
| 102 | 'type' => 'text', |
||
| 103 | 'classes' => array( 'code' ), |
||
| 104 | 'tooltip' => __( 'Merchant ID as mentioned at <strong>My Profile</strong> in the Sisow dashboard.', 'pronamic_ideal' ), |
||
| 105 | ); |
||
| 106 | |||
| 107 | // Merchant Key. |
||
| 108 | $fields[] = array( |
||
| 109 | 'section' => 'general', |
||
| 110 | 'filter' => FILTER_SANITIZE_STRING, |
||
| 111 | 'methods' => array( 'sisow' ), |
||
| 112 | 'meta_key' => '_pronamic_gateway_sisow_merchant_key', |
||
| 113 | 'title' => _x( 'Merchant Key', 'sisow', 'pronamic_ideal' ), |
||
| 114 | 'type' => 'text', |
||
| 115 | 'classes' => array( 'regular-text', 'code' ), |
||
| 116 | 'tooltip' => __( 'Merchant Key as mentioned at <strong>My Profile</strong> in the Sisow dashboard.', 'pronamic_ideal' ), |
||
| 117 | ); |
||
| 118 | |||
| 119 | // Shop ID. |
||
| 120 | $fields[] = array( |
||
| 121 | 'section' => 'general', |
||
| 122 | 'filter' => FILTER_SANITIZE_STRING, |
||
| 123 | 'methods' => array( 'sisow' ), |
||
| 124 | 'meta_key' => '_pronamic_gateway_sisow_shop_id', |
||
| 125 | 'title' => _x( 'Shop ID', 'sisow', 'pronamic_ideal' ), |
||
| 126 | 'type' => 'text', |
||
| 127 | 'classes' => array( 'regular-text', 'code' ), |
||
| 128 | 'tooltip' => __( 'Shop ID as mentioned at <strong>My Profile</strong> in the Sisow dashboard.', 'pronamic_ideal' ), |
||
| 129 | /* translators: %s: 0 */ |
||
| 130 | 'description' => sprintf( __( 'Default: <code>%s</code>', 'pronamic_ideal' ), 0 ), |
||
| 131 | 'default' => 0, |
||
| 132 | ); |
||
| 133 | |||
| 134 | return $fields; |
||
| 135 | } |
||
| 136 | |||
| 137 | /** |
||
| 138 | * Get configuration. |
||
| 139 | * |
||
| 140 | * @param int $post_id Post ID. |
||
| 141 | * @return Config |
||
| 142 | */ |
||
| 143 | public function get_config( $post_id ) { |
||
| 144 | $config = new Config(); |
||
| 145 | |||
| 146 | $config->merchant_id = $this->get_meta( $post_id, 'sisow_merchant_id' ); |
||
| 147 | $config->merchant_key = $this->get_meta( $post_id, 'sisow_merchant_key' ); |
||
| 148 | $config->shop_id = $this->get_meta( $post_id, 'sisow_shop_id' ); |
||
| 149 | $config->mode = $this->get_meta( $post_id, 'mode' ); |
||
| 150 | |||
| 151 | return $config; |
||
| 152 | } |
||
| 153 | |||
| 154 | /** |
||
| 155 | * Get gateway. |
||
| 156 | * |
||
| 157 | * @param int $post_id Post ID. |
||
| 158 | * @return Gateway |
||
| 159 | */ |
||
| 160 | public function get_gateway( $post_id ) { |
||
| 161 | return new Gateway( $this->get_config( $post_id ) ); |
||
| 162 | } |
||
| 163 | } |
||
| 164 |