Worldpay payment gateway integration php



1.Create a test Account in World-pay
2.Get worldpay merchant Id and Installation Id
3.Before the passing the Payment details to payment Gateway we need to store
 the details of what we are passing such as unique id,amount,product id like that
4.Befor making a test payment we are required to upload two files to the worldpay server
5.They are resultC.html and resultY.html
6.the content in this html are below
7.resultY.html is called after the successful payment and this page will be refreshed after 2 seconds


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<meta http-equiv="refresh" content="2;url=Baseurl/success?transId=
<WPDISPLAY ITEM=transId>&cartId=<WPDISPLAY ITEM=cartId>&transStatus=<WPDISPLAY ITEM=transStatus>">

8.resultC.html is called after the Failed/cancelled payment and this page will be refreshed after 2 seconds
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<meta http-equiv="refresh" content="2;url=Baseurl/error?transId=
<WPDISPLAY ITEM=transId>&cartId=<WPDISPLAY ITEM=cartId>&transStatus=<WPDISPLAY ITEM=transStatus>">

9. These two files are to be Uploaded worldpay server before the payment and never send that to production
push to production only 8 hrs before production release only

10.After saving the details just render the form and make that form auto submit

++++++++++++++++++++++++++ Auto submit form +++++++++++++

    //for Test details
            $worldPayUrl = "https://secure-test.wp3.rbsworldpay.com/wcc/purchase";
            $paymentmode = 100;

    //for Production details
            $worldPayUrl = "https://secure.wp3.rbsworldpay.com/wcc/purchase";
            $paymentmode = 0;

      <form name="worldpaypayment" action="<?=$worldPayUrl;?>" onsubmit="return orderDisable();" onload="submit();"  method="post">
       <input type="hidden" name="instId" value="installId" />
       <input type="hidden" name="currency" value="GBP" />
       <input type="hidden" name="testMode" value="<?=$paymentmode?>" />
       <input type="hidden" name="amount" id="amount" value="TotalPrice" />
       <input type="hidden" name="name" id="firstname" value="firstname" />
       <input type="hidden" name="postcode" id="postcode" size="7"  value="PostalCode" />
       <input type="hidden" name="email" id="email" value="email" />
       <input type="hidden" name="address" id="address"  value="BillingAddress" />
       <input type="hidden" name="name" value="CAPTURED" />
       <input type="hidden" name="cartId" value="unique id" />
       <input type='hidden' name="accId1" value="accId1" />
       <input type='hidden' name="country" value="GB"/>
       <input type="hidden" name="desc" value="product description" />


11.After the successful Payment worldpay will send the details to our application

12. the details contain $resp_data[];
    $transactionKey = $resp_data['transId'];//this is the transaction id that is
//send by the world pay to check in there cms for later verification

        $cartId         = $resp_data['cartId'];
        $transStatus    = $resp_data['transStatus'];
if($transStatus  == "Y"){
get the details of the purchase from the DB with the $cartId(Unique id)
an update the details
}else{//transaction failed
//redirect to error page