Jump to content

[SOLVED] How can this done???


depojones

Recommended Posts

They should also provide documentation on how to implement it. Perhaps contact them regarding this.

 

Trust. We have contacted them and the only they provide us is a bunch of XML code without an actual process of communicating and ending data to their server. Please have a look at what they provided us.

 

String msisdn = "27820001234";

String pin = "1234";

String amount = "100.00";

String cardPresent = "0";

String cardNumber = "4242424242424242";

String expiry = "1109";

String cvc = "123";

String reconReference = "recon ref";

String budgetPeriod = "00";

String reference = "test";

String clientTel = "27820001234";

String isTxManuallyAuthed = "0";

String autoSettle = "1";

String isThreeDSecure = "0";

String algorithm = "1";

String checksum = "12821821AAFEDD328328238923D2389329BBC";



String xml = "<OnlineLinQ>" +

    "<TxRequest>" +

        "<Msisdn>" + msisdn + "</Msisdn>" +

        "<PIN>" + pin + "</PIN>" +

        "<Amount>" + amount + "</Amount>" +

        "<CardEntry>" +

            "<CardPresent>" + cardPresent + "</CardPresent>" +

            "<Track2></Track2>" +

        "</CardEntry>" +

        "<CardNumber>" + cardNumber + "</CardNumber>" +

        "<ExpiryDate>" + expiry + "</ExpiryDate>" +

        "<CVC>" + cvc + "</CVC>" +

        "<ReconReference>" + reconReference + "</ReconReference>" +

        "<BudgetPeriod>" + budgetPeriod + "</BudgetPeriod>" +

        "<Reference>" + reference + "</Reference>" +

        "<ClientTel>" + clientTel + "</ClientTel>" +

        "<ManualAuth>" +

            "<IsTxManuallyAuthed>" + isTxManuallyAuthed + "</IsTxManuallyAuthed>" +

            "<ManualAuthCode></ManualAuthCode>" +

        "</ManualAuth>" +

        "<AutomaticSettlement>" + autoSettle + "</AutomaticSettlement>" +

        "<ThreeDSecure>" +

            "<IsThreeDSecured>" + isThreeDSecure + "</IsThreeDSecured>" +

            "<CAVV></CAVV>" +

            "<ECI></ECI>" +

            "<XID></XID>" +

        "</ThreeDSecure>" +

        "<Security>" +

            "<Algorithm>" + algorithm + "</Algorithm>" +

            "<Checksum>" + checksum + "</Checksum>" +

        "</Security>" +

    "</TxRequest>" +

"</OnlineLinQ>";

Link to comment
Share on other sites

I thought this would be as easy as creating a simple HTML form and encoding the form action to the CC processing server. But by the look of things, its getting way beyond my PHP/XML knowledge.

 

@448191

 

ay i provide you with the API the company provided us with? Maybe you could detect what's going on there.

Link to comment
Share on other sites

I thought this would be as easy as creating a simple HTML form and encoding the form action to the CC processing server. But by the look of things, its getting way beyond my PHP/XML knowledge.

 

@448191

 

ay i provide you with the API the company provided us with? Maybe you could detect what's going on there.

 

I seriously doubt I could do this without full access to your code and a full API description. Even then it might take a full day to get it working. I'm sorry, but it looks like you're screwed.

Link to comment
Share on other sites

I thought this would be as easy as creating a simple HTML form and encoding the form action to the CC processing server. But by the look of things, its getting way beyond my PHP/XML knowledge.

 

@448191

 

ay i provide you with the API the company provided us with? Maybe you could detect what's going on there.

 

I seriously doubt I could do this without full access to your code and a full API description. Even then it might take a full day to get it working. I'm sorry, but it looks like you're screwed.

 

I do not have any working code at the moment expect the HTML front end to capture the credit card information. Aside from this, i have a well detailed API configuration from our CC processing company. (Take a look at the file below.)

 

[attachment deleted by admin]

Link to comment
Share on other sites

Something like this should work.

 

<?php
$merchantAccountPhone = '27820001234';
$merchantAccountPin = '1234';
$cardNumber = '4242424242424242';
$exp = '1110';
$lastThreeNumbersOnBack = '123';
$amount = '100.00';
$merchantOrderNumber = 'recon ref';
$merchantInvoiceNumber = 'test';
$phone = '132456789';

$xmlRequest = <<<XML
<enMobileAPI>
    <AuthorisationRequest msisdn="$merchantAccountPhone" pin="$merchantAccountPin">
        <Amount>$amount</Amount>
        <CardPresent>false</CardPresent>
        <BudgetPeriod>00</BudgetPeriod>
        <CardNumber>$cardNumber</CardNumber>
        <ExpiryDate>$exp</ExpiryDate>
        <Cv2>$lastThreeNumbersOnBack</Cv2>
        <ReconReference>$merchantOrderNumber</ReconReference>
        <Reference>$merchantInvoiceNumber</Reference>
        <ClientTel>$phone</ClientTel>
        <AutomaticSettlement>true</AutomaticSettlement>
    </AuthorisationRequest>
</enMobileAPI>
XML;

$fp = fsockopen("ssl://www.vwire.co.za", 443, $errno, $errstr, 30);

if(!$fp)
{
    trigger_error("$errstr ($errno)", E_USER_ERROR);
}
else
{
    $out = "GET /vapp/XML-Landing2.jsp?xmlData=" . rawurlencode($xmlRequest) . " HTTP/1.1 \r\n";
    $out .= "Host: www.vwire.co.za\r\n";
    $out .= "Connection: Close\r\n\r\n";
    
    fwrite($fp, $out);
    
    $response = '';
    
    while(!feof($fp))
    {
        $response .= fgets($fp, 128);
    }
    
    fclose($fp);
}
echo $response;



