public function _handle_service_calls($call_type = '')
 {
     // Test for gateway's IP:
     if (leyka_options()->opt('chronopay_ip') && !in_array($_SERVER['REMOTE_ADDR'], explode(',', leyka_options()->opt('chronopay_ip')))) {
         // Security fail
         $message = __("This message has been sent because a call to your ChronoPay function was made from an IP that did not match with the one in your Chronopay gateway setting. This could mean someone is trying to hack your payment website. The details of the call are below.", 'leyka') . "\n\r\n\r";
         $message .= "POST:\n\r" . print_r($_POST, true) . "\n\r\n\r";
         $message .= "GET:\n\r" . print_r($_GET, true) . "\n\r\n\r";
         $message .= "SERVER:\n\r" . print_r($_SERVER, true) . "\n\r\n\r";
         $message .= "IP:\n\r" . print_r($_SERVER['REMOTE_ADDR'], true) . "\n\r\n\r";
         $message .= "Chronopay IP setting value:\n\r" . print_r(leyka_options()->opt('chronopay_ip'), true) . "\n\r\n\r";
         wp_mail(get_option('admin_email'), __('Chronopay IP check failed!', 'leyka'), $message);
         status_header(200);
         die;
     }
     // Test for e-sign:
     $sharedsec = leyka_options()->opt('chronopay_shared_sec');
     $customer_id = isset($_POST['customer_id']) ? trim(stripslashes($_POST['customer_id'])) : '';
     $transaction_id = isset($_POST['transaction_id']) ? trim(stripslashes($_POST['transaction_id'])) : '';
     $transaction_type = isset($_POST['transaction_type']) ? trim(stripslashes($_POST['transaction_type'])) : '';
     $total = isset($_POST['total']) ? trim(stripslashes($_POST['total'])) : '';
     $sign = md5($sharedsec . $customer_id . $transaction_id . $transaction_type . $total);
     if (empty($_POST['sign']) || $sign != trim(stripslashes($_POST['sign']))) {
         // Security fail
         $message = __("This message has been sent because a call to your ChronoPay function was made by a server that did not have the correct security key.  This could mean someone is trying to hack your payment site.  The details of the call are below.", 'leyka') . "\n\r\n\r";
         $message .= "POST:\n\r" . print_r($_POST, true) . "\n\r\n\r";
         $message .= "GET:\n\r" . print_r($_GET, true) . "\n\r\n\r";
         $message .= "SERVER:\n\r" . print_r($_SERVER, true) . "\n\r\n\r";
         wp_mail(get_option('admin_email'), __('Chronopay security key check failed!', 'leyka'), $message);
         status_header(200);
         die;
     }
     $_POST['cs2'] = (int) $_POST['cs2'];
     $donation = new Leyka_Donation($_POST['cs2']);
     if (!$donation->id || !$donation->campaign_id) {
         $message = __("This message has been sent because a call to your ChronoPay callbacks URL was made with a donation ID parameter (POST['cs2']) that Leyka is unknown of. The details of the call are below.", 'leyka') . "\n\r\n\r";
         $message .= "POST:\n\r" . print_r($_POST, true) . "\n\r\n\r";
         $message .= "GET:\n\r" . print_r($_GET, true) . "\n\r\n\r";
         $message .= "SERVER:\n\r" . print_r($_SERVER, true) . "\n\r\n\r";
         $message .= "Donation ID:\n\r" . $_POST['cs2'] . "\n\r\n\r";
         wp_mail(get_option('admin_email'), __('Chronopay gives unknown donation ID parameter!', 'leyka'), $message);
         status_header(200);
         die;
     }
     if (strtolower($_POST['currency']) == 'rub') {
         $currency_string = 'rur';
     } else {
         $message = __("This message has been sent because a call to your ChronoPay callbacks URL was made with a currency parameter (POST['currency']) that Leyka is unknown of. The details of the call are below.", 'leyka') . "\n\r\n\r";
         $message .= "POST:\n\r" . print_r($_POST, true) . "\n\r\n\r";
         $message .= "GET:\n\r" . print_r($_GET, true) . "\n\r\n\r";
         $message .= "SERVER:\n\r" . print_r($_SERVER, true) . "\n\r\n\r";
         wp_mail(get_option('admin_email'), __('Chronopay gives unknown currency parameter!', 'leyka'), $message);
         status_header(200);
         die;
     }
     // Store donation data - rebill payment:
     if (apply_filters('leyka_chronopay_callback_is_recurring', leyka_options()->opt('chronopay_card_rebill_product_id_' . $currency_string) && $_POST['product_id'] == leyka_options()->opt('chronopay_card_rebill_product_id_' . $currency_string), $_POST['product_id'])) {
         if ($transaction_type == 'Purchase') {
             // Initial rebill payment
             if ($donation->status != 'funded') {
                 $donation->add_gateway_response($_POST);
                 $donation->status = 'funded';
                 $donation->type = 'rebill';
                 if (!$donation->donor_email && !empty($_POST['email'])) {
                     $donation->donor_email = $_POST['email'];
                 }
                 Leyka_Donation_Management::send_all_emails($donation->id);
                 // Save donor's customer_id parameter to link this donation to all others in this recurrent chain:
                 $donation->chronopay_customer_id = $customer_id;
             }
         } else {
             if ($transaction_type == 'Rebill') {
                 // Rebill payment
                 $donation_id = Leyka_Donation::add(array('status' => 'funded', 'payment_type' => 'rebill'));
                 $donation->add_gateway_response($_POST);
                 $init_recurrent_payment = $this->get_init_recurrent_donation($customer_id);
                 $donation->chronopay_customer_id = $customer_id;
                 $donation->payment_title = $init_recurrent_payment->title;
                 $donation->campaign_id = $init_recurrent_payment->campaign_id;
                 $donation->payment_method_id = $init_recurrent_payment->pm_id;
                 $donation->gateway_id = $init_recurrent_payment->gateway_id;
                 $donation->donor_name = $init_recurrent_payment->donor_name;
                 $donation->donor_email = $init_recurrent_payment->donor_email;
                 $donation->amount = $init_recurrent_payment->amount;
                 $donation->currency = $init_recurrent_payment->currency;
                 Leyka_Donation_Management::send_all_emails($donation_id);
             }
         }
     } else {
         if (leyka_options()->opt('chronopay_card_product_id_' . $currency_string) && $_POST['product_id'] == leyka_options()->opt('chronopay_card_product_id_' . $currency_string)) {
             if ($donation->status != 'funded') {
                 $donation->add_gateway_response($_POST);
                 $donation->status = 'funded';
                 if (!$donation->donor_email && !empty($_POST['email'])) {
                     $donation->donor_email = $_POST['email'];
                 }
                 Leyka_Donation_Management::send_all_emails($donation->id);
                 // Save donor's customer_id parameter.. just because we're scrupulous 0:)
                 $donation->chronopay_customer_id = $customer_id;
             }
         }
     }
     status_header(200);
     die;
 }
