@@ -18,27 +18,27 @@ |
||
| 18 | 18 | public static function listen() { |
| 19 | 19 | $data = Security::get_request_data(); |
| 20 | 20 | |
| 21 | - $data = array_change_key_case( $data, CASE_UPPER ); |
|
| 21 | + $data = array_change_key_case($data, CASE_UPPER); |
|
| 22 | 22 | |
| 23 | - if ( isset( |
|
| 24 | - $data[ Parameters::NC_ERROR ], |
|
| 23 | + if (isset( |
|
| 24 | + $data[Parameters::NC_ERROR], |
|
| 25 | 25 | $data['PAYID'], |
| 26 | - $data[ Parameters::ORDERID ], |
|
| 27 | - $data[ Parameters::STATUS ] |
|
| 28 | - ) ) { |
|
| 29 | - $payment_id = $data[ Parameters::ORDERID ]; |
|
| 26 | + $data[Parameters::ORDERID], |
|
| 27 | + $data[Parameters::STATUS] |
|
| 28 | + )) { |
|
| 29 | + $payment_id = $data[Parameters::ORDERID]; |
|
| 30 | 30 | |
| 31 | - if ( isset( $data['PAYMENT_ID'] ) ) { |
|
| 32 | - $payment_id = filter_var( $data['PAYMENT_ID'], FILTER_SANITIZE_NUMBER_INT ); |
|
| 31 | + if (isset($data['PAYMENT_ID'])) { |
|
| 32 | + $payment_id = filter_var($data['PAYMENT_ID'], FILTER_SANITIZE_NUMBER_INT); |
|
| 33 | 33 | } |
| 34 | 34 | |
| 35 | - $payment = get_pronamic_payment( $payment_id ); |
|
| 35 | + $payment = get_pronamic_payment($payment_id); |
|
| 36 | 36 | |
| 37 | 37 | // Add note. |
| 38 | - $payment->add_note( __( 'Webhook requested.', 'pronamic_ideal' ) ); |
|
| 38 | + $payment->add_note(__('Webhook requested.', 'pronamic_ideal')); |
|
| 39 | 39 | |
| 40 | 40 | // Update payment. |
| 41 | - Plugin::update_payment( $payment ); |
|
| 41 | + Plugin::update_payment($payment); |
|
| 42 | 42 | } |
| 43 | 43 | } |
| 44 | 44 | } |
@@ -7,15 +7,15 @@ |
||
| 7 | 7 | abstract class AbstractIntegration extends Common_AbstractIntegration { |
| 8 | 8 | public function __construct() { |
| 9 | 9 | $this->url = 'https://secure.ogone.com/'; |
| 10 | - $this->product_url = __( 'https://payment-services.ingenico.com/nl/en', 'pronamic_ideal' ); |
|
| 10 | + $this->product_url = __('https://payment-services.ingenico.com/nl/en', 'pronamic_ideal'); |
|
| 11 | 11 | $this->dashboard_url = 'https://secure.ogone.com/'; |
| 12 | 12 | $this->provider = 'ogone'; |
| 13 | 13 | |
| 14 | 14 | // Actions |
| 15 | - $function = array( __NAMESPACE__ . '\Listener', 'listen' ); |
|
| 15 | + $function = array(__NAMESPACE__ . '\Listener', 'listen'); |
|
| 16 | 16 | |
| 17 | - if ( ! has_action( 'wp_loaded', $function ) ) { |
|
| 18 | - add_action( 'wp_loaded', $function ); |
|
| 17 | + if ( ! has_action('wp_loaded', $function)) { |
|
| 18 | + add_action('wp_loaded', $function); |
|
| 19 | 19 | } |
| 20 | 20 | } |
| 21 | 21 | |
@@ -30,12 +30,12 @@ discard block |
||
| 30 | 30 | * Get calculations parameters in |
| 31 | 31 | */ |
| 32 | 32 | public static function get_calculations_parameters_in() { |
| 33 | - if ( ! isset( self::$calculations_parameters_in ) ) { |
|
| 33 | + if ( ! isset(self::$calculations_parameters_in)) { |
|
| 34 | 34 | self::$calculations_parameters_in = array(); |
| 35 | 35 | |
| 36 | - $file = dirname( __FILE__ ) . '/../data/calculations-parameters-sha-in.txt'; |
|
| 37 | - if ( is_readable( $file ) ) { |
|
| 38 | - self::$calculations_parameters_in = file( $file, FILE_IGNORE_NEW_LINES ); |
|
| 36 | + $file = dirname(__FILE__) . '/../data/calculations-parameters-sha-in.txt'; |
|
| 37 | + if (is_readable($file)) { |
|
| 38 | + self::$calculations_parameters_in = file($file, FILE_IGNORE_NEW_LINES); |
|
| 39 | 39 | } |
| 40 | 40 | } |
| 41 | 41 | |
@@ -46,12 +46,12 @@ discard block |
||
| 46 | 46 | * Get calculations parameters in |
| 47 | 47 | */ |
| 48 | 48 | public static function get_calculations_parameters_out() { |
| 49 | - if ( ! isset( self::$calculations_parameters_out ) ) { |
|
| 49 | + if ( ! isset(self::$calculations_parameters_out)) { |
|
| 50 | 50 | self::$calculations_parameters_out = array(); |
| 51 | 51 | |
| 52 | - $file = dirname( __FILE__ ) . '/../data/calculations-parameters-sha-out.txt'; |
|
| 53 | - if ( is_readable( $file ) ) { |
|
| 54 | - self::$calculations_parameters_out = file( $file, FILE_IGNORE_NEW_LINES ); |
|
| 52 | + $file = dirname(__FILE__) . '/../data/calculations-parameters-sha-out.txt'; |
|
| 53 | + if (is_readable($file)) { |
|
| 54 | + self::$calculations_parameters_out = file($file, FILE_IGNORE_NEW_LINES); |
|
| 55 | 55 | } |
| 56 | 56 | } |
| 57 | 57 | |
@@ -66,8 +66,8 @@ discard block |
||
| 66 | 66 | public static function get_request_data() { |
| 67 | 67 | $data = array(); |
| 68 | 68 | |
| 69 | - if ( isset( $_SERVER['REQUEST_METHOD'] ) ) { // WPCS: input var okay |
|
| 70 | - switch ( $_SERVER['REQUEST_METHOD'] ) { // WPCS: input var okay |
|
| 69 | + if (isset($_SERVER['REQUEST_METHOD'])) { // WPCS: input var okay |
|
| 70 | + switch ($_SERVER['REQUEST_METHOD']) { // WPCS: input var okay |
|
| 71 | 71 | case 'GET': |
| 72 | 72 | // @todo see how we can improve security around this |
| 73 | 73 | $data = $_GET; // WPCS: input var okay |
@@ -84,48 +84,48 @@ discard block |
||
| 84 | 84 | return $data; |
| 85 | 85 | } |
| 86 | 86 | |
| 87 | - public static function get_calculation_fields( $calculation_fields, $fields ) { |
|
| 88 | - $calculation_fields = array_flip( $calculation_fields ); |
|
| 87 | + public static function get_calculation_fields($calculation_fields, $fields) { |
|
| 88 | + $calculation_fields = array_flip($calculation_fields); |
|
| 89 | 89 | |
| 90 | - return array_intersect_key( $fields, $calculation_fields ); |
|
| 90 | + return array_intersect_key($fields, $calculation_fields); |
|
| 91 | 91 | } |
| 92 | 92 | |
| 93 | - public static function get_signature( $fields, $passphrase, $hash_algorithm ) { |
|
| 93 | + public static function get_signature($fields, $passphrase, $hash_algorithm) { |
|
| 94 | 94 | // This string is constructed by concatenating the values of the fields sent with the order (sorted |
| 95 | 95 | // alphabetically, in the format ‘parameter=value’), separated by a passphrase. |
| 96 | 96 | $string = ''; |
| 97 | 97 | |
| 98 | 98 | // All parameters need to be put alphabetically |
| 99 | - ksort( $fields ); |
|
| 99 | + ksort($fields); |
|
| 100 | 100 | |
| 101 | 101 | // Loop |
| 102 | - foreach ( $fields as $name => $value ) { |
|
| 102 | + foreach ($fields as $name => $value) { |
|
| 103 | 103 | $value = (string) $value; |
| 104 | 104 | |
| 105 | 105 | // Use of empty will fail, value can be string '0' |
| 106 | - if ( strlen( $value ) > 0 ) { |
|
| 107 | - $name = strtoupper( $name ); |
|
| 106 | + if (strlen($value) > 0) { |
|
| 107 | + $name = strtoupper($name); |
|
| 108 | 108 | |
| 109 | 109 | $string .= $name . '=' . $value . $passphrase; |
| 110 | 110 | } |
| 111 | 111 | } |
| 112 | 112 | |
| 113 | 113 | // Hash |
| 114 | - $result = hash( $hash_algorithm, $string ); |
|
| 114 | + $result = hash($hash_algorithm, $string); |
|
| 115 | 115 | |
| 116 | 116 | // String to uppercase |
| 117 | - $result = strtoupper( $result ); |
|
| 117 | + $result = strtoupper($result); |
|
| 118 | 118 | |
| 119 | 119 | return $result; |
| 120 | 120 | } |
| 121 | 121 | |
| 122 | - public static function sign_data( Data $data, $pass_phrase, $hash_algorithm ) { |
|
| 122 | + public static function sign_data(Data $data, $pass_phrase, $hash_algorithm) { |
|
| 123 | 123 | $calculation_fields = Security::get_calculations_parameters_in(); |
| 124 | 124 | |
| 125 | - $fields = Security::get_calculation_fields( $calculation_fields, $data->get_fields() ); |
|
| 125 | + $fields = Security::get_calculation_fields($calculation_fields, $data->get_fields()); |
|
| 126 | 126 | |
| 127 | - $signature = Security::get_signature( $fields, $pass_phrase, $hash_algorithm ); |
|
| 127 | + $signature = Security::get_signature($fields, $pass_phrase, $hash_algorithm); |
|
| 128 | 128 | |
| 129 | - $data->set_field( 'SHASign', $signature ); |
|
| 129 | + $data->set_field('SHASign', $signature); |
|
| 130 | 130 | } |
| 131 | 131 | } |
@@ -286,8 +286,8 @@ |
||
| 286 | 286 | * |
| 287 | 287 | * @param string $status |
| 288 | 288 | */ |
| 289 | - public static function transform( $status ) { |
|
| 290 | - switch ( $status ) { |
|
| 289 | + public static function transform($status) { |
|
| 290 | + switch ($status) { |
|
| 291 | 291 | case self::INCOMPLETE_OR_INVALID : |
| 292 | 292 | case self::AUTHORIZATION_REFUSED : |
| 293 | 293 | case self::AUTHOR_DELETION_REFUSED : |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | * Constructs and initializes Ogone config object. |
| 42 | 42 | */ |
| 43 | 43 | public function __construct() { |
| 44 | - $this->set_form_action_url( $this->get_default_form_action_url() ); |
|
| 44 | + $this->set_form_action_url($this->get_default_form_action_url()); |
|
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | /** |
@@ -51,9 +51,9 @@ discard block |
||
| 51 | 51 | * @return string |
| 52 | 52 | */ |
| 53 | 53 | protected function get_default_form_action_url() { |
| 54 | - $is_utf8 = strcasecmp( get_bloginfo( 'charset' ), 'UTF-8' ) === 0; |
|
| 54 | + $is_utf8 = strcasecmp(get_bloginfo('charset'), 'UTF-8') === 0; |
|
| 55 | 55 | |
| 56 | - if ( $is_utf8 ) { |
|
| 56 | + if ($is_utf8) { |
|
| 57 | 57 | return 'https://secure.ogone.com/ncol/prod/orderstandard_utf8.asp'; |
| 58 | 58 | } |
| 59 | 59 | |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | * |
| 78 | 78 | * @param string $url Ogone e-Commerce form action URL. |
| 79 | 79 | */ |
| 80 | - public function set_form_action_url( $url ) { |
|
| 80 | + public function set_form_action_url($url) { |
|
| 81 | 81 | $this->form_action_url = $url; |
| 82 | 82 | } |
| 83 | 83 | |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | * @return string |
| 99 | 99 | */ |
| 100 | 100 | public function get_direct_query_url() { |
| 101 | - if ( 'test' === $this->mode ) { |
|
| 101 | + if ('test' === $this->mode) { |
|
| 102 | 102 | return 'https://secure.ogone.com/ncol/test/querydirect.asp'; |
| 103 | 103 | } |
| 104 | 104 | |
@@ -41,11 +41,11 @@ discard block |
||
| 41 | 41 | * |
| 42 | 42 | * @param string $name |
| 43 | 43 | */ |
| 44 | - public function get_field( $name ) { |
|
| 44 | + public function get_field($name) { |
|
| 45 | 45 | $value = null; |
| 46 | 46 | |
| 47 | - if ( isset( $this->fields[ $name ] ) ) { |
|
| 48 | - $value = $this->fields[ $name ]; |
|
| 47 | + if (isset($this->fields[$name])) { |
|
| 48 | + $value = $this->fields[$name]; |
|
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | return $value; |
@@ -59,8 +59,8 @@ discard block |
||
| 59 | 59 | * |
| 60 | 60 | * @return Data |
| 61 | 61 | */ |
| 62 | - public function set_field( $name, $value ) { |
|
| 63 | - $this->fields[ $name ] = $value; |
|
| 62 | + public function set_field($name, $value) { |
|
| 63 | + $this->fields[$name] = $value; |
|
| 64 | 64 | |
| 65 | 65 | return $this; |
| 66 | 66 | } |
@@ -42,10 +42,10 @@ discard block |
||
| 42 | 42 | * |
| 43 | 43 | * @param string $psp_id |
| 44 | 44 | */ |
| 45 | - public function __construct( $psp_id ) { |
|
| 45 | + public function __construct($psp_id) { |
|
| 46 | 46 | $this->data = new Data(); |
| 47 | - $this->data->set_field( Parameters::PSPID, $psp_id ); |
|
| 48 | - $this->data->set_field( 'PM', self::PAYMENT_TYPE_IDEAL ); |
|
| 47 | + $this->data->set_field(Parameters::PSPID, $psp_id); |
|
| 48 | + $this->data->set_field('PM', self::PAYMENT_TYPE_IDEAL); |
|
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | /** |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | * |
| 63 | 63 | * @param string $url an URL |
| 64 | 64 | */ |
| 65 | - public function set_payment_server_url( $url ) { |
|
| 65 | + public function set_payment_server_url($url) { |
|
| 66 | 66 | $this->payment_server_url = $url; |
| 67 | 67 | } |
| 68 | 68 | |
@@ -26,15 +26,15 @@ discard block |
||
| 26 | 26 | * |
| 27 | 27 | * @param Config $config |
| 28 | 28 | */ |
| 29 | - public function __construct( Config $config ) { |
|
| 30 | - parent::__construct( $config ); |
|
| 29 | + public function __construct(Config $config) { |
|
| 30 | + parent::__construct($config); |
|
| 31 | 31 | |
| 32 | - $this->set_method( Gateway::METHOD_HTML_FORM ); |
|
| 33 | - $this->set_has_feedback( false ); |
|
| 34 | - $this->set_amount_minimum( 0.01 ); |
|
| 32 | + $this->set_method(Gateway::METHOD_HTML_FORM); |
|
| 33 | + $this->set_has_feedback(false); |
|
| 34 | + $this->set_amount_minimum(0.01); |
|
| 35 | 35 | |
| 36 | - $this->client = new Client( $config->psp_id ); |
|
| 37 | - $this->client->set_payment_server_url( $config->get_form_action_url() ); |
|
| 36 | + $this->client = new Client($config->psp_id); |
|
| 37 | + $this->client->set_payment_server_url($config->get_form_action_url()); |
|
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | /** |
@@ -64,44 +64,44 @@ discard block |
||
| 64 | 64 | * |
| 65 | 65 | * @see Pronamic_WP_Pay_Gateway::start() |
| 66 | 66 | */ |
| 67 | - public function start( Payment $payment ) { |
|
| 68 | - $payment->set_action_url( $this->client->get_payment_server_url() ); |
|
| 67 | + public function start(Payment $payment) { |
|
| 68 | + $payment->set_action_url($this->client->get_payment_server_url()); |
|
| 69 | 69 | |
| 70 | 70 | $ogone_data = $this->client->get_data(); |
| 71 | 71 | |
| 72 | 72 | // General |
| 73 | - $ogone_data_general = new DataGeneralHelper( $ogone_data ); |
|
| 73 | + $ogone_data_general = new DataGeneralHelper($ogone_data); |
|
| 74 | 74 | |
| 75 | 75 | $ogone_data_general |
| 76 | - ->set_order_id( $payment->format_string( $this->config->order_id ) ) |
|
| 77 | - ->set_order_description( $payment->get_description() ) |
|
| 78 | - ->set_param_plus( 'payment_id=' . $payment->get_id() ) |
|
| 79 | - ->set_currency( $payment->get_currency() ) |
|
| 80 | - ->set_amount( $payment->get_amount()->get_amount() ) |
|
| 81 | - ->set_language( $payment->get_locale() ); |
|
| 76 | + ->set_order_id($payment->format_string($this->config->order_id)) |
|
| 77 | + ->set_order_description($payment->get_description()) |
|
| 78 | + ->set_param_plus('payment_id=' . $payment->get_id()) |
|
| 79 | + ->set_currency($payment->get_currency()) |
|
| 80 | + ->set_amount($payment->get_amount()->get_amount()) |
|
| 81 | + ->set_language($payment->get_locale()); |
|
| 82 | 82 | |
| 83 | 83 | // Customer |
| 84 | - $ogone_data_customer = new DataCustomerHelper( $ogone_data ); |
|
| 84 | + $ogone_data_customer = new DataCustomerHelper($ogone_data); |
|
| 85 | 85 | |
| 86 | 86 | $ogone_data_customer |
| 87 | - ->set_name( $payment->get_customer_name() ) |
|
| 88 | - ->set_email( $payment->get_email() ) |
|
| 89 | - ->set_address( $payment->get_address() ) |
|
| 90 | - ->set_zip( $payment->get_zip() ) |
|
| 91 | - ->set_town( $payment->get_city() ) |
|
| 92 | - ->set_country( $payment->get_country() ) |
|
| 93 | - ->set_telephone_number( $payment->get_telephone_number() ); |
|
| 87 | + ->set_name($payment->get_customer_name()) |
|
| 88 | + ->set_email($payment->get_email()) |
|
| 89 | + ->set_address($payment->get_address()) |
|
| 90 | + ->set_zip($payment->get_zip()) |
|
| 91 | + ->set_town($payment->get_city()) |
|
| 92 | + ->set_country($payment->get_country()) |
|
| 93 | + ->set_telephone_number($payment->get_telephone_number()); |
|
| 94 | 94 | |
| 95 | 95 | // URL's |
| 96 | - $ogone_url_helper = new DataUrlHelper( $ogone_data ); |
|
| 96 | + $ogone_url_helper = new DataUrlHelper($ogone_data); |
|
| 97 | 97 | |
| 98 | 98 | $ogone_url_helper |
| 99 | - ->set_accept_url( add_query_arg( 'status', Statuses::SUCCESS, $payment->get_return_url() ) ) |
|
| 100 | - ->set_cancel_url( add_query_arg( 'status', Statuses::CANCELLED, $payment->get_return_url() ) ) |
|
| 101 | - ->set_decline_url( add_query_arg( 'status', Statuses::FAILURE, $payment->get_return_url() ) ) |
|
| 102 | - ->set_exception_url( add_query_arg( 'status', Statuses::FAILURE, $payment->get_return_url() ) ) |
|
| 103 | - ->set_back_url( home_url( '/' ) ) |
|
| 104 | - ->set_home_url( home_url( '/' ) ); |
|
| 99 | + ->set_accept_url(add_query_arg('status', Statuses::SUCCESS, $payment->get_return_url())) |
|
| 100 | + ->set_cancel_url(add_query_arg('status', Statuses::CANCELLED, $payment->get_return_url())) |
|
| 101 | + ->set_decline_url(add_query_arg('status', Statuses::FAILURE, $payment->get_return_url())) |
|
| 102 | + ->set_exception_url(add_query_arg('status', Statuses::FAILURE, $payment->get_return_url())) |
|
| 103 | + ->set_back_url(home_url('/')) |
|
| 104 | + ->set_home_url(home_url('/')); |
|
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | /** |
@@ -109,13 +109,13 @@ discard block |
||
| 109 | 109 | * |
| 110 | 110 | * @param Payment $payment |
| 111 | 111 | */ |
| 112 | - public function update_status( Payment $payment ) { |
|
| 113 | - if ( ! filter_has_var( INPUT_GET, 'status' ) ) { |
|
| 112 | + public function update_status(Payment $payment) { |
|
| 113 | + if ( ! filter_has_var(INPUT_GET, 'status')) { |
|
| 114 | 114 | return; |
| 115 | 115 | } |
| 116 | 116 | |
| 117 | - $status = filter_input( INPUT_GET, 'status', FILTER_SANITIZE_STRING ); |
|
| 117 | + $status = filter_input(INPUT_GET, 'status', FILTER_SANITIZE_STRING); |
|
| 118 | 118 | |
| 119 | - $payment->set_status( $status ); |
|
| 119 | + $payment->set_status($status); |
|
| 120 | 120 | } |
| 121 | 121 | } |
@@ -17,27 +17,27 @@ |
||
| 17 | 17 | class ConfigFactory extends GatewayConfigFactory { |
| 18 | 18 | private $config_class; |
| 19 | 19 | |
| 20 | - public function __construct( $config_class = null, $config_test_class = null ) { |
|
| 21 | - $this->config_class = is_null( $config_class ) ? __NAMESPACE__ . '\Config' : $config_class; |
|
| 22 | - $this->config_test_class = is_null( $config_test_class ) ? __NAMESPACE__ . '\Config' : $config_test_class; |
|
| 20 | + public function __construct($config_class = null, $config_test_class = null) { |
|
| 21 | + $this->config_class = is_null($config_class) ? __NAMESPACE__ . '\Config' : $config_class; |
|
| 22 | + $this->config_test_class = is_null($config_test_class) ? __NAMESPACE__ . '\Config' : $config_test_class; |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | - public function get_config( $post_id ) { |
|
| 26 | - $mode = get_post_meta( $post_id, '_pronamic_gateway_mode', true ); |
|
| 25 | + public function get_config($post_id) { |
|
| 26 | + $mode = get_post_meta($post_id, '_pronamic_gateway_mode', true); |
|
| 27 | 27 | |
| 28 | - $config_class = ( 'test' === $mode ) ? $this->config_test_class : $this->config_class; |
|
| 28 | + $config_class = ('test' === $mode) ? $this->config_test_class : $this->config_class; |
|
| 29 | 29 | |
| 30 | 30 | $config = new $config_class(); |
| 31 | 31 | |
| 32 | - $form_action_url = get_post_meta( $post_id, '_pronamic_gateway_ogone_form_action_url', true ); |
|
| 32 | + $form_action_url = get_post_meta($post_id, '_pronamic_gateway_ogone_form_action_url', true); |
|
| 33 | 33 | |
| 34 | - if ( '' !== $form_action_url ) { |
|
| 35 | - $config->set_form_action_url( $form_action_url ); |
|
| 34 | + if ('' !== $form_action_url) { |
|
| 35 | + $config->set_form_action_url($form_action_url); |
|
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | $config->mode = $mode; |
| 39 | - $config->psp_id = get_post_meta( $post_id, '_pronamic_gateway_ogone_psp_id', true ); |
|
| 40 | - $config->order_id = get_post_meta( $post_id, '_pronamic_gateway_ogone_order_id', true ); |
|
| 39 | + $config->psp_id = get_post_meta($post_id, '_pronamic_gateway_ogone_psp_id', true); |
|
| 40 | + $config->order_id = get_post_meta($post_id, '_pronamic_gateway_ogone_order_id', true); |
|
| 41 | 41 | |
| 42 | 42 | return $config; |
| 43 | 43 | } |