/**
  * Perform an authorization request
  * TODO: perhaps rather than passing in a parameter for the increment retry count, we could keep a state object for that
  *
  * @param Realex_API $realex_client realex api client
  * @param WC_Order $order the order
  * @param array $data optional post data to use in place of $_POST
  * @param boolean $increment_retry_count optional whether to increment the retry
  *        count to avoid order number clashes, defaults to true.  It's important
  *        that this be true for, and only for, the first request of any transaction
  *
  * @return SimpleXMLElement response, or false on error
  */
 private function auth_request($realex_client, $order, $data = null, $increment_retry_count = true)
 {
     $request = new stdClass();
     $request->merchantid = $this->get_merchant_id();
     $request->account = $this->get_account($this->get_post('realex_cardType', $data), $order);
     // blank account defaults to 'internet'
     // it's important that the order suffix for failed orders be generated *only* for non-3dsecure
     //  transactions here, because the 3ds-verifyenrolled will have already taken care of this for us
     $request->orderid = $this->get_order_number($order, $increment_retry_count);
     $request->amount = $order->payment_total * 100;
     // in pennies
     $request->amountCurrency = $order->get_order_currency();
     $request->card = new stdClass();
     $request->card->number = $this->get_post('realex_accountNumber', $data);
     $request->card->expdate = $this->get_post('realex_expirationMonth', $data) . substr($this->get_post('realex_expirationYear', $data), -2);
     $request->card->type = $this->get_post('realex_cardType', $data);
     $request->card->chname = $order->billing_first_name . " " . $order->billing_last_name;
     // TODO: hmmm, should I be collecting this from the checkout form?
     if ($this->cvv == "yes") {
         $request->card->cvn = new stdClass();
         $request->card->cvn->number = $this->get_post('realex_cvNumber', $data);
         $request->card->cvn->presind = 1;
     }
     if ($this->get_post('realex_cardType', $data) == 'SWITCH') {
         $request->card->issueno = $this->get_post('realex_issueNumber', $data);
     }
     $request->autosettleFlag = $this->settlement == "yes" ? 1 : 0;
     $request->tssinfo = new stdClass();
     if ($order->get_user_id()) {
         $request->tssinfo->custnum = $order->get_user_id();
     }
     // Realex accepts only the postcode/country for auth addresses
     $request->tssinfo->addressBilling = new stdClass();
     if ($this->avs_check()) {
         $request->tssinfo->addressBilling->code = preg_replace('/\\D/', '', $order->billing_postcode) . '|' . preg_replace('/\\D/', '', $order->billing_address_1);
     } else {
         $request->tssinfo->addressBilling->code = $order->billing_postcode;
     }
     $request->tssinfo->addressBilling->country = $order->billing_country;
     if ($order->shipping_postcode) {
         $request->tssinfo->addressShipping = new stdClass();
         $request->tssinfo->addressShipping->code = $order->shipping_postcode;
         $request->tssinfo->addressShipping->country = $order->shipping_country;
     }
     // allow additional request information to be added
     $request = apply_filters('wc_gateway_realex_auth_request', $request);
     // display the request object, if debug mode
     if ($this->is_debug_mode()) {
         $this->response_debug_message($request, "Request: auth");
     }
     return $realex_client->auth_request($request);
 }
 /**
  * Perform a 3ds-verifysig request
  *
  * @param Realex_API $realex_client realex api client
  * @param WC_Order $order the order
  * @param array $data the request data
  *
  * @return SimpleXMLElement response, or false on error
  */
 private function threeds_verifysig_request($realex_client, $order, $data)
 {
     $request = new stdClass();
     $request->merchantid = $this->wc_gateway_realex->get_merchant_id();
     $request->account = $this->wc_gateway_realex->get_account($data['realex_cardType'], $order);
     // blank account defaults to 'internet'
     $request->orderid = $this->wc_gateway_realex->get_order_number($order);
     $request->amount = $order->payment_total * 100;
     // in pennies
     $request->amountCurrency = $order->get_order_currency();
     $request->card = new stdClass();
     $request->card->number = $data['realex_accountNumber'];
     $request->card->expdate = $data['realex_expirationMonth'] . substr($data['realex_expirationYear'], -2);
     $request->card->type = $data['realex_cardType'];
     $request->card->chname = $order->billing_first_name . " " . $order->billing_last_name;
     // TODO: hmmm, should I be collecting this from the checkout form?
     $request->pares = $data['pares'];
     // display the request object, if debug mode
     if ($this->wc_gateway_realex->is_debug_mode()) {
         $this->wc_gateway_realex->response_debug_message($request, "Request: 3ds-verifysig");
     }
     return $realex_client->threeds_verifysig_request($request);
 }