include "Sfa/BillToAddress.php"; include "Sfa/CardInfo.php"; include "Sfa/Merchant.php"; include "Sfa/MPIData.php"; include "Sfa/ShipToAddress.php"; include "Sfa/PGResponse.php"; include "Sfa/PostLibPHP.php"; include "Sfa/PGReserveData.php"; $oMPI = new MPIData(); $oCI = new CardInfo(); $oPostLibphp = new PostLibPHP(); $oMerchant = new Merchant(); $oBTA = new BillToAddress(); $oSTA = new ShipToAddress(); $oPGResp = new PGResponse(); $oPGReserveData = new PGReserveData(); $oMerchant->setMerchantDetails("00012849", "00012849", "00012849", "193.545.34.33", rand() . "", "Ord123", $baseurl . "payment/SFAResponse.php", "POST", "INR", "INV123", "req.Sale", $applicationfees, "", "Ext1", "true", "Ext3", "Ext4", "Ext5"); $oBTA->setAddressDetails("CID", "Tester", "JBIMS", "Mumbai", "Maharashtra", "Test", "Test", "Test", "IND", "*****@*****.**"); $oSTA->setAddressDetails("Add1", "Add2", "Add3", "City", "State", "443543", "IND", "*****@*****.**"); $INRapplicationfees = "INR" . $applicationfees; $applicationfeespaisa = $applicationfees * 100; $oMPI->setMPIRequestDetails($applicationfeespaisa, $INRapplicationfees, "356", "2", "JBIMS Admission", "", "", "", "0", "", "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd.ms-powerpoint, application/vnd.ms-excel, application/msword, application/x-shockwave-flash, */*", "Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.0)"); $oPGReserveData->setReserveObj($applicationid, $applicantName, $applicantemailid, $applicationfees, "5", "6", "7", "8", "9", "10"); $oPGResp = $oPostLibphp->postSSL($oBTA, $oSTA, $oMerchant, $oMPI, $oPGReserveData); if ($oPGResp->getRespCode() == '000') { $url = $oPGResp->getRedirectionUrl(); //$url =~ s/http/https/; //print "Location: ".$url."\n\n"; //header("Location: ".$url); redirect($url); } else {
function postAuth($aoMerchant, $aoCInfo, $aoPGResp, $oPSD, $aoReserveData) { $ojMerchant = new Merchant(); $ojCInfo = new CardInfo(); //$oPGResp = new Java('com.opus.epg.sfa.java.PGResponse'); //$ojPSD = new Java('com.opus.epg.sfa.java.PaySecureDetails'); $ojReserveData = new PGReserveData(); $oPostLib = new PostLibPHP(); $oPGResphp = new PGResponse(); ## Mandetory checks for Merchant objects # check for Merchant id and the Message type # ## if ($aoMerchant == null) { $oPGResphp->setRespCode("2"); $oPGResphp->setRespMessage(" Merchant object is null"); return $oPGResphp; } if ($aoMerchant->getMerchantID() == null || $aoMerchant->getMerchantID() == "") { $oPGResphp->setRespCode("2"); $oPGResphp->setRespMessage(" Merchant id is null or Invalid"); return $oPGResphp; } if ($aoMerchant->getMessageType() == null || $aoMerchant->getMessageType() == "") { $oPGResphp->setRespCode("2"); $oPGResphp->setRespMessage(" Message type is null."); return $oPGResphp; } if ($oPSD->getPaysecureResp() == null || $oPSD->getPaysecureResp() == "") { $oPGResphp->setRespCode("2"); $oPGResphp->setRespMessage(" Invalid Paysecure Response. Transaction cannot be processed."); return $oPGResphp; } if ($oPSD->getPaySecureTxnID() == null || $oPSD->getPaySecureTxnID() == "") { $oPGResphp->setRespCode("2"); $oPGResphp->setRespMessage(" Invalid PaySecure Txn Id. Transaction cannot be processed."); return $oPGResphp; } if ($oPSD->getAuthAmount() == null || $oPSD->getAuthAmount() == "") { $oPGResphp->setRespCode("2"); $oPGResphp->setRespMessage(" Error. Auth Amount is Invalid."); return $oPGResphp; } if ($oPSD->getCardAcceptorID() == null || $oPSD->getCardAcceptorID() == "") { $oPGResphp->setRespCode("2"); $oPGResphp->setRespMessage(" Error. Card Acceptor/Merchant Id is Invalid."); return $oPGResphp; } if ($oPSD->getCurrCode() == null || $oPSD->getCurrCode() == "") { $oPGResphp->setRespCode("2"); $oPGResphp->setRespMessage(" Invalid Currency code. Transaction cannot be processed."); return $oPGResphp; } # Assigning Merchant object of php to Merchant object of java Sfa $ojMerchant->setMerchantDetails($aoMerchant->getMerchantID(), $aoMerchant->getVendor(), $aoMerchant->getPartner(), $aoMerchant->getCustIPAddress(), $aoMerchant->getMerchantTxnID(), $aoMerchant->getOrderReferenceNo(), $aoMerchant->getRespURL(), $aoMerchant->getRespMethod(), $aoMerchant->getCurrCode(), $aoMerchant->getInvoiceNo(), $aoMerchant->getMessageType(), $aoMerchant->getAmount(), $aoMerchant->getGMTTimeOffset(), $aoMerchant->getExt1(), $aoMerchant->getExt2(), $aoMerchant->getExt3(), $aoMerchant->getExt4(), $aoMerchant->getExt5()); # Assigning Card Info object of php to Card info object of java Sfa if ($aoCInfo != null || $aoCInfo != "") { $ojCInfo->setCardDetails($aoCInfo->getCardType(), $aoCInfo->getCardNum(), $aoCInfo->getCVVNum(), $aoCInfo->getExpDtYr(), $aoCInfo->getExpDtMon(), $aoCInfo->getNameOnCard(), $aoCInfo->getInstrType()); } if ($aoReserveData != null || $aoReserveData != "") { $ojReserveData->setReserveObj($aoReserveData->getReserveField1(), $aoReserveData->getReserveField2(), $aoReserveData->getReserveField3(), $aoReserveData->getReserveField4(), $aoReserveData->getReserveField5(), $aoReserveData->getReserveField6(), $aoReserveData->getReserveField7(), $aoReserveData->getReserveField8(), $aoReserveData->getReserveField9(), $aoReserveData->getReserveField10()); } $strData = $this->buildMerchantBillShip($aoMerchant, null, null); $oEncryptionUtilenc = new EncryptionUtil(); $strMotoEncryptedData = $aoMerchant->getMerchantID() . trim($aoMerchant->getMerchantTxnID()) . trim($aoMerchant->getCustIPAddress()) . trim($aoMerchant->getAmount()) . trim($aoMerchant->getMessageType()) . trim($aoMerchant->getCurrCode()) . trim($aoMerchant->getInvoiceNo()) . trim($aoCInfo->getCardNum()) . trim($aoCInfo->getExpDtYr()) . trim($aoCInfo->getExpDtMon()) . $aoCInfo->getCVVNum(); $sDigest = $oEncryptionUtilenc->getHMAC($strMotoEncryptedData, trim($this->mstrKeyDir) . $aoMerchant->getMerchantID() . '.key', $aoMerchant->getMerchantID()); if ($sDigest == null || $sDigest == "") { if ($this->verbose != null && trim($this->verbose) == "true") { error_log("Error in Encrypting/Hashing Merchant Data.Transaction cannot proceed.", 0); } $oPGResphp->setRespCode("2"); $oPGResphp->setRespMessage(" Error while encrypting/hashing data. Transaction cannot be processed."); return $oPGResphp; } $strData = $strData . '&EncryptedData=' . $sDigest; $strData = $strData . '&IntfVer=ASPV2.0'; $strData = $strData . '&OsType=' . trim($this->mstrOSType); $strData = $strData . '&LanguageType=php'; $strData = $strData . '&CustIPAddress=' . $aoMerchant->getCustIPAddress(); $strData = $strData . '&InstrType=' . $aoCInfo->getInstrType(); $strData = $strData . '&CardType=' . $aoCInfo->getCardType(); $strData = $strData . '&CardNum=' . $aoCInfo->getCardNum(); $strData = $strData . '&ExpDtYr=' . $aoCInfo->getExpDtYr(); $strData = $strData . '&ExpDtMon=' . $aoCInfo->getExpDtMon(); $strData = $strData . '&CVVNum=' . $aoCInfo->getCVVNum(); $strData = $strData . '&NameOnCard=' . $aoCInfo->getNameOnCard(); if ($aoMPI == null || $aoMPI == "") { $strData = $strData . '&status=""'; $strData = $strData . '&cavv=""'; $strData = $strData . '&eci=""'; $strData = $strData . '&xid=""'; $strData = $strData . '&purchaseAmount=""'; $strData = $strData . '¤cyVal=""'; $strData = $strData . '&shoppingcontext=""'; } else { $strData = $strData . '&status=' . $aoMPI->getVBVStatus(); $strData = $strData . '&cavv=' . $aoMPI->getCAVV(); $strData = $strData . '&eci=' . $aoMPI->getECI(); $strData = $strData . '&xid=' . $aoMPI->getXID(); $strData = $strData . '&purchaseAmount=' . $aoMPI->getPurchaseAmount(); $strData = $strData . '¤cyVal=' . $aoMPI->getCurrencyVal(); $strData = $strData . '&shoppingcontext=' . $aoMPI->getShoppingContext(); } $strData = $strData . '&Reserve1=' . $aoReserveData->getReserveField1(); $strData = $strData . '&Reserve2=' . $aoReserveData->getReserveField2(); $strData = $strData . '&Reserve3=' . $aoReserveData->getReserveField3(); $strData = $strData . '&Reserve4=' . $aoReserveData->getReserveField4(); $strData = $strData . '&Reserve5=' . $aoReserveData->getReserveField5(); $strData = $strData . '&Reserve6=' . $aoReserveData->getReserveField6(); $strData = $strData . '&Reserve7=' . $aoReserveData->getReserveField7(); $strData = $strData . '&Reserve8=' . $aoReserveData->getReserveField8(); $strData = $strData . '&Reserve9=' . $aoReserveData->getReserveField9(); $strData = $strData . '&Reserve10=' . $aoReserveData->getReserveField10(); $strData = $strData . '&WsErrCode=' . $aoReserveData->getWsErrCode(); $strData = $strData . '&WsErrMsg=' . $aoReserveData->getWsErrMsg(); $strData = $strData . '&WsExponent=' . $aoReserveData->getWsExponent(); $strData = $strData . '&WsGuid=' . $aoReserveData->getWsGuid(); $strData = $strData . '&WsModulus=' . $aoReserveData->getWsModulus(); $strData = $strData . '&WsTxnId=' . $aoReserveData->getWsTxnId(); $oPGResp = $this->postData(trim($this->motoURL), trim($ojReserveData)); # Assigning PGResponse objects of java to PGResponse object of php $oPGResphp->setRespCode($oPGResp->getRespCode()); $oPGResphp->setRespMessage($oPGResp->getRespMessage()); $oPGResphp->setTxnId($oPGResp->getTxnId()); $oPGResphp->setEpgTxnId($oPGResp->getEpgTxnId()); $oPGResphp->setAuthIdCode($oPGResp->getAuthIdCode()); $oPGResphp->setRRN($oPGResp->getRRN()); $oPGResphp->setCVRespCode($oPGResp->getCVRespCode()); $oPGResphp->setReserveFld1($oPGResp->getReserveFld1()); $oPGResphp->setReserveFld2($oPGResp->getReserveFld2()); $oPGResphp->setReserveFld3($oPGResp->getReserveFld3()); $oPGResphp->setReserveFld4($oPGResp->getReserveFld4()); $oPGResphp->setReserveFld5($oPGResp->getReserveFld5()); $oPGResphp->setReserveFld6($oPGResp->getReserveFld6()); $oPGResphp->setReserveFld7($oPGResp->getReserveFld7()); $oPGResphp->setReserveFld8($oPGResp->getReserveFld8()); $oPGResphp->setReserveFld9($oPGResp->getReserveFld9()); $oPGResphp->setReserveFld10($oPGResp->getReserveFld10()); # Returning PGResponse object of php return $oPGResphp; }