16.1.12

Worldpay direct xml integration php





  • Worldpay Direct XML
  1. submit orders with payment details
  2. send a modification for the order
  3. perform an inquiry to request the payment status of the order
  4. When setting up the HTTP(s) connection over which you will send XML orders, remember to use a valid login and password.
  • <amount value="1982" currencyCode="EUR" exponent="2"/>
       Exponent is the number of decimals available in the currency.
       Also note that currency code is always in capitals.
  • <order orderCode="T0211010">
     Ordercode should be different for every payment
  • <countryCode>GB</countryCode>
      The countryCode element is used in XML orders/communications,

      it is an upper-case two-letter 'ISO 3166' standard country code    

                  Worldpay-direct-xml

require_once 'HTTP/Request.php';

$xml='<?xml version="1.0"? encoding="UTF-8"?>
<!DOCTYPE paymentService PUBLIC "-//WorldPay//DTD WorldPay PaymentService v1//EN""http://dtd.worldpay.com/paymentService_v1.dtd">
<paymentService version="1.4" merchantCode="WPACC11112222">
    <submit>
        <order orderCode="T021101078">
              <description>20 Tulip Bulbs from MYMERCHANT Webshops</description>
              <amount value="2600" currencyCode="EUR" exponent="2"/>
              <paymentDetails>
                  <VISA-SSL>
                      <cardNumber>4444333322221111</cardNumber>
                      <expiryDate>
                          <date month="09" year="2015"/>
                      </expiryDate>
                      <cardHolderName>Akhilraj</cardHolderName>
                      <cvc>123</cvc>
                      <cardAddress>
                          <address>
                               <street>47A Queensbridge Rd</street>
                               <postalCode>CB94BQ</postalCode>
                               <countryCode>GB</countryCode>
                          </address>
                      </cardAddress>
                   </VISA-SSL>
                   <session shopperIPAddress="'.$_SERVER['SERVER_ADDR'].'" id="0215ui8ib1" />
              </paymentDetails>
              <shopper>
                  <shopperEmailAddress>dfgdf@gmail.com</shopperEmailAddress>
                  <browser>
                       <acceptHeader>'.$_SERVER['HTTP_ACCEPT'].'</acceptHeader>
                       <userAgentHeader>'.$_SERVER['HTTP_USER_AGENT'].'</userAgentHeader>
                   </browser>
               </shopper>
        </order>
   </submit>
</paymentService>';


$posturl='https://MERCHANTID:PASSWORD@secure-test.wp3.rbsworldpay.com/jsp/merchant/xml/paymentService.jsp'; // for testing worldpay MERCHANTID in capitals
//$posturl='https://secure.wp3.rbsworldpay.com/jsp/merchant/xml/paymentService.jsp' //for worldpay production

$req = new HTTP_Request($posturl);
$req->setMethod(HTTP_REQUEST_METHOD_POST);
$req->addHeader('Connection', 'keep-alive');
$req->addRawPostData($xml);
$req->sendRequest();
$req->getResponseBody();
echo nl2br(htmlentities($req->getResponseBody()));


      Response for successful Payment

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE paymentService PUBLIC "-//WorldPay//DTD WorldPay PaymentService v1//EN" "http://dtd.worldpay.com/paymentService_v1.dtd">
<paymentService version="1.4" merchantCode="MYMERCHANT WPACC11112222">
    <reply>
        <orderStatus orderCode="T0211010">
             <payment>
             <paymentMethod>VISA-SSL</paymentMethod>
             <amount value="2600" currencyCode="EUR" exponent="2" debitCreditIndicator="credit"/>
             <lastEvent>AUTHORISED</lastEvent>
             <CVCResultCode description="APPROVED"/>
                 <balance accountType="IN_PROCESS_AUTHORISED">
                      <amount value="2600" currencyCode="EUR" exponent="2"debitCreditIndicator="credit"/>
                 </balance> <cardNumber>4444********1111</cardNumber>
                 <riskScore value="0"/>
             </payment>
        </orderStatus>
    </reply>
</paymentService>

For Unsuccessful Payment

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE paymentService PUBLIC "-//WorldPay//DTD WorldPay PaymentService v1//EN""http://dtd.worldpay.com/paymentService_v1.dtd">
<paymentService version="1.4" merchantCode="MYMERCHANT WPACC11112222">
   <reply>
       <orderStatus orderCode="T0211010">
           <payment>
               <paymentMethod>VISA-SSL</paymentMethod>
               <amount value="2600" currencyCode="EUR" exponent="2"debitCreditIndicator="credit"/>
               <lastEvent>REFUSED</lastEvent>
               <CVCResultCode description="NOT SUPPLIED BY SHOPPER"/>
               <ISO8583ReturnCode code="5" description="REFUSED"/>
               <riskScore value="0"/>
           </payment>
       </orderStatus>
   </reply>
</paymentService>

  • <lastEvent>AUTHORISED</lastEvent>
     The payment status is specified by the lastEvent element.

  • <ISO8583ReturnCode code="5" description="REFUSED"/>
     The element ISO8583ReturnCode shows the refusal response code from the    acquirer and a mapped description from WorldPay.

  • 0 AUTHORISED
  • 85 REJECTED BY CARD ISSUER
  • 2 REFERRED
  • 91 CREDITCARD ISSUER TEMPORARILY NOT REACHABLE
  • 4 HOLD CARD
  • 97 SECURITY BREACH
  • 5 REFUSED
  • 3 INVALID ACCEPTOR
  • 8 APPROVE AFTER IDENTIFICATION
  • 12 INVALID TRANSACTION
  • 13 INVALID AMOUNT
  • 14 INVALID ACCOUNT
  • 15 INVALID CARD ISSUER
  • 19 REPEAT OF LAST TRANSACTION
  • 17 ANNULATION BY CLIENT
  • 20 ACQUIRER ERROR
  • 28 ACCESS DENIED
  • 21 REVERSAL NOT PROCESSED, MISSING AUTHORISATION
  • 29 IMPOSSIBLE REFERENCE NUMBER
  • 24 UPDATE OF FILE IMPOSSIBLE
  • 33 CARD EXPIRED
  • 25 REFERENCE NUMBER CANNOT BE FOUND
  • 34 FRAUD SUSPICION
  • 26 DUPLICATE REFERENCE NUMBER
  • 38 SECURITY CODE EXPIRED
  • 27 ERROR IN REFERENCE NUMBER FIELD
  • 41 LOST CARD
  • 30 FORMAT ERROR
  • 43 STOLEN CARD, PICK UP
  • 31 UNKNOWN ACQUIRER ACCOUNT CODE
  • 51 LIMIT EXCEEDED
  • 40 REQUESTED FUNCTION NOT SUPPORTED
  • 55 INVALID SECURITY CODE
  • 58 TRANSACTION NOT PERMITTED
  • 56 UNKNOWN CARD
  • 64 AMOUNT HIGHER THAN PREVIOUS TRANSACTION AMOUNT
  • 57 ILLEGAL TRANSACTION
  • 68 TRANSACTION TIMED OUT
  • 62 RESTRICTED CARD
  • 80 AMOUNT NO LONGER AVAILABLE, AUTHORISATION EXPIRED
  • 63 SECURITY RULES VIOLATED   
  • 92 CREDITCARD TYPE NOT PROCESSED BY ACQUIRER
  • 75 SECURITY CODE INVALID
  • 94 DUPLICATE REQUEST
  • 76 CARD BLOCKED