Link to comment
Share on other sites

Well, you still have to do some validation and retrieve the correct values from $_POST, but yes.

 

Edit: but that code only outputs the response. You have to do something with it (like check if the transaction was successful).

 

Oh, and I forgot to add ssl:// to the url, that's why it didn't work. Though I'm not getting back any data using these credentials.

Link to comment
Share on other sites

Well, I don't know what to tell you then. I've build a little on that script, creating some small classes. It send this to their server by GET over SSL. This is in complete compliance with the API in the doc.

 

<enMobileAPI>
<AuthorisationRequest msisdn="27820001234" pin="1234">
	<AutomaticSettlement>true</AutomaticSettlement>
	<BudgetPeriod>00</BudgetPeriod>
	<CardPresent>false</CardPresent>
	<ClientTel></ClientTel>
	<Reference></Reference>
	<CardNumber>4242424242424242</CardNumber>
	<Cv2>123</Cv2>
	<ExpiryDate>1110</ExpiryDate>
	<Amount>100.00</Amount>
	<ReconReference>123456798</ReconReference>
</AuthorisationRequest>
</enMobileAPI>

 

Classes:

 

<?php
class LinqException extends Exception {}

abstract class LinqRequest
{   
    protected $_data = array();
    
    /**
     * Session
     *
     * @var LinqSession
     */
    private $_session;
   
    public function setSession(LinqSession $session)
    {
        $this->_session = $session;
    }
    
    /**
     * get the Request session
     *
     * @return LinqSession
     */
    public function getSession()
    {
        return $this->_session;
    }
    
    public function setClientTel($string)
    {
        $this->_data['ClientTel'] = $string;
        
        return $this;
    }
    
    public function setReference($string)
    {
        $this->_data['Reference'] = $string;
        
        return $this;
    }
    
    abstract public function asXml();

}
class LinqRequestDefault extends LinqRequest
{   
    /**
     * Default data values
     *
     * @var unknown_type
     */
    protected $_data = array(
        'AutomaticSettlement' => 'true',
        'BudgetPeriod' => '00',
        'CardPresent' => 'false',
        'ClientTel' => null,
        'Reference' => null
    );
    
    public function __construct($cardNumber, $cv2, $exp, $amount, $reconRef)
    {
        $this->_data['CardNumber'] = $cardNumber;
        $this->_data['Cv2'] = $cv2;
        $this->_data['ExpiryDate'] = $exp;
        $this->_data['Amount'] = $amount;
        $this->_data['ReconReference'] = $reconRef;
    }
        
    public function asXml()
    {
        $xml = "<AuthorisationRequest msisdn=\"{$this->getSession()->getMsisdn()}\" pin=\"{$this->getSession()->getPin()}\">";
        
        foreach($this->_data as $key => $value)
        {
            $xml .= "<$key>$value</$key>";
        }
        
        $xml .= "</AuthorisationRequest>";
        
        return "<enMobileAPI>$xml</enMobileAPI>";
    }

}

class LinqResponse
{
    private $_raw;
    
    public function __construct($raw)
    {
        $this->_raw = $raw;
    }
}

class LinqSession
{
    private $_msisdn;
    private $_pin;
    
    
    public function __construct($msisdn, $pin)
    {
        $this->_msisdn = $msisdn;
        $this->_pin = $pin;
    }

    public function getMsisdn()
    {
        return $this->_msisdn;
    }
    
    public function getPin()
    {
        return $this->_pin;
    }
}

class LinqGateway
{
    private $_host;
    
    private $_location;
    
    private $_ssl;
    
    private $_port;
    
    /**
     * Reqeuest session
     *
     * @var LinqSession
     */
    private $_session;
    
    public function __construct($host, $location, $ssl = true, $port = null)
    {
        $this->_host = $host;
        
        $this->_location = $location;

        $this->_ssl = $ssl;
    }
    
    public function startSession(LinqSession $session)
    {
        $this->_session = $session;
    }
    
    public function getHost()
    {
        return $this->_host;
    }
    
    public function getLocation()
    {
        return $this->_location;
    }
    
    public function getProtocol()
    {
        return $this->_ssl ? 'ssl' : 'tcp';
    }
    
    public function getPort()
    {
        if($this->_port === null)
        {
            return $this->_ssl ? 443 : 80;
        }
        return $this->_port;
    }
    
    public function request(LinqRequest $request)
    {
        $fp = fsockopen("{$this->getProtocol()}://{$this->getHost()}", $this->getPort(), $errno, $errstr, 30);

        if(!$fp)
        {
            throw new LinqException("$errstr ($errno)");
        }
        else
        {
            $request->setSession($this->_session);
            
            $out = "GET {$this->getLocation()}?xmlData=" . rawurlencode($request->asXml()) . " HTTP/1.1\r\n";
            $out .= "Host: www.vwire.co.za\r\n";
            $out .= "Connection: Close\r\n\r\n";
            
            fwrite($fp, $out);
            
            $response = '';
            
            while(!feof($fp))
            {
                $response .= fgets($fp, 128);
            }
            
            fclose($fp);
        } 

        return new LinqResponse($response);
    }
}

 

Usage:

 

<?php
$gateway = new LinqGateway('www.vwire.co.za', '/vapp/XML-Landing2.jsp');

$gateway->startSession(new LinqSession('27820001234', '1234'));

$request = new LinqRequestDefault('4242424242424242', '123', '1110', '100.00', '123456798');

$response1 = $gateway->request($request);

var_dump(htmlspecialchars($request->asXml()), $response1);

 

Maybe the given credentials are wrong?

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.