public static function update_status_unknown_to_success(Pronamic_Pay_Payment $payment, $can_redirect = false) { $data = new Pronamic_WP_Pay_Extensions_S2Member_PaymentData(array('level' => get_post_meta($payment->get_id(), '_pronamic_payment_s2member_level', true), 'period' => get_post_meta($payment->get_id(), '_pronamic_payment_s2member_period', true), 'ccaps' => get_post_meta($payment->get_id(), '_pronamic_payment_s2member_ccaps', true))); $email = $payment->get_email(); // get account from email $user = get_user_by('email', $email); // No valid user? if (!$user) { // Make a random string for password $random_string = wp_generate_password(10); // Make a user with the username as the email $user_id = wp_create_user($email, $random_string, $email); // Subject $subject = __('Account Confirmation', 'pronamic_ideal') . ' | ' . get_bloginfo('name'); // Message $message = get_option('pronamic_pay_s2member_signup_email_message'); $message = str_replace(array('%%email%%', '%%password%%'), array($email, $password), $message); // Mail wp_mail($email, $subject, $message); $user = new WP_User($user_id); } $level = $data->get_level(); $period = $data->get_period(); $ccaps = $data->get_ccaps(); $capability = 'access_s2member_level' . $level; $role = 's2member_level' . $level; // Update user role //$user->add_cap( $capability ); // TODO Perhaps this should line be removed. At s2Member EOT this capability is not removed, which allows the user to illegitimately view the protected content. $user->set_role($role); $note = sprintf(__('Update user "%s" to role "%s" and added custom capability "%s".', 'pronamic_ideal'), $email, $role, $capability); $payment->add_note($note); // Custom Capabilities if (!empty($ccaps)) { $ccaps = Pronamic_WP_Pay_Extensions_S2Member_Util::ccap_string_to_array($ccaps); Pronamic_WP_Pay_Extensions_S2Member_Util::ccap_user_update($user, $ccaps); } // Registration times $registration_time = time(); $registration_times = get_user_option('s2member_paid_registration_times', $user->ID); if (empty($registration_times)) { $registration_times = array(); } $registration_times['level' . $level] = $registration_time; update_user_option($user->ID, 's2member_paid_registration_times', $registration_times); if (in_array($period, array('1 L'))) { // Lifetime, delete end of time option delete_user_option($user->ID, 's2member_auto_eot_time'); } else { // Auto end of time // @see https://github.com/WebSharks/s2Member/blob/131126/s2member/includes/classes/utils-time.inc.php#L100 $eot_time_current = get_user_option('s2member_auto_eot_time', $user->ID); if (!is_numeric($eot_time_current)) { $eot_time_current = time(); } $eot_time_new = c_ws_plugin__s2member_utils_time::auto_eot_time($user->ID, false, $period, false, $eot_time_current); update_user_option($user->ID, 's2member_auto_eot_time', $eot_time_new); } }
/** * Update status of the specified payment * * @param Pronamic_Pay_Payment $payment */ public function update_status(Pronamic_Pay_Payment $payment) { $approval_code = filter_input(INPUT_POST, 'approval_code', FILTER_SANITIZE_STRING); $input_hash = filter_input(INPUT_POST, 'response_hash'); $hash_values = array($this->client->get_secret(), $approval_code, filter_input(INPUT_POST, 'chargetotal', FILTER_SANITIZE_STRING), filter_input(INPUT_POST, 'currency', FILTER_SANITIZE_STRING), filter_input(INPUT_POST, 'txndatetime', FILTER_SANITIZE_STRING), $this->client->get_storename()); if (filter_has_var(INPUT_POST, 'notification_hash')) { $input_hash = filter_input(INPUT_POST, 'notification_hash'); $hash_values = array(filter_input(INPUT_POST, 'chargetotal', FILTER_SANITIZE_STRING), $this->client->get_secret(), filter_input(INPUT_POST, 'currency', FILTER_SANITIZE_STRING), filter_input(INPUT_POST, 'txndatetime', FILTER_SANITIZE_STRING), $this->client->get_storename(), $approval_code); } $hash = Pronamic_WP_Pay_Gateways_EMS_ECommerce_Client::compute_hash($hash_values); // Check if the posted hash is equal to the calculated response or notification hash if (0 === strcasecmp($input_hash, $hash)) { $response_code = substr($approval_code, 0, 1); switch ($response_code) { case 'Y': $status = Pronamic_WP_Pay_Statuses::SUCCESS; break; case 'N': $status = Pronamic_WP_Pay_Statuses::FAILURE; $fail_code = filter_input(INPUT_POST, 'fail_rc', FILTER_SANITIZE_NUMBER_INT); if ('5993' === $fail_code) { $status = Pronamic_WP_Pay_Statuses::CANCELLED; } break; default: $status = Pronamic_WP_Pay_Statuses::OPEN; break; } // Set the status of the payment $payment->set_status($status); $labels = array('approval_code' => __('Approval code', 'pronamic_ideal'), 'oid' => __('Order ID', 'pronamic_ideal'), 'refnumber' => _x('Reference number', 'creditcard', 'pronamic_ideal'), 'status' => __('Status', 'pronamic_ideal'), 'txndate_processed' => __('Time of transaction processing', 'pronamic_ideal'), 'tdate' => __('Identification for transaction', 'pronamic_ideal'), 'fail_reason' => __('Fail reason', 'pronamic_ideal'), 'response_hash' => __('Response hash', 'pronamic_ideal'), 'processor_response_code' => __('Processor response code', 'pronamic_ideal'), 'fail_rc' => __('Fail code', 'pronamic_ideal'), 'terminal_id' => __('Terminal ID', 'pronamic_ideal'), 'ccbin' => __('Creditcard issuing bank', 'pronamic_ideal'), 'cccountry' => __('Creditcard country', 'pronamic_ideal'), 'ccbrand' => __('Creditcard brand', 'pronamic_ideal')); $note = ''; $note .= '<p>'; $note .= __('EMS e-Commerce transaction data in response message:', 'pronamic_ideal'); $note .= '</p>'; $note .= '<dl>'; foreach ($labels as $key => $label) { if (filter_has_var(INPUT_POST, $key)) { $note .= sprintf('<dt>%s</dt>', esc_html($label)); $note .= sprintf('<dd>%s</dd>', esc_html(filter_input(INPUT_POST, $key, FILTER_SANITIZE_STRING))); } } $note .= '</dl>'; $payment->add_note($note); } }
/** * Update status of the specified payment * * @param Pronamic_Pay_Payment $payment */ public function update_status(Pronamic_Pay_Payment $payment) { $input_data = filter_input(INPUT_POST, 'Data', FILTER_SANITIZE_STRING); $input_seal = filter_input(INPUT_POST, 'Seal', FILTER_SANITIZE_STRING); $data = Pronamic_WP_Pay_Gateways_OmniKassa_Client::parse_piped_string($input_data); $seal = Pronamic_WP_Pay_Gateways_OmniKassa_Client::compute_seal($input_data, $this->config->secret_key); // Check if the posted seal is equal to our seal if (0 === strcasecmp($input_seal, $seal)) { $response_code = $data['responseCode']; $status = Pronamic_WP_Pay_Gateways_OmniKassa_ResponseCodes::transform($response_code); // Set the status of the payment $payment->set_status($status); $labels = array('amount' => __('Amount', 'pronamic_ideal'), 'captureDay' => _x('Capture Day', 'creditcard', 'pronamic_ideal'), 'captureMode' => _x('Capture Mode', 'creditcard', 'pronamic_ideal'), 'currencyCode' => __('Currency Code', 'pronamic_ideal'), 'merchantId' => __('Merchant ID', 'pronamic_ideal'), 'orderId' => __('Order ID', 'pronamic_ideal'), 'transactionDateTime' => __('Transaction Date Time', 'pronamic_ideal'), 'transactionReference' => __('Transaction Reference', 'pronamic_ideal'), 'keyVersion' => __('Key Version', 'pronamic_ideal'), 'authorisationId' => __('Authorisation ID', 'pronamic_ideal'), 'paymentMeanBrand' => __('Payment Mean Brand', 'pronamic_ideal'), 'paymentMeanType' => __('Payment Mean Type', 'pronamic_ideal'), 'responseCode' => __('Response Code', 'pronamic_ideal')); $note = ''; $note .= '<p>'; $note .= __('OmniKassa transaction data in response message:', 'pronamic_ideal'); $note .= '</p>'; $note .= '<dl>'; foreach ($labels as $key => $label) { if (isset($data[$key])) { $note .= sprintf('<dt>%s</dt>', esc_html($label)); $note .= sprintf('<dd>%s</dd>', esc_html($data[$key])); } } $note .= '</dl>'; $payment->add_note($note); } }
/** * Update status payment note * * @param Pronamic_Pay_Payment $payment * @param array $data */ private function update_status_payment_note(Pronamic_Pay_Payment $payment, $data) { $labels = array('STATUS' => __('Status', 'pronamic_ideal'), 'ORDERID' => __('Order ID', 'pronamic_ideal'), 'CURRENCY' => __('Currency', 'pronamic_ideal'), 'AMOUNT' => __('Amount', 'pronamic_ideal'), 'PM' => __('Payment Method', 'pronamic_ideal'), 'ACCEPTANCE' => __('Acceptance', 'pronamic_ideal'), 'STATUS' => __('Status', 'pronamic_ideal'), 'CARDNO' => __('Card Number', 'pronamic_ideal'), 'ED' => __('End Date', 'pronamic_ideal'), 'CN' => __('Customer Name', 'pronamic_ideal'), 'TRXDATE' => __('Transaction Date', 'pronamic_ideal'), 'PAYID' => __('Pay ID', 'pronamic_ideal'), 'NCERROR' => __('NC Error', 'pronamic_ideal'), 'BRAND' => __('Brand', 'pronamic_ideal'), 'IP' => __('IP', 'pronamic_ideal'), 'SHASIGN' => __('SHA Signature', 'pronamic_ideal')); $note = ''; $note .= '<p>'; $note .= __('Ogone transaction data in response message:', 'pronamic_ideal'); $note .= '</p>'; $note .= '<dl>'; foreach ($labels as $key => $label) { if (isset($data[$key]) && '' !== $data[$key]) { $note .= sprintf('<dt>%s</dt>', esc_html($label)); $note .= sprintf('<dd>%s</dd>', esc_html($data[$key])); } } $note .= '</dl>'; $payment->add_note($note); }
/** * Update status of the specified payment * * @param Pronamic_Pay_Payment $payment */ public function update_status(Pronamic_Pay_Payment $payment) { $method = filter_var($_SERVER['REQUEST_METHOD'], FILTER_SANITIZE_STRING); $data = array(); switch ($method) { case 'GET': $data = $_GET; break; case 'POST': $data = $_POST; // WPCS: CSRF OK break; } $data = Pronamic_WP_Pay_Buckaroo_Util::urldecode($data); $data = stripslashes_deep($data); $data = $this->client->verify_request($data); if ($data) { $payment->set_transaction_id($data[Pronamic_WP_Pay_Buckaroo_Parameters::PAYMENT]); $payment->set_status(Pronamic_WP_Pay_Buckaroo_Statuses::transform($data[Pronamic_WP_Pay_Buckaroo_Parameters::STATUS_CODE])); $payment->set_consumer_iban($data[Pronamic_WP_Pay_Buckaroo_Parameters::SERVICE_IDEAL_CONSUMER_IBAN]); $payment->set_consumer_bic($data[Pronamic_WP_Pay_Buckaroo_Parameters::SERVICE_IDEAL_CONSUMER_BIC]); $payment->set_consumer_name($data[Pronamic_WP_Pay_Buckaroo_Parameters::SERVICE_IDEAL_CONSUMER_NAME]); $labels = array(Pronamic_WP_Pay_Buckaroo_Parameters::PAYMENT => __('Payment', 'pronamic_ideal'), Pronamic_WP_Pay_Buckaroo_Parameters::PAYMENT_METHOD => __('Payment Method', 'pronamic_ideal'), Pronamic_WP_Pay_Buckaroo_Parameters::STATUS_CODE => __('Status Code', 'pronamic_ideal'), Pronamic_WP_Pay_Buckaroo_Parameters::STATUS_CODE_DETAIL => __('Status Code Detail', 'pronamic_ideal'), Pronamic_WP_Pay_Buckaroo_Parameters::STATUS_MESSAGE => __('Status Message', 'pronamic_ideal'), Pronamic_WP_Pay_Buckaroo_Parameters::INVOICE_NUMBER => __('Invoice Number', 'pronamic_ideal'), Pronamic_WP_Pay_Buckaroo_Parameters::AMOUNT => __('Amount', 'pronamic_ideal'), Pronamic_WP_Pay_Buckaroo_Parameters::CURRENCY => __('Currency', 'pronamic_ideal'), Pronamic_WP_Pay_Buckaroo_Parameters::TIMESTAMP => __('Timestamp', 'pronamic_ideal'), Pronamic_WP_Pay_Buckaroo_Parameters::SERVICE_IDEAL_CONSUMER_ISSUER => __('Service iDEAL Consumer Issuer', 'pronamic_ideal'), Pronamic_WP_Pay_Buckaroo_Parameters::SERVICE_IDEAL_CONSUMER_NAME => __('Service iDEAL Consumer Name', 'pronamic_ideal'), Pronamic_WP_Pay_Buckaroo_Parameters::SERVICE_IDEAL_CONSUMER_IBAN => __('Service iDEAL Consumer IBAN', 'pronamic_ideal'), Pronamic_WP_Pay_Buckaroo_Parameters::SERVICE_IDEAL_CONSUMER_BIC => __('Service iDEAL Consumer BIC', 'pronamic_ideal'), Pronamic_WP_Pay_Buckaroo_Parameters::TRANSACTIONS => __('Transactions', 'pronamic_ideal')); $note = ''; $note .= '<p>'; $note .= __('Buckaroo data:', 'pronamic_ideal'); $note .= '</p>'; $note .= '<dl>'; foreach ($labels as $key => $label) { if (isset($data[$key])) { $note .= sprintf('<dt>%s</dt>', esc_html($label)); $note .= sprintf('<dd>%s</dd>', esc_html($data[$key])); } } $note .= '</dl>'; $payment->add_note($note); } }