Wednesday, May 16, 2012

Direct post integration eway

Create a eWay account. go: http://www.eway.com.au/developers/partners/become-a-partner.html

Post data as:

<form action="https://www.eway.com.au/gateway/payment.asp" method="post" name="formEWay">
<input type="hidden" name="ewayCustomerID" value=""/>
<input type="hidden" name="ewayTotalAmount" value=""/>
<input type="hidden" name="ewayCustomerFirstName" value=""/>
<input type="hidden" name="ewayCustomerLastName" value=""/>
<input type="hidden" name="ewayCustomerEmail" value=""/>
<input type="hidden" name="ewayCustomerAddress" value=""/>
<input type="hidden" name="ewayCustomerPostcode" value=""/>
<input type="hidden" name="ewayCustomerInvoiceDescription" value="Purchase Order - 10"/>
<input type="hidden" name="ewayCustomerInvoiceRef" value=""/>
<input type="hidden" name="eWAYURL" value="http://dom.com/ewayreturn.php"/>
<input type="hidden" name="eWAYSiteTitle" value="<?php echo $_SERVER["SERVER_NAME"] ?>"/>
<input type="hidden" name="eWAYAutoRedirect" value="1"/>
<input type="hidden" name="eWAYTrxnNumber" value=""/>
<input type="submit" value="Process Secure Credit Card Transaction using eWay"/>
</form>

After return from eway, try the following.
if(isset($_POST['ewayTrxnReference']) && isset($_POST['ewayTrxnStatus']) && isset($_POST['ewayTrxnNumber'])) {
    $orderStatus = "Open";
    $pGateResult = "false";
    $txn_id = $_POST['ewayTrxnReference'];
    $result = $_POST['ewayTrxnStatus'];
    $order_number = $_POST['ewayTrxnNumber'];
    $returnAmount = 0;
    if(isset($_POST["eWAYReturnAmount"])) {
        $returnAmount = $this->getValueReturnedFromeWay($_POST["eWAYReturnAmount"]);
    }
    if (!empty($result) && strcmp('True', trim($result)) == 0) {
         $pGateResult = "true";
         $orderStatus = "Paid";
    }
}

1 comment: