Example #1
0
 public function request($path, $params = array())
 {
     $options = $this->options;
     $url = strtr($options['url'], array(':protocol' => $options['protocol'], ':host' => $options['is_test_mode'] ? $options['test_host'] : $options['live_host'], '::port' => $options['is_test_mode'] ? ':' . $options['test_port'] : '', ':path' => trim($path, '/')));
     fn_yandex_money_log_write(array('REQUEST', $url, $params, $options), 'ym_mws_requests.log');
     $response = Http::post($url, $params, array('ssl_cert' => $options['sslcert'], 'ssl_key' => $options['sslkey']));
     fn_yandex_money_log_write(array('RESPONSE', $response), 'ym_mws_requests.log');
     $response = $this->decodeResponse($response);
     if (empty($response) || !empty($response['error']) || !empty($response['status'])) {
         throw new ExceptionMWS('Error occured!', $response['error'], $response['techMessage']);
     }
     return $response;
 }
Example #2
0
        $payment_type = 'PC';
    } else {
        $payment_type = $payment_info['yandex_payment_type'];
    }
    $phone = '';
    if (!empty($order_info['phone'])) {
        $phone = $order_info['phone'];
    } elseif (!empty($order_info['b_phone'])) {
        $phone = $order_info['b_phone'];
    } elseif (!empty($order_info['s_phone'])) {
        $phone = $order_info['s_phone'];
    }
    $customer_phone = str_replace('+', '', $phone);
    $orderNumber = $order_info['order_id'] . '_' . substr(md5($order_info['order_id'] . TIME), 0, 3);
    $post_data = array('shopId' => $processor_data['processor_params']['shop_id'], 'Sum' => fn_yandex_money_get_sum($order_info, $processor_data), 'scid' => $processor_data['processor_params']['scid'], 'customerNumber' => $order_info['email'], 'orderNumber' => $orderNumber, 'shopSuccessURL' => fn_url("payment_notification.ok?payment=yandex_money&ordernumber={$orderNumber}", AREA, 'https'), 'shopFailURL' => fn_url("payment_notification.error?payment=yandex_money&ordernumber={$orderNumber}", AREA, 'https'), 'cps_email' => $order_info['email'], 'cps_phone' => $customer_phone, 'paymentAvisoURL' => fn_url("payment_notification.payment_aviso?payment=yandex_money", AREA, 'https'), 'checkURL' => fn_url("payment_notification.check_order?payment=yandex_money", AREA, 'https'), 'paymentType' => $payment_type, 'cms_name' => 'cscart');
    if (!empty($processor_data['processor_params']['logging']) && $processor_data['processor_params']['logging'] == 'Y') {
        fn_yandex_money_log_write($post_data, 'ym_post_data.log');
    }
    fn_create_payment_form($post_address, $post_data, 'Yandex.Money', false);
}
function fn_yandex_money_get_sum($order_info, $processor_data)
{
    $price = $order_info['total'];
    if (CART_PRIMARY_CURRENCY != $processor_data['processor_params']['currency']) {
        $currencies = Registry::get('currencies');
        $currency = $currencies[$processor_data['processor_params']['currency']];
        $price = fn_format_rate_value($price, 'F', $currency['decimals'], '.', '', $currency['coefficient']);
    }
    return sprintf('%.2f', $price);
}
exit;