示例#2
0
 public static function get_instance()
 {
     // If the single instance hasn't been set, set it now.
     if (null == self::$_instance) {
         self::$_instance = new self();
     }
     return self::$_instance;
 }
示例#3
0
 /**
  * Register leyka post types.
  */
 function register_post_types()
 {
     /** Donation CPT: */
     $args = array('label' => __('Donations', 'leyka'), 'labels' => array('name' => __('Donations', 'leyka'), 'singular_name' => __('Donation', 'leyka'), 'menu_name' => __('Donations', 'leyka'), 'all_items' => __('Donations', 'leyka'), 'add_new' => __('New donation', 'leyka'), 'add_new_item' => __('Add new donation', 'leyka'), 'edit_item' => __('Donation profile', 'leyka'), 'new_item' => __('New donation', 'leyka'), 'view_item' => __('View donation', 'leyka'), 'search_items' => __('Search donation', 'leyka'), 'not_found' => __('Donations not found', 'leyka'), 'not_found_in_trash' => __('Donations not found in Trash', 'leyka')), 'exclude_from_search' => true, 'public' => true, 'show_ui' => true, 'show_in_nav_menus' => false, 'show_in_menu' => false, 'show_in_admin_bar' => false, 'supports' => false, 'taxonomies' => array(), 'has_archive' => false, 'capability_type' => 'donation', 'map_meta_cap' => true, 'rewrite' => array('slug' => 'donation', 'with_front' => false));
     register_post_type(Leyka_Donation_Management::$post_type, $args);
     /** Donation editing messages */
     add_filter('post_updated_messages', array(Leyka_Donation_Management::get_instance(), 'set_admin_messages'));
     /** Campaign CPT: */
     $args = array('labels' => array('name' => __('Campaigns', 'leyka'), 'singular_name' => __('Campaign', 'leyka'), 'menu_name' => __('Campaigns', 'leyka'), 'all_items' => __('All Campaigns', 'leyka'), 'add_new' => __('New campaign', 'leyka'), 'add_new_item' => __('Add new campaign', 'leyka'), 'edit_item' => __('Edit campaign', 'leyka'), 'new_item' => __('New campaign', 'leyka'), 'view_item' => __('View campaign', 'leyka'), 'search_items' => __('Search campaigns', 'leyka'), 'not_found' => __('Campaigns not found', 'leyka'), 'not_found_in_trash' => __('Campaigns not found in Trash', 'leyka')), 'exclude_from_search' => false, 'public' => true, 'publicly_queryable' => true, 'show_ui' => true, 'show_in_nav_menus' => true, 'show_in_menu' => false, 'show_in_admin_bar' => true, 'supports' => array('title', 'editor', 'thumbnail'), 'taxonomies' => array(), 'has_archive' => true, 'capability_type' => 'campaign', 'map_meta_cap' => true, 'rewrite' => array('slug' => 'campaign', 'with_front' => false));
     register_post_type(Leyka_Campaign_Management::$post_type, $args);
     /** Campaign editing messages */
     add_filter('post_updated_messages', array(Leyka_Campaign_Management::get_instance(), 'set_admin_messages'));
     register_post_status('submitted', array('label' => _x('Submitted', '«Submitted» donation status', 'leyka'), 'public' => true, 'exclude_from_search' => false, 'show_in_admin_all_list' => true, 'show_in_admin_status_list' => true, 'label_count' => _n_noop('Submitted <span class="count">(%s)</span>', 'Submitted <span class="count">(%s)</span>', 'leyka')));
     register_post_status('funded', array('label' => _x('Funded', '«Completed» donation status', 'leyka'), 'public' => true, 'exclude_from_search' => false, 'show_in_admin_all_list' => true, 'show_in_admin_status_list' => true, 'label_count' => _n_noop('Funded <span class="count">(%s)</span>', 'Funded <span class="count">(%s)</span>', 'leyka')));
     register_post_status('refunded', array('label' => _x('Refunded', '«Refunded» donation status', 'leyka'), 'public' => true, 'exclude_from_search' => false, 'show_in_admin_all_list' => true, 'show_in_admin_status_list' => true, 'label_count' => _n_noop('Refunded <span class="count">(%s)</span>', 'Refunded <span class="count">(%s)</span>', 'leyka')));
     register_post_status('failed', array('label' => _x('Failed', '«Failed» donation status', 'leyka'), 'public' => true, 'exclude_from_search' => false, 'show_in_admin_all_list' => true, 'show_in_admin_status_list' => true, 'label_count' => _n_noop('Failed <span class="count">(%s)</span>', 'Failed <span class="count">(%s)</span>', 'leyka')));
     do_action('leyka_cpt_registered');
 }
 public function _handle_service_calls($call_type = '')
 {
     error_log_yandex_phyz("\n\n---- {$call_type} ----\n\n" . print_r($_REQUEST, true));
     $donation_id = (int) @$_POST['label'];
     // Donation ID
     $amount = (int) @$_POST['withdraw_amount'];
     error_log_yandex_phyz("Label={$donation_id}\n");
     error_log_yandex_phyz("Amount={$amount}\n");
     if (!$donation_id) {
         error_log_yandex_phyz("Label is empty\n");
         return;
     }
     $donation = new Leyka_Donation($donation_id);
     error_log_yandex_phyz("Donation initialized\n");
     error_log_yandex_phyz(print_r($donation, TRUE) . "\n");
     $params_to_sha1 = implode('&', array(@$_POST['notification_type'], @$_POST['operation_id'], @$_POST['amount'], @$_POST['currency'], @$_POST['datetime'], @$_POST['sender'], @$_POST['codepro'], leyka_options()->opt('yandex_money_secret'), @$_POST['label']));
     error_log_yandex_phyz("Params_to_sha1={$params_to_sha1}\n");
     $sha1 = sha1($params_to_sha1);
     error_log_yandex_phyz("sha1={$sha1}\n");
     if ($sha1 != @$_POST['sha1_hash']) {
         error_log_yandex_phyz("Invalid response sha1_hash\n");
         $this->_check_order_answer(1, __('Sorry, there is some tech error on our side. Your payment will be cancelled.', 'leyka'), __('Invalid response sha1_hash', 'leyka'));
     } elseif ($donation) {
         error_log_yandex_phyz("Donation OK\n");
         error_log_yandex_phyz('$donation->sum=' . $donation->sum . "\n");
         error_log_yandex_phyz('$donation->status=' . $donation->status . "\n");
         if ($donation->sum != $amount) {
             error_log_yandex_phyz("Donation sum is unmatched\n");
             $this->_check_order_answer(1, __('Sorry, there is some tech error on our side. Your payment will be cancelled.', 'leyka'), __('Donation sum is unmatched', 'leyka'));
         } elseif ($donation->status != 'funded') {
             error_log_yandex_phyz("Donation is funded\n");
             if (!empty($_POST['notification_type'])) {
                 // Update a donation's actual PM, if needed
                 $actual_pm = $_POST['notification_type'] == 'card-incoming' ? 'yandex_phyz_card' : 'yandex_phyz_money';
                 if ($donation->pm_id != $_POST['notification_type']) {
                     $donation->pm_id = $actual_pm;
                 }
             }
             $donation->add_gateway_response($_POST);
             $donation->status = 'funded';
             Leyka_Donation_Management::send_all_emails($donation->id);
         } else {
             error_log_yandex_phyz("Already funded\n");
         }
         $this->_check_order_answer();
     } else {
         error_log_yandex_phyz("There is no donation in Leyka DB\n");
         $this->_check_order_answer(1, __('Sorry, there is some tech error on our side. Your payment will be cancelled.', 'leyka'), __('Unregistered donation ID', 'leyka'));
     }
 }
 public function _handle_service_calls($call_type = '')
 {
     // Test for gateway's IP:
     if (leyka_options()->opt('cp_ip') && !in_array($_SERVER['REMOTE_ADDR'], explode(',', leyka_options()->opt('cp_ip')))) {
         // Security fail
         $message = __("This message has been sent because a call to your CloudPayments function was made from an IP that did not match with the one in your CloudPayments gateway setting. This could mean someone is trying to hack your payment website. The details of the call are below.", 'leyka') . "\n\r\n\r";
         $message .= "POST:\n\r" . print_r($_POST, true) . "\n\r\n\r";
         $message .= "GET:\n\r" . print_r($_GET, true) . "\n\r\n\r";
         $message .= "SERVER:\n\r" . print_r($_SERVER, true) . "\n\r\n\r";
         $message .= "IP:\n\r" . print_r($_SERVER['REMOTE_ADDR'], true) . "\n\r\n\r";
         $message .= "CloudPayments IP setting value:\n\r" . print_r(leyka_options()->opt('cp_ip'), true) . "\n\r\n\r";
         wp_mail(get_option('admin_email'), __('CloudPayments IP check failed!', 'leyka'), $message);
         status_header(200);
         die;
     }
     switch ($call_type) {
         case 'check':
             // Check if payment is correct
             // InvoiceId - leyka donation ID, SubscriptionId - CP recurring subscription ID
             if (empty($_POST['InvoiceId']) && empty($_POST['SubscriptionId'])) {
                 die(json_encode(array('code' => '10')));
             }
             if (empty($_POST['Amount']) || (double) $_POST['Amount'] <= 0 || empty($_POST['Currency'])) {
                 die(json_encode(array('code' => '11', 'reason' => sprintf('Amount or Currency in POST are empty. Amount: %s, Currency: %s', $_POST['Amount'], $_POST['Currency']))));
             }
             if (empty($_POST['InvoiceId'])) {
                 // Non-init recurring donation
                 if (!$this->get_init_recurrent_donation($_POST['SubscriptionId'])) {
                     die(json_encode(array('code' => '11', 'reason' => sprintf('Init recurring payment is not found. POST SubscriptionId: %s', $_POST['SubscriptionId']))));
                 }
             } else {
                 // Single or init recurring donation
                 $donation = new Leyka_Donation((int) $_POST['InvoiceId']);
                 $donation->add_gateway_response($_POST);
                 switch ($_POST['Currency']) {
                     case 'RUB':
                         $_POST['Currency'] = 'rur';
                         break;
                     case 'USD':
                         $_POST['Currency'] = 'usd';
                         break;
                     case 'EUR':
                         $_POST['Currency'] = 'eur';
                         break;
                     default:
                 }
                 if ($donation->sum != $_POST['Amount'] || $donation->currency != $_POST['Currency']) {
                     die(json_encode(array('code' => '11', 'reason' => sprintf('Amount of original data and POST are mismatching. Original: %.2f %s, POST: %.2f %s', $donation->sum, $donation->currency, $_POST['Amount'], $_POST['Currency']))));
                 }
             }
             die(json_encode(array('code' => '0')));
             // Payment check passed
         // Payment check passed
         case 'complete':
         case 'fail':
             // InvoiceId - leyka donation ID, SubscriptionId - CP recurring subscription ID
             if (empty($_POST['InvoiceId']) && empty($_POST['SubscriptionId'])) {
                 die(json_encode(array('code' => '10')));
             }
             if (empty($_POST['InvoiceId'])) {
                 // Non-init recurring donation
                 $donation = $this->get_donation_by_transaction_id($_POST['TransactionId']);
                 $init_recurrent_payment = $this->get_init_recurrent_donation($_POST['SubscriptionId']);
                 $donation->init_recurring_donation_id = $init_recurrent_payment->id;
                 $donation->payment_title = $init_recurrent_payment->title;
                 $donation->campaign_id = $init_recurrent_payment->campaign_id;
                 $donation->payment_method_id = $init_recurrent_payment->pm_id;
                 $donation->gateway_id = $init_recurrent_payment->gateway_id;
                 $donation->donor_name = $init_recurrent_payment->donor_name;
                 $donation->donor_email = $init_recurrent_payment->donor_email;
                 $donation->amount = $init_recurrent_payment->amount;
                 $donation->currency = $init_recurrent_payment->currency;
             } else {
                 // Single or init recurring donation
                 $donation = new Leyka_Donation((int) $_POST['InvoiceId']);
             }
             if (!empty($_POST['SubscriptionId'])) {
                 $donation->payment_type = 'rebill';
                 $donation->recurring_id = $_POST['SubscriptionId'];
             }
             $donation->add_gateway_response($_POST);
             if ($call_type == 'complete') {
                 Leyka_Donation_Management::send_all_emails($donation->id);
                 $donation->status = 'funded';
             } else {
                 $donation->status = 'failed';
             }
             die(json_encode(array('code' => '0')));
             // Payment completed / fail registered
         // Payment completed / fail registered
         default:
     }
 }
 public function _handle_service_calls($call_type = '')
 {
     if (empty($_REQUEST['InvId'])) {
         $message = __("This message has been sent because a call to your Robokassa callback (Result URL) was made without InvId parameter given. The details of the call are below.", 'leyka') . "\n\r\n\r";
         $message .= "THEIR_POST:\n\r" . print_r($_POST, true) . "\n\r\n\r";
         $message .= "GET:\n\r" . print_r($_GET, true) . "\n\r\n\r";
         $message .= "SERVER:\n\r" . print_r($_SERVER, true) . "\n\r\n\r";
         wp_mail(get_option('admin_email'), __('Robokassa - InvId missing!', 'leyka'), $message);
         status_header(200);
         die;
     }
     $donation = new Leyka_Donation((int) $_REQUEST['InvId']);
     // Test for e-sign. Values from Robokassa must be used:
     $sign = strtoupper(md5("{$_REQUEST['OutSum']}:{$_REQUEST['InvId']}:" . leyka_options()->opt('robokassa_shop_password2') . ":Shp_item=1"));
     if (empty($_REQUEST['SignatureValue']) || strtoupper($_REQUEST['SignatureValue']) != $sign) {
         $message = __("This message has been sent because a call to your Robokassa callback was called with wrong digital signature. This could mean someone is trying to hack your payment website. The details of the call are below:", 'leyka') . "\n\r\n\r";
         $message .= "POST:\n\r" . print_r($_POST, true) . "\n\r\n\r";
         $message .= "GET:\n\r" . print_r($_GET, true) . "\n\r\n\r";
         $message .= "SERVER:\n\r" . print_r($_SERVER, true) . "\n\r\n\r";
         $message .= "Signature from request:\n\r" . print_r($_REQUEST['SignatureValue'], true) . "\n\r\n\r";
         $message .= "Signature calculated:\n\r" . print_r($sign, true) . "\n\r\n\r";
         wp_mail(get_option('admin_email'), __('Robokassa digital signature check failed!', 'leyka'), $message);
         die;
     }
     // Single payment:
     if ($donation->status != 'funded') {
         $donation->add_gateway_response($_REQUEST);
         $donation->status = 'funded';
         //            $currency_letter = substr($_REQUEST['IncCurrLabel'], -1);
         $_REQUEST['IncCurrLabel'] = empty($_REQUEST['IncCurrLabel']) ? '' : substr_replace($_REQUEST['IncCurrLabel'], '', -1);
         if ($donation->pm_id != $_REQUEST['IncCurrLabel'] && array_key_exists($_REQUEST['IncCurrLabel'], $this->_payment_methods)) {
             $donation->pm_id = $_REQUEST['IncCurrLabel'];
         }
         Leyka_Donation_Management::send_all_emails($donation->id);
         die('OK' . $_REQUEST['InvId']);
     } else {
         die;
     }
 }
