It is used for VFT Inquiry Transaction
@param string $ccno
@param string $amount
@param string $instnumber
@param string $vftcode
@return bool
976565
function DoVFTInquiry($ccno,
                          $amount,
                          $instnumber,
                          $vftcode) {

        $posnetRequest = new PosnetRequest();

        $posnetRequest->ccno = $ccno;
        $posnetRequest->amount = $amount;
        $posnetRequest->instnumber = $instnumber;
        $posnetRequest->vftcode = $vftcode;

        return $this->DoTran($posnetRequest, "vftinquiry");
    }
146413
public function verifyEnrolled($amount, $currency, $orderId = null)
    {
        $response = (new AuthorizationBuilder(TransactionType::VERIFY_ENROLLED, $this))
            ->withAmount($amount)
            ->withCurrency($currency)
            ->withOrderId($orderId)
            ->execute();

        if (!empty($response->threeDSecure)) {
            $secureEcom = $response->threeDSecure;
            $secureEcom->setAmount($amount);
            $secureEcom->setCurrency($currency);
            $secureEcom->setOrderId($response->orderId);
            $this->threeDSecure = $secureEcom;

            if (in_array($this->threeDSecure->enrolled, array('N', 'U'))) {
                $this->threeDSecure->xid = null;
                if ($this->threeDSecure->enrolled == 'N') {
                    $this->threeDSecure->eci = $this->cardType == 'MC' ? 1 : 6;
                } elseif ($this->threeDSecure->enrolled == 'U') {
                    $this->threeDSecure->eci = $this->cardType == 'MC' ? 0 : 7;
                }
            }

            return $this->threeDSecure->enrolled == 'Y';
        }
        return false;
    }
293105
public function confirmTransaction($iSequenceNumber, $iConfirmedDate)
    {
        $oTransaction = TdbPkgShopPaymentTransaction::GetNewInstance();
        $loadData = array('shop_order_id' => $this->order->id, 'sequence_number' => $iSequenceNumber);
        if (true === $oTransaction->LoadFromFields($loadData)) {
            $oTransaction = $this->confirmTransactionObject($oTransaction, $iConfirmedDate);
        } else {
            $oTransaction = null;
        }

        return $oTransaction;
    }
159149
public function isSuccessful()
    {
        // As per appendix F, 000 means the message was processed correctly
        if ((string) $this->data->Status->statusCode !== '000'
            || ($this->hasTransaction()
                && (string) $this->data->Payment->TxnList->Txn->approved !== 'Yes')) {
            return false;
        }

        return true;
    }
1131531
public function updateOrderNo($invNo, $orderid)
    {
        $this->_checkInvNo($invNo);
        $this->_checkEstoreOrderNo($orderid);

        $digestSecret = self::digest(
            $this->colon($invNo, $orderid, $this->_secret)
        );

        $paramList = array(
            $this->_eid,
            $digestSecret,
            $invNo,
            $orderid
        );

        self::printDebug('update_orderno array', $paramList);

        $result = $this->xmlrpc_call('update_orderno', $paramList);

        return $result;
    }
