wp-pay-gateways /
adyen
| 1 | <?php |
||
| 2 | /** |
||
| 3 | * Integration |
||
| 4 | * |
||
| 5 | * @author Pronamic <[email protected]> |
||
| 6 | * @copyright 2005-2019 Pronamic |
||
| 7 | * @license GPL-3.0-or-later |
||
| 8 | * @package Pronamic\WordPress\Pay\Gateways\Adyen |
||
| 9 | */ |
||
| 10 | |||
| 11 | namespace Pronamic\WordPress\Pay\Gateways\Adyen; |
||
| 12 | |||
| 13 | use Pronamic\WordPress\Pay\Gateways\Common\AbstractIntegration; |
||
| 14 | use Pronamic\WordPress\Pay\Util as Pay_Util; |
||
| 15 | |||
| 16 | /** |
||
| 17 | * Integration |
||
| 18 | * |
||
| 19 | * @author Remco Tolsma |
||
| 20 | * @version 1.0.0 |
||
| 21 | * @since 1.0.0 |
||
| 22 | */ |
||
| 23 | class Integration extends AbstractIntegration { |
||
| 24 | /** |
||
| 25 | * REST route namespace. |
||
| 26 | * |
||
| 27 | * @var string |
||
| 28 | */ |
||
| 29 | const REST_ROUTE_NAMESPACE = 'pronamic-pay/adyen/v1'; |
||
| 30 | |||
| 31 | /** |
||
| 32 | * Integration constructor. |
||
| 33 | */ |
||
| 34 | 6 | public function __construct() { |
|
| 35 | 6 | $this->id = 'adyen'; |
|
| 36 | 6 | $this->name = 'Adyen'; |
|
| 37 | 6 | $this->provider = 'adyen'; |
|
| 38 | 6 | $this->url = 'https://www.adyen.com/'; |
|
| 39 | 6 | $this->dashboard_url = array( |
|
| 40 | 6 | __( 'test', 'pronamic_ideal' ) => 'https://ca-test.adyen.com/ca/ca/login.shtml', |
|
| 41 | 6 | __( 'live', 'pronamic_ideal' ) => 'https://ca-live.adyen.com/ca/ca/login.shtml', |
|
| 42 | ); |
||
| 43 | |||
| 44 | // Notifications controller. |
||
| 45 | 6 | $notifications_controller = new NotificationsController(); |
|
| 46 | |||
| 47 | 6 | $notifications_controller->setup(); |
|
| 48 | |||
| 49 | // Payments result controller. |
||
| 50 | 6 | $payments_result_controller = new PaymentsResultController(); |
|
| 51 | |||
| 52 | 6 | $payments_result_controller->setup(); |
|
| 53 | |||
| 54 | // Settings. |
||
| 55 | 6 | add_action( 'init', array( $this, 'init' ) ); |
|
| 56 | 6 | add_action( 'admin_init', array( $this, 'admin_init' ) ); |
|
| 57 | 6 | } |
|
| 58 | |||
| 59 | /** |
||
| 60 | * Initialize. |
||
| 61 | * |
||
| 62 | * @return void |
||
| 63 | */ |
||
| 64 | 1 | public function init() { |
|
| 65 | /* |
||
| 66 | * Authentication - User Name |
||
| 67 | */ |
||
| 68 | 1 | register_setting( |
|
| 69 | 1 | 'pronamic_pay', |
|
| 70 | 1 | 'pronamic_pay_adyen_notification_authentication_username', |
|
| 71 | array( |
||
| 72 | 1 | 'type' => 'string', |
|
| 73 | 'sanitize_callback' => 'sanitize_text_field', |
||
| 74 | ) |
||
| 75 | ); |
||
| 76 | |||
| 77 | /* |
||
| 78 | * Authentication - Password |
||
| 79 | */ |
||
| 80 | 1 | register_setting( |
|
| 81 | 1 | 'pronamic_pay', |
|
| 82 | 1 | 'pronamic_pay_adyen_notification_authentication_password', |
|
| 83 | array( |
||
| 84 | 1 | 'type' => 'string', |
|
| 85 | 'sanitize_callback' => 'sanitize_text_field', |
||
| 86 | ) |
||
| 87 | ); |
||
| 88 | 1 | } |
|
| 89 | |||
| 90 | /** |
||
| 91 | * Admin initialize. |
||
| 92 | * |
||
| 93 | * @return void |
||
| 94 | */ |
||
| 95 | 1 | public function admin_init() { |
|
| 96 | 1 | add_settings_section( |
|
| 97 | 1 | 'pronamic_pay_adyen_notification_authentication', |
|
| 98 | 1 | __( 'Adyen Notification Authentication', 'pronamic_ideal' ), |
|
| 99 | 1 | array( $this, 'settings_section_notification_authentication' ), |
|
| 100 | 1 | 'pronamic_pay' |
|
| 101 | ); |
||
| 102 | |||
| 103 | 1 | add_settings_field( |
|
| 104 | 1 | 'pronamic_pay_adyen_notification_authentication_username', |
|
| 105 | 1 | __( 'User Name', 'pronamic_ideal' ), |
|
| 106 | 1 | array( __CLASS__, 'input_element' ), |
|
| 107 | 1 | 'pronamic_pay', |
|
| 108 | 1 | 'pronamic_pay_adyen_notification_authentication', |
|
| 109 | array( |
||
| 110 | 1 | 'label_for' => 'pronamic_pay_adyen_notification_authentication_username', |
|
| 111 | ) |
||
| 112 | ); |
||
| 113 | |||
| 114 | 1 | add_settings_field( |
|
| 115 | 1 | 'pronamic_pay_adyen_notification_authentication_password', |
|
| 116 | 1 | __( 'Password', 'pronamic_ideal' ), |
|
| 117 | 1 | array( __CLASS__, 'input_element' ), |
|
| 118 | 1 | 'pronamic_pay', |
|
| 119 | 1 | 'pronamic_pay_adyen_notification_authentication', |
|
| 120 | array( |
||
| 121 | 1 | 'label_for' => 'pronamic_pay_adyen_notification_authentication_password', |
|
| 122 | ) |
||
| 123 | ); |
||
| 124 | 1 | } |
|
| 125 | |||
| 126 | /** |
||
| 127 | * Settings section notification authentication. |
||
| 128 | * |
||
| 129 | * @return void |
||
| 130 | */ |
||
| 131 | 1 | public function settings_section_notification_authentication() { |
|
| 132 | 1 | printf( |
|
| 133 | 1 | '<p>%s</p>', |
|
| 134 | 1 | esc_html__( |
|
| 135 | 1 | 'Set the user name and password below and in the webhook authentication settings in the Adyen dashboard for increased security (recommended).', |
|
| 136 | 1 | 'pronamic_ideal' |
|
| 137 | ) |
||
| 138 | ); |
||
| 139 | 1 | } |
|
| 140 | |||
| 141 | /** |
||
| 142 | * Input text. |
||
| 143 | * |
||
| 144 | * @param array $args Arguments. |
||
| 145 | * @return void |
||
| 146 | */ |
||
| 147 | 1 | public static function input_element( $args ) { |
|
| 148 | 1 | $name = $args['label_for']; |
|
| 149 | 1 | $value = get_option( $name ); |
|
| 150 | |||
| 151 | 1 | printf( |
|
| 152 | 1 | '<input name="%s" id="%s" value="%s" type="text" class="regular-text" />', |
|
| 153 | 1 | esc_attr( $name ), |
|
| 154 | 1 | esc_attr( $name ), |
|
| 155 | 1 | esc_attr( $value ) |
|
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 156 | ); |
||
| 157 | 1 | } |
|
| 158 | |||
| 159 | /** |
||
| 160 | * Get config factory class. |
||
| 161 | * |
||
| 162 | * @return string |
||
| 163 | */ |
||
| 164 | 1 | public function get_config_factory_class() { |
|
| 165 | 1 | return __NAMESPACE__ . '\ConfigFactory'; |
|
| 166 | } |
||
| 167 | |||
| 168 | /** |
||
| 169 | * Get settings class. |
||
| 170 | * |
||
| 171 | * @return string |
||
| 172 | */ |
||
| 173 | 1 | public function get_settings_class() { |
|
| 174 | 1 | return __NAMESPACE__ . '\Settings'; |
|
| 175 | } |
||
| 176 | |||
| 177 | /** |
||
| 178 | * Get required settings for this integration. |
||
| 179 | * |
||
| 180 | * @link https://github.com/wp-premium/gravityforms/blob/1.9.16/includes/fields/class-gf-field-multiselect.php#L21-L42 |
||
| 181 | * @since 1.1.6 |
||
| 182 | * @return array |
||
| 183 | */ |
||
| 184 | 1 | public function get_settings() { |
|
| 185 | 1 | $settings = parent::get_settings(); |
|
| 186 | |||
| 187 | 1 | $settings[] = 'adyen'; |
|
| 188 | |||
| 189 | 1 | return $settings; |
|
| 190 | } |
||
| 191 | } |
||
| 192 |