public function customFields(waOrder $order)
 {
     $company_field = $this->cust_company ? $this->cust_company : 'company';
     $inn_field = $this->cust_inn ? $this->cust_inn : 'inn';
     $result = array('inn' => array('title' => 'ИНН', 'control_type' => waHtmlControl::INPUT), 'company' => array('title' => _ws('Company'), 'control_type' => waHtmlControl::INPUT));
     if ($company = $order->getContactField($company_field)) {
         $result['company']['value'] = $company;
     }
     if ($inn = $order->getContactField($inn_field)) {
         $result['inn']['value'] = $inn;
     }
     return $result;
 }
 protected function getRequestParams(waOrder $order, $str = false)
 {
     $params = array();
     $params['hostedSecureID'] = $this->hosted_secure_id;
     $params['action'] = 'buildForm';
     $params['sessionId'] = $this->packSessionId(array($this->app_id, $this->merchant_id, $order->id, $order->contact_id, $order->currency));
     $params['payment_type'] = 'Credit_Card';
     $params['formType'] = 1;
     $params['allowed_types'] = implode('|', $this->allowed_credit_card_types);
     $params['trans_type'] = 'auth_capture';
     $params['collectAddress'] = 2;
     $params['required'] = 'all';
     $params['orderId'] = $order->id;
     $params['currency_code'] = $order->currency;
     $params['address'] = $order->billing_address['address'];
     $params['city'] = $order->billing_address['city'];
     $params['state'] = $order->billing_address['region'];
     if ($order->billing_address['zip']) {
         $params['zip'] = $order->billing_address['zip'];
     }
     $name = $order->billing_address['name'];
     if (!$name) {
         $name = $order->getContactField('name');
     }
     if ($name) {
         $params['name'] = $name;
     }
     if ($str) {
         $result = array();
         foreach ($params as $k => $v) {
             $v = urlencode($v);
             $result[] = "{$k}={$v}";
         }
         return implode('&', $result);
     }
     return $params;
 }
 /**
  * @param array $payment_form_data
  * @param waOrder $order_data
  * @return array|null
  * @throws waPaymentException
  */
 private function soapAuth($payment_form_data, $order_data)
 {
     $result = '';
     try {
         $soap_client = $this->getSoapClient();
         $parameters = new createBill();
         if (!empty($payment_form_data['customer_phone'])) {
             $mobile_phone = $payment_form_data['customer_phone'];
         } else {
             $mobile_phone = $order_data->getContactField($this->customer_phone, 'default');
         }
         $mobile_phone = preg_replace('/^\\s*\\+\\s*7/', '', $mobile_phone);
         $mobile_phone = preg_replace('/[\\D]+/', '', $mobile_phone);
         $parameters->login = $this->api_login ? $this->api_login : $this->login;
         $parameters->password = $this->password;
         $parameters->user = $mobile_phone;
         $parameters->amount = number_format($order_data->total, 3, '.', '');
         $parameters->comment = $order_data->description;
         $parameters->txn = $this->getInvoiceId($order_data->id);
         $parameters->lifetime = date('d.m.Y H:i:s', time() + 3600 * max(1, (int) $this->lifetime));
         $parameters->alarm = $this->alarm;
         $parameters->create = 1;
         $response = $soap_client->createBill($parameters);
         if ($response->createBillResult) {
             $result = $this->getResponseCodeDescription($response->createBillResult);
             self::log($this->id, array(__METHOD__ . " #{$order_data->id}\tphone:{$mobile_phone}\t{$result}"));
         }
     } catch (SoapFault $sf) {
         $result = $sf->getMessage();
         self::log($this->id, $sf->getMessage());
         if (!empty($soap_client)) {
             self::log($this->id, $soap_client->getDebug());
         }
     }
     return $result;
 }