545795
function _doRefund($oID, $amount = 0) {
    global $db, $messageStack;
    $_POST['refamt'] = preg_replace('/[^0-9.%]/', '', $_POST['refamt']);
    $new_order_status = (int)MODULE_PAYMENT_LINKPOINT_API_REFUNDED_ORDER_STATUS_ID;
    if ($new_order_status == 0) $new_order_status = 1;
    $proceedToRefund = true;
    $refundNote = strip_tags(zen_db_input($_POST['refnote']));
    if (isset($_POST['refconfirm']) && $_POST['refconfirm'] != 'on') {
      $messageStack->add_session(MODULE_PAYMENT_LINKPOINT_API_TEXT_REFUND_CONFIRM_ERROR, 'error');
      $proceedToRefund = false;
    }
    if (isset($_POST['buttonrefund']) && $_POST['buttonrefund'] == MODULE_PAYMENT_LINKPOINT_API_ENTRY_REFUND_BUTTON_TEXT) {
      $refundAmt = (float)$_POST['refamt'];
      $new_order_status = (int)MODULE_PAYMENT_LINKPOINT_API_REFUNDED_ORDER_STATUS_ID;
      if ($refundAmt == 0) {
        $messageStack->add_session(MODULE_PAYMENT_LINKPOINT_API_TEXT_INVALID_REFUND_AMOUNT, 'error');
        $proceedToRefund = false;
      }
    }
    if (isset($_POST['cc_number']) && (int)trim($_POST['cc_number']) == 0) {
      $messageStack->add_session(MODULE_PAYMENT_LINKPOINT_API_TEXT_CC_NUM_REQUIRED_ERROR, 'error');
    }
    if (isset($_POST['trans_id']) && (int)trim($_POST['trans_id']) == 0) {
      $messageStack->add_session(MODULE_PAYMENT_LINKPOINT_API_TEXT_TRANS_ID_REQUIRED_ERROR, 'error');
      $proceedToRefund = false;
    }

    $sql = "select lp_trans_num, transaction_time from " . TABLE_LINKPOINT_API . " where order_id = " . (int)$oID . " and transaction_result = 'APPROVED' order by transaction_time DESC";
    $query = $db->Execute($sql);
    if ($query->RecordCount() < 1) {
      $messageStack->add_session(MODULE_PAYMENT_LINKPOINT_API_TEXT_NO_MATCHING_ORDER_FOUND, 'error');
      $proceedToRefund = false;
    }
    /**
     * Submit refund request to gateway
     */
    if ($proceedToRefund) {
      unset($myorder);
      $myorder["ordertype"] = 'CREDIT';
      $myorder["oid"] = $query->fields['lp_trans_num'];
      if ($_POST['trans_id'] != '') $myorder["tdate"] = $_POST['trans_id'];
      $myorder["chargetotal"] = number_format($refundAmt, 2, '.', '');
      $myorder["comments"]  = htmlentities($refundNote, ENT_QUOTES, 'UTF-8');

      $result = $this->_sendRequest($myorder);
      $response_alert = $result['r_approved'] . ' ' . $result['r_error'] . ($this->commError == '' ? '' : ' Communications Error - Please notify webmaster.');
      $this->reportable_submit_data['Note'] = $refundNote;
      $failure = ($result["r_approved"] != "APPROVED");
      if ($failure) {
        $messageStack->add_session($response_alert, 'error');
      } else {
        // Success, so save the results
        $this->_updateOrderStatus($oID, $new_order_status, 'REFUND INITIATED. Order ID:' . $result['r_ordernum'] . ' - ' . 'Trans ID: ' . $result['r_tdate'] . "\n" . 'Amount: ' . $myorder["chargetotal"] . "\n" . $refundNote);
        $messageStack->add_session(sprintf(MODULE_PAYMENT_LINKPOINT_API_TEXT_REFUND_INITIATED, $result['r_tdate'], $result['r_ordernum']), 'success');
        return true;
      }
    }
    return false;
  }
485490
public function charge($amount, array $options = []): Successful
    {
        $response = BraintreeTransaction::sale(array_merge([
            'amount' => number_format($amount * (1 + ($this->taxPercentage() / 100)), 2, '.', ''),
            'paymentMethodToken' => $this->paymentMethod()->token,
            'options' => [
                'submitForSettlement' => true,
            ],
            'recurring' => true,
        ], $options));

        if (! $response->success) {
            throw new Exception('Braintree was unable to perform a charge: '.$response->message);
        }

        return $response;
    }
865047
public function createBill($login, $amount, $receiver, $message)
    {
        $currencyEntry = new Gamecurrency();
        $currencyEntry->setAmount($amount);
        $currencyEntry->setSenderlogin($login);
        $currencyEntry->setReceiverlogin($receiver);
        $currencyEntry->setMessage($message);
        $currencyEntry->setDatetime(new \DateTime());
        try {
            $currencyEntry->save();

            return $currencyEntry;

        } catch (\Exception $e) {
            $this->logger->error("Error while creating bill", ["exception" => $e]);
            $this->console->write('$f00 Fail.', true);

            return false;
        }
    }
1307920
public function money($amount, $decimals = 2, $sourceCurrency = null)
    {
        return str_replace(
            ['{number}', '{currency}'],
            [$this->number($decimals), $this->currency()],
            $this->get('money')['format']
        );
    }
1305286
public boolean confirmPayment(String orderNumber, String timestamp, String paid, String method, String authCode) {
		String base = new StringBuilder()
  	  .append(orderNumber)
  	  .append('|')
  	  .append(timestamp)
  	  .append('|')
  	  .append(paid)
  	  .append('|')
  	  .append(method)
  	  .append('|')
  	  .append(merchantSecret)
  	  .toString();
		
		return 
			StringUtils.equals(
				StringUtils.upperCase(DigestUtils.md5Hex(base)),
				authCode
			);
	}
89640
public function status($orderCode, $toNumber)
	{
		$params = compact('orderCode', 'toNumber');
		$requestParams = $this->initRequestParams('status', $params);
		$this->request('status', $requestParams);

		return empty($this->error);
	}
97790
public function checkVat($countryCode, $vatNumber)
    {
        try {
            return $this->getSoapClient()->checkVat(
                array(
                    'countryCode' => $countryCode,
                    'vatNumber' => $vatNumber
                )
            );
        } catch (SoapFault $e) {
            throw new ViesException('Error communicating with VIES service', 0, $e);
        }
    }
101602
private function createOperation($accIdDebit, $accIdCredit, $amount, $note)
    {
        /* prepare transaction */
        $tran = new ETrans();
        $tran->setDebitAccId($accIdDebit);
        $tran->setCreditAccId($accIdCredit);
        $tran->setValue($amount);
        $tran->setNote($note);
        /* perform operation */
        $req = new \Praxigento\Accounting\Api\Service\Operation\Create\Request();
        $req->setOperationTypeCode(Cfg::CODE_TYPE_OPER_WALLET_REFUND);
        $req->setTransactions([$tran]);
        $req->setOperationNote($note);
        $resp = $this->servOper->exec($req);
        $result = $resp->getOperationId();
        return $result;
    }
107406
public function checkVat(string $countryCode, string $vatNumber) : bool 
    {
        try {
            $response = $this->getClient()->checkVat(
                array(
                    'countryCode' => $countryCode,
                    'vatNumber' => $vatNumber
                )
            );
        } catch( SoapFault $e ) {
            throw new ViesException( $e->getMessage(), $e->getCode() );
        }

        return (bool) $response->valid;
    }
940380
function pre_confirmation_check() {
    global $messageStack, $order;
    include(DIR_WS_CLASSES . 'cc_validation.php');
    $cc_validation = new cc_validation();
    $result = $cc_validation->validate($_POST['paypalwpp_cc_number'],
                                       $_POST['paypalwpp_cc_expires_month'], $_POST['paypalwpp_cc_expires_year'],
                                       (isset($_POST['paypalwpp_cc_issue_month']) ? $_POST['paypalwpp_cc_issue_month'] : ''), (isset($_POST['paypalwpp_cc_issue_year']) ? $_POST['paypalwpp_cc_issue_year'] : ''));
    $error = '';
    switch ($result) {
      case 1:
        break;
      case -1:
      $error = MODULE_PAYMENT_PAYPALDP_TEXT_BAD_CARD;//sprintf(TEXT_CCVAL_ERROR_UNKNOWN_CARD, substr($cc_validation->cc_number, 0, 4));
      if ($_POST['paypalwpp_cc_number'] == '') $error = str_replace('\n', '', MODULE_PAYMENT_PAYPALDP_TEXT_JS_CC_NUMBER); // yes, those are supposed to be single-quotes.
      break;
      case -2:
      case -3:
      case -4:
      $error = TEXT_CCVAL_ERROR_INVALID_DATE;
      break;
      case false:
      $error = TEXT_CCVAL_ERROR_INVALID_NUMBER;
      break;
    }

    $_POST['paypalwpp_cc_checkcode'] = preg_replace('/[^0-9]/i', '', $_POST['paypalwpp_cc_checkcode']);
    if (isset($_POST['paypalwpp_cc_issuenumber'])) $_POST['paypalwpp_cc_issuenumber'] = preg_replace('/[^0-9]/i', '', $_POST['paypalwpp_cc_issuenumber']);

    if (($result === false) || ($result < 1) ) {
      $messageStack->add_session('checkout_payment', $error . '<!-- ['.$this->code.'] -->' . '<!-- result: ' . $result . ' -->', 'error');
      zen_redirect(zen_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL', true, false));
    }

    $this->cc_card_type = $cc_validation->cc_type;
    $this->cc_card_number = $cc_validation->cc_number;
    $this->cc_expiry_month = $cc_validation->cc_expiry_month;
    $this->cc_expiry_year = $cc_validation->cc_expiry_year;
    $this->cc_checkcode = $_POST['paypalwpp_cc_checkcode'];


    // In the case of UK cards, hook 3D-Secure if appropriate
    // 3D-Secure
    /**
     * Checks if the card is enrolled in an authentication program and
     * launches the start-authentication process if it is enrolled.
     * The order may continue to authorization if a card is not enrolled
     * or an error occurs.
     *
     * Under the Verified by Visa, MasterCard SecureCode and JCB J/Secure
     * program guidelines, not all credit cards are eligible for
     * participation in the payer authentication programs. Certain types of
     * credit and debit cards, such as commercial and prepaid cards,
     * are simply not able to participate in the programs. For this reason,
     * this configuration is available to provide the option to allow
     * transactions using credit and debit cards that are unable to be
     * authenticated to complete and proceed with authorization.
     */
    if (MODULE_PAYMENT_PAYPALDP_MERCHANT_COUNTRY == 'UK' && (!isset($_POST['MD']))) {
      if (isset($_SESSION['3Dsecure_auth_status']) && isset($_SESSION['3Dsecure_auth_xid']) && isset($_SESSION['3Dsecure_auth_cavv']) && isset($_SESSION['3Dsecure_auth_eci'])) {
        // at this point we have 3d-secure auth data
      } else {
        // at this stage we need to prepare for checking whether 3d-secure is needed
        $this->clear_3DSecure_session_vars(TRUE);
        $_SESSION['3Dsecure_requires_lookup'] = $this->requiresLookup($_POST['paypalwpp_cc_number']);
        $_SESSION['3Dsecure_card_type'] = $this->determineCardType($_POST['paypalwpp_cc_number']);
      }
      if (isset($_SESSION['3Dsecure_requires_lookup']) && $_SESSION['3Dsecure_requires_lookup'] == TRUE) {
        $_SESSION['3Dsecure_merchantData'] = serialize(array('im'=>$_POST['paypalwpp_cc_issue_month'], 'iy'=>$_POST['paypalwpp_cc_issue_year'], 'in'=>$_POST['paypalwpp_cc_issuenumber'], 'fn'=>$_POST['paypalwpp_cc_firstname'], 'ln'=>$_POST['paypalwpp_cc_lastname']));
        global $order_total_modules;
        $calculatedOrderTotal = $order_total_modules->pre_confirmation_check(TRUE);
        $lookup_data_array = array('currency' => $order->info['currency'],
                                   'txn_amount' => $calculatedOrderTotal,
                                   'order_desc' => 'Zen Cart(R) ' . MODULE_PAYMENT_PAYPALDP_TEXT_TRANSACTION_FOR . ' ' . $_POST['paypalwpp_cc_firstname'] . ' ' . $_POST['paypalwpp_cc_lastname'],
                                   'cc3d_card_number' => $_POST['paypalwpp_cc_number'],
                                   'cc3d_checkcode' => $_POST['paypalwpp_cc_checkcode'],
                                   'cc3d_exp_month' => $_POST['paypalwpp_cc_expires_month'],
                                   'cc3d_exp_year' => $_POST['paypalwpp_cc_expires_year']  );
        ////////////////////////////////////////////////////////////////////////////
        // Process the enrollment lookup
        ////////////////////////////////////////////////////////////////////////////
        $lookup_response = $this->get3DSecureLookupResponse($lookup_data_array);

        $shouldContinue = $lookup_response['continue_flag'];
        $errorNo = $lookup_response['error_no'];
        $errorDesc = $lookup_response['error_desc'];
        $_SESSION['3Dsecure_enrolled'] = $lookup_response['enrolled'];
        $_SESSION['3Dsecure_transactionId'] = $lookup_response['transaction_id'];
        $requestXML = $lookup_response['requestXML'];
        $rawXML = $lookup_response['rawXML'];
        if (isset($lookup_response['EciFlag'])) $_SESSION['3Dsecure_auth_eci'] = $lookup_response['EciFlag'];

        ////////////////////////////////////////////////////////////////////////////
        // Assert that there was no error code returned and the Cardholder is
        // enrolled in the authentication program prior to starting the
        // Authentication process.
        //
        // If the card is not enrolled or an error was returned, check the business
        // rules to determine if the order should continue.
        ////////////////////////////////////////////////////////////////////////////

        if (strcasecmp('0', $errorNo) == 0 && strcasecmp('Y', $_SESSION['3Dsecure_enrolled']) == 0) {

          ////////////////////////////////////////////////////////////////////////
          // Card is enrolled, continue to payer authentication
          ////////////////////////////////////////////////////////////////////////
          $_SESSION['3Dsecure_acsURL'] = $lookup_response['acs_url'];
          $_SESSION['3Dsecure_payload'] = $lookup_response['payload'];
          $this->form_action_url = zen_href_link(FILENAME_PAYER_AUTH_FRAME, '', 'SSL', true, false);

        } else {

          if ($shouldContinue != 'Y') {
            ////////////////////////////////////////////////////////////////////
            // Business rules are set to prompt for another form of payment
            ////////////////////////////////////////////////////////////////////
            $error= $this->get_authentication_error();
            if (in_array($errorNo, array('8000', '8010', '8020', '8030'))) $error = CENTINEL_PROCESSING_ERROR;
            $reason = $errorNo . ' - ' . $errorDesc;
            $messageStack->add_session('checkout_payment', $error . '<!-- ['.$this->code.'] -->' . '<!-- result: ' . $reason . ' -->', 'error');
            $errorText = $error . "\n\n" . $reason . "\n(" . $this->code . ")\n\nProblem occurred while customer " . $_SESSION['customer_id'] . ' ' . $_SESSION['customer_first_name'] . ' ' . $_SESSION['customer_last_name'] . ' was attempting checkout with 3D-Secure authentication.';
            zen_mail(STORE_NAME, STORE_OWNER_EMAIL_ADDRESS, MODULE_PAYMENT_PAYPALDP_TEXT_EMAIL_ERROR_SUBJECT . ' ' . $reason, $errorText, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS, array('EMAIL_MESSAGE_HTML'=>nl2br($errorText)), 'paymentalert');
            zen_redirect(zen_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL', true, false));

          } else {
            ////////////////////////////////////////////////////////////////////
            // Business rules are set to continue to authorization
            ////////////////////////////////////////////////////////////////////
            if (!isset($_SESSION['3Dsecure_auth_eci']) || $_SESSION['3Dsecure_auth_eci'] == '') {
              // Not enrolled or error, determine the ECI value for the card number, and make it available to the payment module.
              if ($_SESSION['3Dsecure_enrolled'] == 'N') {
                switch($_SESSION['3Dsecure_card_type']) {
                  case 'VISA':
                    $_SESSION['3Dsecure_auth_eci'] = "06";
                    break;
                  case 'MASTERCARD':
                    $_SESSION['3Dsecure_auth_eci'] = "01";
                    break;
                  case 'JCB':
                    $_SESSION['3Dsecure_auth_eci'] = "06";
                    break;
                }
              } else if ('U' == $_SESSION['3Dsecure_enrolled'] || '0' != $errorNo) {
                switch($_SESSION['3Dsecure_card_type']) {
                  case 'VISA':
                    $_SESSION['3Dsecure_auth_eci'] = "07";
                    break;
                  case 'MASTERCARD':
                    $_SESSION['3Dsecure_auth_eci'] = "01";
                    break;
                  case 'JCB':
                    $_SESSION['3Dsecure_auth_eci'] = "07";
                    break;
                }
              }
            }
          }
        }
      }
    }
    // end uk/3d-secure check
  }
972985
function _doRefund($oID, $amount = 0) {
    global $db, $messageStack;
    $new_order_status = (int)MODULE_PAYMENT_AUTHORIZENET_ECHECK_REFUNDED_ORDER_STATUS_ID;
    if ($new_order_status == 0) $new_order_status = 1;
    $proceedToRefund = true;
    $refundNote = strip_tags(zen_db_input($_POST['refnote']));
    if (isset($_POST['refconfirm']) && $_POST['refconfirm'] != 'on') {
      $messageStack->add_session(MODULE_PAYMENT_AUTHORIZENET_ECHECK_TEXT_REFUND_CONFIRM_ERROR, 'error');
      $proceedToRefund = false;
    }
    if (isset($_POST['buttonrefund']) && $_POST['buttonrefund'] == MODULE_PAYMENT_AUTHORIZENET_ECHECK_ENTRY_REFUND_BUTTON_TEXT) {
      $refundAmt = (float)$_POST['refamt'];
      $new_order_status = (int)MODULE_PAYMENT_AUTHORIZENET_ECHECK_REFUNDED_ORDER_STATUS_ID;
      if ($refundAmt == 0) {
        $messageStack->add_session(MODULE_PAYMENT_AUTHORIZENET_ECHECK_TEXT_INVALID_REFUND_AMOUNT, 'error');
        $proceedToRefund = false;
      }
    }
    if (isset($_POST['cc_number']) && trim($_POST['cc_number']) == '') {
      $messageStack->add_session(MODULE_PAYMENT_AUTHORIZENET_ECHECK_TEXT_CC_NUM_REQUIRED_ERROR, 'error');
    }
    if (isset($_POST['trans_id']) && trim($_POST['trans_id']) == '') {
      $messageStack->add_session(MODULE_PAYMENT_AUTHORIZENET_ECHECK_TEXT_TRANS_ID_REQUIRED_ERROR, 'error');
      $proceedToRefund = false;
    }

    /**
     * Submit refund request to gateway
     */
    if ($proceedToRefund) {
      $submit_data = array('x_type' => 'CREDIT',
                           'x_card_num' => trim($_POST['cc_number']),
                           'x_amount' => number_format($refundAmt, 2),
                           'x_trans_id' => trim($_POST['trans_id'])
                           );
      unset($response);
      $response = $this->_sendRequest($submit_data);
      $response_code = $response[0];
      $response_text = $response[3];
      $response_alert = $response_text . ($this->commError == '' ? '' : ' Communications Error - Please notify webmaster.');
      $this->reportable_submit_data['Note'] = $refundNote;
      $this->_debugActions($response);

      if ($response_code != '1') {
        $messageStack->add_session($response_alert, 'error');
      } else {
        // Success, so save the results
        $sql_data_array = array('orders_id' => $oID,
                                'orders_status_id' => (int)$new_order_status,
                                'date_added' => 'now()',
                                'comments' => 'REFUND INITIATED. Trans ID:' . $response[6] . ' ' . $response[4]. "\n" . ' Gross Refund Amt: ' . $response[9] . "\n" . $refundNote,
                                'customer_notified' => 0
                             );
        zen_db_perform(TABLE_ORDERS_STATUS_HISTORY, $sql_data_array);
        $db->Execute("update " . TABLE_ORDERS  . "
                      set orders_status = '" . (int)$new_order_status . "'
                      where orders_id = '" . (int)$oID . "'");
        $messageStack->add_session(sprintf(MODULE_PAYMENT_AUTHORIZENET_ECHECK_TEXT_REFUND_INITIATED, $response[9], $response[6]), 'success');
        return true;
      }
    }
    return false;
  }
377701
public function finalAmount(&$amount, array &$components, array $price_rule, array $data)
    {
        $value = $this->convertValue($price_rule, $data['currency']);
        $components[$price_rule['price_rule_id']] = array('rule' => $price_rule, 'price' => $value);
        return $amount = $value;
    }