Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6892815
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:34:54+00:00 2026-05-27T06:34:54+00:00

I am writing a PHP script to take credit card & customer details on

  • 0

I am writing a PHP script to take credit card & customer details on my site, send these details invisibly to Worldpay’s server for processing and then take action based on the response (paid, failed etc).

My problem is that I can’t seem to authenticate with Worldpay when sending my XML – I’ve replaced MYMERCHANTCODE with the proper merchant code. This is the code I am using – it is based on Worldpay’s example:

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="MYMERCHANTCODE">
    <submit>
        <order orderCode="T0211010">

              <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="2009"/>
                      </expiryDate>
                      <cardHolderName>J. Shopper</cardHolderName>
                      <cvc>123</cvc>
                      <cardAddress>
                          <address>
                               <street>47A Queensbridge Rd</street>
                               <postalCode>CB94BQ</postalCode>
                               <countryCode>GB</countryCode>
                          </address>
                      </cardAddress>
                   </VISA-SSL>
                   <session shopperIPAddress="123.123.123.123" id="0215ui8ib1" />
              </paymentDetails>

              <shopper>
                  <shopperEmailAddress>jshopper@myprovider.int</shopperEmailAddress>
                  <browser> [This example uses firefox 3.5.5 to demonstrate]
                       <acceptHeader>text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8</acceptHeader>
                       <userAgentHeader>Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.1.5) Gecko/20091102 Firefox/3.5.5 (.NET CLR 3.5.30729)</userAgentHeader>
                   </browser>
               </shopper>

        </order>
   </submit>
</paymentService>';

$dest='https://secure-test.wp3.rbsworldpay.com/jsp/merchant/xml/paymentService.jsp'; //for sandbox
//$dest='https://secure.wp3.rbsworldpay.com/jsp/merchant/xml/paymentService.jsp' //for production

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

When I run this, this is what is output:

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>401 Authorization Required</title>
</head><body>
<h1>Authorization Required</h1>
<p>This server could not verify that you
are authorized to access the document
requested. Either you supplied the wrong
credentials (e.g., bad password), or your
browser doesn't understand how to supply
the credentials required.</p>
</body></html>

Can someone please help with this? The documentation says to add your IP address for requests to your Worldpay account, which I think I have done correctly.

Many thanks

UPDATE:

I’ve just realised that if I add my merchant ID & xml password before the URL, eg:

$dest='https://MERCHANTID:PASSWORD@secure-test.wp3.rbsworldpay.com/jsp/merchant/xml/paymentService.jsp';

It then authenticates, so I will answer my own question.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T06:34:55+00:00Added an answer on May 27, 2026 at 6:34 am

    I realised that if I add my merchant ID & xml password before the URL, eg:

    $dest='https://MERCHANTID:PASSWORD@secure-test.wp3.rbsworldpay.com/jsp/merchant/xml/paymentService.jsp';
    

    It then authenticates. Hopefully this will save someone time as I couldn’t find this in the documentation.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In a PHP script I am writing, I need to send a control+z character
I'm writing this cURL script in PHP. It's purpose is to take a product
Im writing a php script to compare the similarity of 2 strings. This works
I'm writing a PHP script and the script outputs a simple text file log
I'm writing a PHP script that does a lot of repetitive work, and when
I am writing a PHP script to add items to a shopping basket. My
I'm writing a php script to crop an image. The script overwrites the 'old'
I'm writing a PHP script that downloads a series of generated files (using wget
I'm writing a php script to export MySQL database rows into a .txt file
I'm writing a PHP script that builds an SQL query by concatenating the string

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.