Example #1
0
function fn_rus_payments_change_order_status(&$status_to, &$status_from, &$order_info, &$force_notification, &$order_statuses, &$place_order)
{
    $processor_data = fn_get_processor_data($order_info['payment_id']);
    $payment_info = $order_info['payment_info'];
    if (!empty($processor_data['processor']) && $processor_data['processor'] == 'Yandex.Money' && !empty($payment_info['yandex_postponed_payment'])) {
        try {
            $cert = $processor_data['processor_params']['certificate_filename'];
            $mws_client = new MWSClient();
            $mws_client->authenticate(array('pkcs12_file' => Registry::get('config.dir.certificates') . $cert, 'pass' => $processor_data['processor_params']['p12_password'], 'is_test_mode' => $processor_data['processor_params']['mode'] == 'test'));
            if ($status_to == $processor_data['processor_params']['confirmed_order_status']) {
                $mws_client->confirmPayment($payment_info['yandex_invoice_id'], $order_info['total']);
                $payment_info['yandex_confirmed_time'] = date('c');
                $payment_info['yandex_postponed_payment'] = false;
            } elseif ($status_to == $processor_data['processor_params']['canceled_order_status']) {
                $mws_client->cancelPayment($payment_info['yandex_invoice_id']);
                $payment_info['yandex_canceled_time'] = date('c');
                $payment_info['yandex_postponed_payment'] = false;
            }
            $payment_info['order_status'] = $status_to;
            fn_update_order_payment_info($order_info['order_id'], $payment_info);
            $order_info['payment_info'] = $payment_info;
        } catch (\Exception $e) {
            fn_set_notification('E', __('error'), __('addons.rus_payments.yandex_money_mws_operation_error'));
            return $status_to = $status_from;
        }
    }
}
Example #2
0
    if (!empty(Tygh::$app['session']['reference_id']) && Tygh::$app['session']['reference_id'] == $reference_id) {
        exit;
    } else {
        Tygh::$app['session']['reference_id'] = $reference_id;
    }
    $_order_id = db_get_field('SELECT order_id FROM ?:order_data WHERE type = ?s AND data = ?s', 'E', $transaction_id);
    if (!empty($_order_id)) {
        exit;
    }
    Tygh::$app['session']['order_id'] = empty(Tygh::$app['session']['order_id']) ? array() : Tygh::$app['session']['order_id'];
    $order_id =& Tygh::$app['session']['order_id'];
    $order_id = fn_prepare_to_place_order($xml, $cart, $auth);
    $pp_response = array('transaction_id' => $transaction_id);
    $data = array('order_id' => $order_id, 'type' => 'E', 'data' => $transaction_id);
    db_query("REPLACE INTO ?:order_data ?e", $data);
    fn_update_order_payment_info($order_id, $pp_response);
    fn_order_placement_routines('route', $order_id);
} elseif ($message_recognizer == 'OrderCancelledNotification') {
    // Customer cancel this order on the Amazon side. We need to cancel the order in the shop
    list($amazon_sess_id, $payment_id) = explode(';', base64_decode((string) $xml->ProcessedOrder->ProcessedOrderItems->ProcessedOrderItem->CartCustomData->ClientRequestId));
    $processor_data = fn_get_payment_method_data($payment_id);
    // If we use the signed cart, validate the request
    if (!fn_amazon_validate_request($processor_data, $_POST)) {
        die('Access denied');
    }
    $transaction_id = (string) $xml->ProcessedOrder->AmazonOrderID;
    $order_id = db_get_field('SELECT order_id FROM ?:order_data WHERE type = ?s AND data = ?s', 'E', $transaction_id);
    if (!empty($order_id)) {
        fn_change_order_status($order_id, 'I');
    }
} elseif ($message_recognizer == 'OrderReadyToShipNotification') {
Example #3
0
     $payment_id = db_get_field("SELECT payment_id FROM ?:orders WHERE order_id = ?i", $_REQUEST['order_id']);
     $processor_data = fn_get_payment_method_data($payment_id);
     $order_info = fn_get_order_info($_REQUEST['order_id']);
     $order_number_id = $processor_data['processor_params']['mode'] == 'test' ? '1' : $_REQUEST['order_number'];
     $pp_response = array();
     if (strtoupper(md5($processor_data['processor_params']['secret_word'] . $processor_data['processor_params']['account_number'] . $order_number_id . $order_info['total'])) == $_REQUEST['key'] && $_REQUEST['credit_card_processed'] == 'Y') {
         $pp_response['order_status'] = $processor_data['processor_params']['fraud_verification'] == 'Y' ? $processor_data['processor_params']['fraud_wait'] : 'P';
         $pp_response['reason_text'] = __('order_id') . '-' . $_REQUEST['order_number'];
     } else {
         $pp_response['order_status'] = $_REQUEST['credit_card_processed'] == 'K' ? 'O' : 'F';
         $pp_response['reason_text'] = $_REQUEST['credit_card_processed'] == 'Y' ? "MD5 Hash is invalid" : __('order_id') . '-' . $_REQUEST['order_number'];
     }
     $pp_response['transaction_id'] = !empty($_REQUEST['tcoid']) ? $_REQUEST['tcoid'] : '';
     if (fn_check_payment_script('2checkout.php', $_REQUEST['order_id'])) {
         if ($processor_data['processor_params']['fraud_verification'] == 'Y') {
             fn_update_order_payment_info($_REQUEST['order_id'], $pp_response);
             fn_change_order_status($_REQUEST['order_id'], $pp_response['order_status'], '', false);
         } else {
             fn_finish_payment($_REQUEST['order_id'], $pp_response, false);
         }
         fn_order_placement_routines('route', $_REQUEST['order_id']);
     }
     // Fraud checking notification
 } elseif (!empty($_REQUEST['message_type']) && $_REQUEST['message_type'] == 'FRAUD_STATUS_CHANGED') {
     if (!empty($_REQUEST['vendor_order_id'])) {
         list($order_id) = explode('_', $_REQUEST['vendor_order_id']);
         if (!empty($order_id)) {
             $payment_id = db_get_field("SELECT payment_id FROM ?:orders WHERE order_id = ?i", $order_id);
             $processor_data = fn_get_payment_method_data($payment_id);
             $pp_response = array();
             if ($_REQUEST['fraud_status'] == 'pass') {
Example #4
0
                $order->appendChild($dom->createElement('amount', $refund_data['amount'] * 100));
            }
            $dom->appendChild($order);
            $extra = array('headers' => array('Content-type: application/x-www-form-urlencoded;charset=utf-8', 'Expect:'));
            $result_xml = Http::post($url, array('xml' => $dom->saveXML()), $extra);
            $xml_data = @simplexml_load_string($result_xml);
            if (!empty($xml_data->response_message)) {
                if ($xml_data->response_code == 0) {
                    fn_set_notification('N', __('notify'), $xml_data->response_message);
                    $payment_info['avangard_refunded_transaction_id'] = strval($xml_data->id);
                    $payment_info['avangard_refunded_time'] = date('c');
                    $payment_info['avangard_refund_amount'] = $refund_data['amount'];
                    if (!empty($refund_data['cause'])) {
                        $payment_info['avangard_refund_cause'] = $refund_data['cause'];
                    }
                    fn_update_order_payment_info($order_info['order_id'], $payment_info);
                    fn_change_order_status($order_info['order_id'], $pdata['processor_params']['returned_order_status']);
                } else {
                    fn_set_notification('E', __('error'), $xml_data->response_message);
                }
            }
        }
        return array(CONTROLLER_STATUS_OK, "orders.details?order_id={$_REQUEST['order_id']}");
    }
}
if ($mode == 'details') {
    $order_info = Tygh::$app['view']->getTemplateVars('order_info');
    if ($order_info && !empty($order_info['payment_method']['processor_id'])) {
        $processor_id = $order_info['payment_method']['processor_id'];
        $processor_script = db_get_field("SELECT processor_script FROM ?:payment_processors WHERE processor_id = ?i", $processor_id);
        Tygh::$app['view']->assign('processor_script', $processor_script);
function fn_paypal_do_express_checkout($processor_data, $paypal_checkout_details, $order_info)
{
    $pp_order_id = $processor_data['processor_params']['order_prefix'] . ($order_info['repaid'] ? $order_info['order_id'] . '_' . $order_info['repaid'] : $order_info['order_id']);
    $request = array('PAYERID' => $paypal_checkout_details['PAYERID'], 'TOKEN' => $paypal_checkout_details['TOKEN'], 'PAYMENTREQUEST_0_PAYMENTACTION' => 'SALE', 'PAYMENTREQUEST_0_CURRENCYCODE' => $processor_data['processor_params']['currency'], 'PAYMENTREQUEST_0_AMT' => $order_info['total'], 'METHOD' => 'DoExpressCheckoutPayment', 'PAYMENTREQUEST_0_INVNUM' => $pp_order_id, 'BUTTONSOURCE' => 'ST_ShoppingCart_EC_US', 'PAYMENTREQUEST_0_CUSTOM' => $order_info['order_id'], 'PAYMENTREQUEST_0_NOTIFYURL' => fn_url("payment_notification.paypal_ipn", AREA, 'current'));
    fn_paypal_build_request($processor_data, $request, $post_url, $cert_file);
    $order_details = !empty($order_info) ? fn_paypal_build_details($order_info, $processor_data, false) : fn_paypal_build_details($cart, $processor_data);
    $request = array_merge($request, $order_details);
    if (!empty($order_info)) {
        //We need to minus taxes when it based on unit price because product subtotal already include this tax.
        if (Registry::get('settings.General.tax_calculation') == 'unit_price') {
            $sum_taxes = fn_paypal_sum_taxes($order_info);
            $request['PAYMENTREQUEST_0_ITEMAMT'] -= $sum_taxes['P'];
            $request['PAYMENTREQUEST_0_SHIPPINGAMT'] -= $sum_taxes['S'];
        }
    }
    $result = fn_paypal_request($request, $post_url, $cert_file);
    if (isset($result['L_ERRORCODE0']) && $result['L_ERRORCODE0'] == 10486 && (!isset($order_info['payment_info']['attempts_number']) || $order_info['payment_info']['attempts_number'] < 2)) {
        //According paypal documetation we should make two attempt and redirect customer back to paypal.
        $count = isset($order_info['payment_info']['attempts_number']) ? $order_info['payment_info']['attempts_number'] : 0;
        $count++;
        fn_update_order_payment_info($order_info['order_id'], array('attempts_number' => $count));
        fn_paypal_payment_form($processor_data, $paypal_checkout_details['TOKEN']);
    }
    return $result;
}
Example #6
0
/**
 * Updates order payment information
 *
 * @param int $order_id
 * @param array $pp_response Response from payment processor
 * @return boolean true
 */
function fn_update_order_payment_info($order_id, $pp_response)
{
    if (empty($order_id) || empty($pp_response) || !is_array($pp_response)) {
        return false;
    }
    $payment_info = db_get_field("SELECT data FROM ?:order_data WHERE order_id = ?i AND type = 'P'", $order_id);
    if (!empty($payment_info)) {
        $payment_info = unserialize(fn_decrypt_text($payment_info));
    } else {
        $payment_info = array();
    }
    foreach ($pp_response as $k => $v) {
        $payment_info[$k] = $v;
    }
    $data = array('data' => fn_encrypt_text(serialize($payment_info)), 'order_id' => $order_id, 'type' => 'P');
    db_query("REPLACE INTO ?:order_data ?e", $data);
    $child_orders_ids = db_get_fields("SELECT order_id FROM ?:orders WHERE parent_order_id = ?i", $order_id);
    if (!empty($child_orders_ids)) {
        foreach ($child_orders_ids as $child_id) {
            fn_update_order_payment_info($child_id, $pp_response);
        }
    }
    return true;
}
Example #7
0
            $pp_response['order_status'] = 'O';
            $pp_response['reason_text'] = __('kupivkredit_widget_open');
        } elseif ($decision == 'agr') {
            $pp_response['order_status'] = 'P';
            $pp_response['reason_text'] = __('kupivkredit_widget_processed');
        }
    }
    if (fn_check_payment_script('kupivkredit.php', $order_id)) {
        fn_finish_payment($order_id, $pp_response);
        fn_order_placement_routines('route', $order_id, false);
    }
} else {
    $url = $processor_data['processor_params']['test'] == 'Y' ? 'https://' . KVK_WIDGET_TEST_URL : 'https://' . KVK_WIDGET_URL;
    $kvk_order_id = ($order_info['repaid'] ? $order_info['order_id'] . '_' . $order_info['repaid'] : $order_info['order_id']) . '_' . fn_date_format(time(), '%H_%M_%S');
    //We should save this iformation for the actions such as 'confirm order', 'cancel order' in the admin area.
    fn_update_order_payment_info($order_id, array('kvk_order_id' => $kvk_order_id));
    $order = array();
    foreach ($order_info['products'] as $k => $item) {
        $price = fn_format_price(($item['subtotal'] - fn_external_discounts($item)) / $item['amount']);
        $order['items'][] = array('title' => $item['product'], 'category' => db_get_field("SELECT ?:category_descriptions.category FROM ?:category_descriptions LEFT JOIN ?:products_categories ON ?:category_descriptions.category_id = ?:products_categories.category_id WHERE ?:products_categories.product_id = ?i AND ?:products_categories.link_type = ?s AND ?:category_descriptions.lang_code = ?s", $item['product_id'], 'M', $order_info['lang_code']), 'qty' => $item['amount'], 'price' => fn_format_rate_value($price, 'F', 0, '.', '', ''));
    }
    if (!empty($order_info['shipping_cost'])) {
        $order['items'][] = array('title' => __('shipping_cost'), 'category' => '', 'qty' => 1, 'price' => fn_format_rate_value($order_info['shipping_cost'], 'F', 0, '.', '', ''));
    }
    if (!empty($order_info['taxes'])) {
        foreach ($order_info['taxes'] as $tax) {
            if ($tax['price_includes_tax'] == 'N') {
                $order['items'][] = array('title' => __('tax'), 'category' => '', 'qty' => 1, 'price' => fn_format_rate_value($tax['tax_subtotal'], 'F', 0, '.', '', ''));
            }
        }
    }
Example #8
0
        $payment_info = array('order_status' => 'P', 'transaction_id' => $litepaid_id, 'reason_text' => isset($response['data']['error_name']) ? $response['data']['error_name'] : '');
        fn_finish_payment($order_id, $payment_info, false);
        fn_order_placement_routines('route', $order_id);
    } else {
        fn_order_placement_routines('route', $order_id);
    }
} else {
    $amount = $order_info['total'];
    $currencies = Registry::get('currencies');
    if (!empty($currencies['EUR']['coefficient'])) {
        $amount /= $currencies['EUR']['coefficient'];
    }
    $data = array('key' => trim($processor_data['processor_params']['api_key']), 'value' => number_format($amount, 2, '.', ''), 'return_url' => fn_url("payment_notification.return?payment=litepaid&order_id={$order_id}", AREA, 'current'), 'description' => 'Order #' . $order_id, 'test' => !empty($processor_data['processor_params']['test_mode']) ? '1' : '0');
    $response = Http::get('https://www.litepaid.com/api?' . http_build_query($data));
    if (!$response || !($response = @json_decode($response, true)) || empty($response['result']) || $response['result'] != 'success' || empty($response['data']['invoice_token'])) {
        echo "<p>LitePaid API request failed. Choose another payment method to complete your order.</p>";
        if (!empty($response['data']['error_name'])) {
            echo "<p><b>Error:</b> " . htmlentities($response['data']['error_name'], ENT_QUOTES, 'UTF-8') . "</p>";
        }
        echo $redirect_timeout;
        exit;
    }
    $litepaid_id = $response['data']['invoice_token'];
    // store transaction id
    fn_update_order_payment_info($order_id, array('transaction_id' => $litepaid_id));
    // redirect
    $url = 'https://www.litepaid.com/invoice/id:' . $litepaid_id;
    @header('Location: ' . $url);
    echo "<script>\nwindow.location = " . json_encode($url) . ";\n</script>\n";
}
exit;
Example #9
0
function fn_pp_save_mode($order_info)
{
    $data['pp_mode'] = 'test';
    if (!empty($order_info['payment_method']) && !empty($order_info['payment_method']['processor_params']) && !empty($order_info['payment_method']['processor_params']['mode'])) {
        $data['pp_mode'] = $order_info['payment_method']['processor_params']['mode'];
    }
    fn_update_order_payment_info($order_info['order_id'], $data);
    return true;
}
Example #10
0
    if (!defined('BOOTSTRAP')) {
        die('Access denied');
    }
    $post_url = fn_payment_url('current', 'chronopay_form.php');
    $return_url = fn_url("payment_notification.notify?payment=chronopay_form&order_id={$order_id}", AREA, 'current');
    $country = db_get_field("SELECT code_A3 FROM ?:countries WHERE code = ?s", $order_info['b_country']);
    $product_name = "";
    // Products
    if (!empty($order_info['products'])) {
        foreach ($order_info['products'] as $v) {
            $product_name = $product_name . str_replace(', ', ' ', $v['product']) . ",<br>\n  ";
        }
    }
    // Certificates
    if (!empty($order_info['gift_certificates'])) {
        foreach ($order_info['gift_certificates'] as $v) {
            $product_name = $product_name . str_replace(', ', ' ', $v['gift_cert_code']) . ",<br>\n  ";
        }
    }
    // Shippings
    if (floatval($order_info['shipping_cost'])) {
        foreach ($order_info['shipping'] as $v) {
            $product_name .= str_replace(', ', ' ', $v['shipping']) . ",<br>\n  ";
        }
    }
    $sign = md5($processor_data['processor_params']['product_id'] . '-' . $order_info['total'] . '-' . $processor_data['processor_params']['sharedsec']);
    fn_update_order_payment_info($order_id, array('awaiting_callback' => true));
    $post_data = array('product_id' => $processor_data['processor_params']['product_id'], 'product_name' => $product_name, 'product_price' => $order_info['total'], 'order_id' => $order_id, 'cs1' => $order_id, 'language' => CART_LANGUAGE, 'f_name' => $order_info['b_firstname'], 's_name' => $order_info['b_lastname'], 'street' => $order_info['b_address'], 'city' => $order_info['b_city'], 'state' => $order_info['b_state'], 'zip' => $order_info['b_zipcode'], 'country' => $country, 'phone' => $order_info['phone'], 'email' => $order_info['email'], 'cb_url' => $post_url, 'cb_type' => 'P', 'success_url' => fn_link_attach($return_url, "sign={$sign}"), 'decline_url' => $return_url, 'sign' => $sign);
    fn_create_payment_form('https://payments.chronopay.com', $post_data, 'ChronoPay');
}
exit;
Example #11
0
 $order_id = $order_info['order_id'];
 $twpg_id = $order_info['payment_method']['processor_params']['twpg_id'];
 $twpg_pass = $order_info['payment_method']['processor_params']['twpg_pass'];
 $approve_url = fn_url("payment_notification.ok&payment=ubrir&order_id=" . $order_id);
 $cancel_url = fn_url("payment_notification.cancel&payment=ubrir&order_id=" . $order_id);
 $decline_url = fn_url("payment_notification.decline&payment=ubrir&order_id=" . $order_id);
 switch ($order_info['payment_info']['pc_type']) {
     case 'visa':
         $ubrir = new Ubrir(array('shopId' => $twpg_id, 'sert' => $twpg_pass, 'amount' => $amount, 'approve_url' => htmlentities($approve_url), 'cancel_url' => htmlentities($cancel_url), 'decline_url' => htmlentities($decline_url)));
         $response = $ubrir->prepare_to_pay();
         $url = $response->URL[0];
         $twpg_id = $response->OrderID[0];
         $sessionid = $response->SessionID[0];
         $twpg_params = array('orderid' => $twpg_id, 'sessionid' => $sessionid);
         $order_params = array('TWPG ID' => (string) $twpg_id, 'TWPG SESSION' => (string) $sessionid);
         fn_update_order_payment_info($order_id, $order_params);
         fn_create_payment_form($url, $twpg_params, 'ubrir', false, 'GET', true);
         break;
     case 'mc':
         $url = "https://91.208.121.201/estore_listener.php";
         $uni_ok = fn_url("payment_notification.uni_ok&payment=ubrir%26");
         $uni_cancel = fn_url("payment_notification.uni_cancel&payment=ubrir%26");
         $uni_id = $order_info['payment_method']['processor_params']['uni_id'];
         $uni_login = $order_info['payment_method']['processor_params']['uni_login'];
         $uni_pass = $order_info['payment_method']['processor_params']['uni_pass'];
         $sign = strtoupper(md5(md5($uni_id) . '&' . md5($uni_login) . '&' . md5($uni_pass) . '&' . md5($order_id) . '&' . md5((int) $amount)));
         $uni_params = array('SHOP_ID' => $uni_id, 'LOGIN' => $uni_login, 'ORDER_ID' => $order_id, 'PAY_SUM' => (int) $amount, 'VALUE_1' => $order_id, 'URL_OK' => $uni_ok, 'URL_NO' => $uni_cancel, 'SIGN' => $sign, 'LANG' => "RU");
         // die;
         fn_create_payment_form($url, $uni_params, 'ubrir', false, 'POST');
         break;
 }