0

Im trying to create a payment system that integrates with eWay .. They have supplied some code for processing payments, except when i run it im getting the following error:

Message: Undefined index: value

Line Number: 106

The function that line 106 references is as follows:

    function parseResponse($xmlResponse){
    $xml_parser = xml_parser_create();
    xml_parse_into_struct($xml_parser, $xmlResponse, $xmlData, $index);
    $responseFields = array();
    foreach($xmlData as $xData)
        if($xData["level"] == 2)
            $responseFields[$xData["tag"]] = $xData["value"];
    return $responseFields;
    }

Im really stuck on this, i cant seem to get it working.

Any help on diagnosing this would be fantastic.

Cheers,

The XML im trying to parse is as follows

<ewaygateway>
<ewayCustomerID>87654321</ewayCustomerID>
<ewayTotalAmount>44000</ewayTotalAmount>
<ewayCardHoldersName>Testing Test</ewayCardHoldersName>
<ewayCardNumber>4444333322221111</ewayCardNumber>
<ewayCardExpiryMonth>04</ewayCardExpiryMonth>
<ewayCardExpiryYear>15</ewayCardExpiryYear>
<ewayCustomerFirstName>Testing test</ewayCustomerFirstName>
<ewayCustomerLastName>Testing test</ewayCustomerLastName>
<ewayCustomerEmail>[email protected]</ewayCustomerEmail>
<ewayCustomerAddress>123 Testing St</ewayCustomerAddress>
<ewayCustomerPostcode>2000</ewayCustomerPostcode>
<ewayCustomerInvoiceDescription>Membership</ewayCustomerInvoiceDescription>
<ewayCustomerInvoiceRef>00001</ewayCustomerInvoiceRef>
<ewayTrxnNumber>000001</ewayTrxnNumber>
<ewayOption1>Nice</ewayOption1>
<ewayOption2>Big</ewayOption2>
<ewayOption3>Option</ewayOption3>
</ewaygateway>

Also, this is how the xml is being generated

        $xmlRequest = "<ewaygateway><ewayCustomerID>" . $this->myCustomerID . "</ewayCustomerID>";
    foreach($this->myTransactionData as $key=>$value)
        $xmlRequest .= "<$key>$value</$key>";
    $xmlRequest .= "</ewaygateway>";
2
  • Any chance you could post the XML you're trying to parse? Commented Apr 10, 2011 at 4:46
  • I have added the XML, also the offending line is $responseFields[$xData["tag"]] = $xData["value"]; .... Also, if everything is perfect and the credit card is valid, no errors are returned .... but if a wrong credit card number is entered it brings up the error Commented Apr 10, 2011 at 5:08

1 Answer 1

1

The <ewaygateway> tag has no value. Just check to make sure the value index exists with isset.

Sign up to request clarification or add additional context in comments.

4 Comments

Reason: it's the root tag. Contained tags don't count as values.
Hey, thanks for your response ... Im not sure what you mean, is there any chance you could show me an example of what i should try?
Bascially, I meant to change $responseFields[$xData["tag"]] = $xData["value"]; to $responseFields[$xData["tag"]] = isset($xData["value"]) ? $xData["value"] : null;. Afterward, you can test to see if any of the values are null to find out if the user omitted some info without causing the notice to trigger.
Ohh, that has worked fantastic ... fixed all the errors ... Thank you so much!!!!!!!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.