Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Nov 2011
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    PHP performing on XML response

    I send off this:

    PHP Code:
    <?php
        $data 
    "<egateway>
                <eCardExpiryMonth>01</eCardExpiryMonth>
                <eCardExpiryYear>04</eCardExpiryYear>
                <eCardHoldersName>Joe Bloke</eCardHoldersName>
                <eCardNumber>4444333322221111</eCardNumber>
                <eCVN>123</eCVN>
                <eTotalAmount>100</eTotalAmount>
            </egateway>
            "
    ;
        
    $ch curl_init();
        
    curl_setopt($chCURLOPT_POSTFIELDS$edata);
        
    curl_setopt($chCURLOPT_URL"https://www.example.com/gateway_cvn/testpage.asp");
        
    curl_exec($ch);
        
    curl_close($ch);
    ?>
    In return, I get the following XML:

    Code:
    <eResponse>
    	<eTrxnStatus>True</eTrxnStatus>
    	<eTrxnNumber>20219</eTrxnNumber>
    	<eAuthCode>123456</eAuthCode>
    	<eReturnAmount>100</eReturnAmount>
    	<eTrxnError>00,Transaction Approved(Test CVN Gateway)</eTrxnError>
    </eResponse>
    Is there a way to make it so this does not show, and instead I can make PHP do something like:

    if (eTrxnStatus == True) {// do stuff};

    ?

  • #2
    New to the CF scene
    Join Date
    Nov 2011
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I'm using:

    PHP Code:
    $response simplexml_load_string(curl_exec($ch));
        if (
    $response -> eTrxnStatus == 'True') {
            echo 
    "True 1111111111111.";
        } 
    ... but getting these errors:
    PHP Warning:
    simplexml_load_string(): Entity: line 1: parser error : Start tag expected, '<' not found
    simplexml_load_string(): 1
    simplexml_load_string(): ^

    PHP Notice: Trying to get property of non-object
    The response code I am getting back in XML is:
    Code:
    <eResponse><eTrxnStatus>True</eTrxnStatus><eTrxnNumber>11673</eTrxnNumber><eTrxnReference/><eReturnAmount>100</eReturnAmount><eTrxnError>00,Transaction Approved(Test CVN Gateway)</eTrxnError></eResponse>
    What could be causing this? I can't make any sense of it at all!

  • #3
    New to the CF scene
    Join Date
    Nov 2011
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I solved the problem with:

    PHP Code:
    curl_setopt($chCURLOPT_RETURNTRANSFER1); 


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •