Spamworldpro Mini Shell
Spamworldpro


Server : Apache
System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64
User : corals ( 1002)
PHP Version : 7.4.33
Disable Function : exec,passthru,shell_exec,system
Directory :  /home/corals/job-board.corals.io/Corals/modules/Payment/Fac/Message/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/corals/job-board.corals.io/Corals/modules/Payment/Fac/Message/Authorize3DSRequest.php
<?php

namespace Corals\Modules\Payment\Fac\Message;

/**
 * FACPG2 Authorize Request
 *
 * Required Parameters:
 * amount - Float ex. "10.00",
 * currency - Currency code ex. "USD",
 * card - Instantiation of Corals\Modules\Payment\Fac\CreditCard
 *
 * There are also 2 optional boolean parameters outside of the normal Omnipay parameters:
 * requireAVSCheck - will tell FAC that we want the to verify the address through AVS
 * createCard - will tell FAC to create a tokenized card in their system while it is authorizing the transaction
 */
class Authorize3DSRequest extends AbstractRequest
{
    /**
     * @var string;
     */
    protected $requestName = 'Authorize3DSRequest';

    /**
     * Transaction code (flag as a authorization)
     *
     * @var int;
     */
    protected $transactionCode = 0;

    /**
     * Returns the signature for the request.
     *
     * @return string base64 encoded sha1 hash of the merchantPassword, merchantId,
     *    acquirerId, transactionId, amount and currency code.
     */
    protected function generateSignature()
    {
        $signature = $this->getMerchantPassword();
        $signature .= $this->getMerchantId();
        $signature .= $this->getAcquirerId();
        $signature .= $this->getTransactionId();
        $signature .= $this->formatAmount();
        $signature .= $this->getCurrencyNumeric();

        return base64_encode(sha1($signature, true));
    }


    public function setMerchantResponseURL($value)
    {
        $this->setParameter('MerchantResponseURL', $value);
    }

    public function getMerchantResponseURL()
    {
        return $this->getParameter('MerchantResponseURL');
    }

    /**
     * Validate and construct the data for the request
     *
     * @return array
     */
    public function getData()
    {
        $this->validate('merchantId', 'merchantPassword', 'acquirerId', 'transactionId', 'amount', 'currency', 'card',
            'MerchantResponseURL');

        // Check for AVS and require billingAddress1 and billingPostcode
        if ($this->getRequireAvsCheck()) {
            $this->getCard()->validate('billingAddress1', 'billingPostcode');
        }

        // Tokenized cards require the CVV and nothing else, token replaces the card number
        if ($this->getCardReference()) {
            $this->validate('cardReference');
            $this->getCard()->validate('cvv', 'expiryMonth', 'expiryYear');

            $cardDetails = [
                'CardCVV2' => $this->getCard()->getCvv(),
                'CardExpiryDate' => $this->getCard()->getExpiryDate('my'),
                'CardNumber' => $this->getCardReference()
            ];
        } else {
            $this->getCard()->validate();

            $cardDetails = [
                'CardCVV2' => $this->getCard()->getCvv(),
                'CardExpiryDate' => $this->getCard()->getExpiryDate('my'),
                'CardNumber' => $this->getCard()->getNumber(),
                'IssueNumber' => $this->getCard()->getIssueNumber()
            ];
        }

        // Only pass the StartDate if year/month are set otherwise it returns 1299
        if ($this->getCard()->getStartYear() && $this->getCard()->getStartMonth()) {
            $cardDetails['StartDate'] = $this->getCard()->getStartDate('my');
        }

        $transactionDetails = [
            'AcquirerId' => $this->getAcquirerId(),
            'Amount' => $this->formatAmount(),
            'Currency' => $this->getCurrencyNumeric(),
            'CurrencyExponent' => $this->getCurrencyDecimalPlaces(),
            'IPAddress' => $this->getClientIp(),
            'MerchantId' => $this->getMerchantId(),
            'OrderNumber' => $this->getTransactionId(),
            'Signature' => $this->generateSignature(),
            'SignatureMethod' => 'SHA1',
            'TransactionCode' => $this->getTransactionCode()
        ];

        $billingDetails = [
            'BillToAddress' => $this->getCard()->getAddress1(),
            'BillToZipPostCode' => $this->getCard()->formatPostcode(),
            'BillToFirstName' => $this->getCard()->getFirstName(),
            'BillToLastName' => $this->getCard()->getLastName(),
            'BillToCity' => $this->getCard()->getCity(),
            'BillToCountry' => $this->getCard()->getNumericCountry(),
            'BillToEmail' => $this->getCard()->getEmail(),
            'BillToTelephone' => $this->getCard()->getPhone(),
            'BillToFax' => $this->getCard()->getFax()
        ];

        // FAC only accepts two digit state abbreviations from the USA
        if ($billingDetails['BillToCountry'] == 840) {
            $billingDetails['BillToState'] = $this->getCard()->validateState();
        }

        $data = [
            'TransactionDetails' => $transactionDetails,
            'CardDetails' => $cardDetails,
            'BillingDetails' => $billingDetails,
            'MerchantResponseURL' => $this->getMerchantResponseURL(),
        ];

        return $data;
    }

    /**
     * Returns endpoint for authorize requests
     *
     * @return string Endpoint URL
     */
    protected function getEndpoint()
    {
        return parent::getEndpoint() . 'Authorize3DS';
    }

    /**
     * Returns the transaction code based on the AVS check requirement
     *
     * @return int Transaction Code
     */
    protected function getTransactionCode()
    {
        $transactionCode = $this->transactionCode;
        if ($this->getRequireAvsCheck()) {
            $transactionCode += 1;
        }
        if ($this->getCreateCard()) {
            $transactionCode += 128;
        }

        return $transactionCode;
    }

    /**
     * Return the authorize response object
     *
     * @param \SimpleXMLElement $xml Response xml object
     *
     * @return AuthorizeResponse
     */
    protected function newResponse($xml)
    {
        return new Authorize3DSResponse($this, $xml);
    }

    /**
     * @param boolean $value Create a tokenized card on FAC during an authorize request
     *
     * @return \Corals\Modules\Payment\Common\Message\AbstractRequest
     */
    public function setCreateCard($value)
    {
        return $this->setParameter('createCard', $value);
    }

    /**
     * @return boolean Create a tokenized card on FAC during an authorize request
     */
    public function getCreateCard()
    {
        return $this->getParameter('createCard');
    }
}

Spamworldpro Mini