示例#7
0
 public function _handle_service_calls($call_type = '')
 {
     switch ($call_type) {
         case 'check_order':
             // Gateway test before the payment - to check if it's correct
             if ($_POST['action'] != 'checkOrder') {
                 // Payment isn't correct, we're not allowing it
                 $this->_callback_answer(1, 'co', __('Wrong service operation', 'leyka'));
             }
             $_POST['orderNumber'] = (int) $_POST['orderNumber'];
             // Donation ID
             if (!$_POST['orderNumber']) {
                 $this->_callback_answer(1, 'co', __('Sorry, there is some tech error on our side. Your payment will be cancelled.', 'leyka'), __('OrderNumber is not set', 'leyka'));
             }
             $donation = new Leyka_Donation($_POST['orderNumber']);
             if ($donation->sum != $_POST['orderSumAmount']) {
                 $this->_callback_answer(1, 'co', __('Sorry, there is some tech error on our side. Your payment will be cancelled.', 'leyka'), __('Donation sum is unmatched', 'leyka'));
             }
             $donation->add_gateway_response($_POST);
             //                set_transient('leyka_yandex_test_cho', '<pre>'.print_r($_POST, true).'</pre>', 60*60*24);
             $this->_callback_answer();
             // OK for yandex money payment
             break;
             // Not needed, just so my IDE can relax
         // Not needed, just so my IDE can relax
         case 'payment_aviso':
             if ($_POST['action'] != 'paymentAviso') {
                 // Payment isn't correct, we're not allowing it
                 $this->_callback_answer(1, 'pa', __('Wrong service operation', 'leyka'));
             }
             $_POST['orderNumber'] = (int) $_POST['orderNumber'];
             // Donation ID
             if (!$_POST['orderNumber']) {
                 $this->_callback_answer(1, 'pa', __('Sorry, there is some tech error on our side. Your payment will be cancelled.', 'leyka'), __('OrderNumber is not set', 'leyka'));
             }
             $donation = new Leyka_Donation($_POST['orderNumber']);
             if ($donation->sum != $_POST['orderSumAmount']) {
                 $this->_callback_answer(1, 'pa', __('Sorry, there is some tech error on our side. Your payment will be cancelled.', 'leyka'), __('Donation sum is unmatched', 'leyka'));
             }
             if ($donation->status != 'funded') {
                 $donation->add_gateway_response($_POST);
                 $donation->status = 'funded';
                 Leyka_Donation_Management::send_all_emails($donation->id);
             }
             do_action('leyka_yandex_payment_aviso_success', $donation);
             //                set_transient('leyka_yandex_test_pa', '<pre>'.print_r($_POST, true).'</pre>', 60*60*24);
             $this->_callback_answer(0, 'pa');
             // OK for yandex money payment
             break;
             // Not needed, just so my IDE can relax
         // Not needed, just so my IDE can relax
         default:
     }
 }
 public function _handle_service_calls($call_type = '')
 {
     if (empty($_POST['orderId'])) {
         $message = __("This message has been sent because a call to your RBK Money callback was made without orderId parameter given. The details of the call are below.", 'leyka') . "\n\r\n\r";
         $message .= "THEIR_POST:\n\r" . print_r($_POST, true) . "\n\r\n\r";
         $message .= "GET:\n\r" . print_r($_GET, true) . "\n\r\n\r";
         $message .= "SERVER:\n\r" . print_r($_SERVER, true) . "\n\r\n\r";
         wp_mail(get_option('admin_email'), __('RBK Money - orderId missing!', 'leyka'), $message);
         status_header(200);
         die;
     }
     $donation = new Leyka_Donation((int) stripslashes($_POST['orderId']));
     if (!$donation) {
         status_header(200);
         die;
     }
     // Test for e-sign:
     if (leyka_options()->opt('rbk_use_hash')) {
         $sign = hash(leyka_options()->opt('rbk_hash_type'), implode('::', array(leyka_options()->opt('rbk_eshop_id'), $_POST['orderId'], $_POST['serviceName'], leyka_options()->opt('rbk_eshop_account'), $donation->amount, mb_strtoupper($donation->currency), $_POST['paymentStatus'], $_POST['userName'], $donation->donor_email, $_POST['paymentData'], leyka_options()->opt('rbk_secret_key'))));
         if (empty($_POST['hash']) || $sign != trim(mb_strtolower($_POST['hash']))) {
             $message = __("This message has been sent because a call to your RBK Money callback was called with wrong data hash. This could mean someone is trying to hack your payment site. The details of the call are below.", 'leyka') . "\n\r\n\r";
             $message .= "POST:\n\r" . print_r($_POST, true) . "\n\r\n\r";
             $message .= "GET:\n\r" . print_r($_GET, true) . "\n\r\n\r";
             $message .= "SERVER:\n\r" . print_r($_SERVER, true) . "\n\r\n\r";
             wp_mail(get_option('admin_email'), __('RBK Money hash check failed!', 'leyka'), $message);
             status_header(200);
             die;
         }
     }
     // Single payment:
     switch ($_POST['paymentStatus']) {
         case 4:
             $new_status = 'failed';
             break;
         case 5:
             $new_status = 'funded';
             break;
         default:
             $new_status = 'submitted';
     }
     if ($donation->status != $new_status) {
         $donation->add_gateway_response($_POST);
         $donation->status = $new_status;
         if (!$donation->donor_email && !empty($_POST['userEmail'])) {
             $donation->donor_email = $_POST['userEmail'];
         }
         if (!$donation->donor_name && !empty($_POST['userName'])) {
             $donation->donor_name = $_POST['userName'];
         }
         Leyka_Donation_Management::send_all_emails($donation->id);
     }
     status_header(200);
     die;
 }